IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Pb avec le Multisampling


Sujet :

OpenGL

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 5
    Points : 4
    Points
    4
    Par défaut Pb avec le Multisampling
    Voilà, je travaille actuellement sur l'amélioration d'unmoteur 3D passant par une machine virtuelle qui lance une fenêtre mère sur laquelle vient se placer une fenêtre OpenGL comme fenêtre fille.
    Je désire implémenter le multisampling pour un antialias de toute la scène,
    cependant il m'est impossible de créer un contexte avec une fenêtre par défaut puis de vérifier l'extension pour le multisampling pour supprimer la fenêtre et la recréer après avoir implémenter le multisampling,
    Voici un bout du code qui déterminer le contexte openGL du moteur,
    Je vous remercie d'avance pour tout conseil..
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
     //////////////////////////////////////////////////////////////////////////////////////////////
    ///        CreateMainContext                                                        
    //////////////////////////////////////////////////////////////////////////////////////////////
     
    HGLRC CreateMainContext()
    {
     
          // On définit le context par défault !!
     
        MMechostr ( 1, " ************Définition du Contexte par default!! ********************\n" ) ;
        ZDetector detect ;
        int        pf=0;
        HDC        hdc ;
        PIXELFORMATDESCRIPTOR pfd;
        HWND    hwnd = CreateWindow("scolGL", "scolGL", WS_CHILD, 0, 0, 1, 1, HScol, NULL, NULL, 0);
        hdc = GetDC(hwnd);
        MMechostr(1," *********************** Format de pixel par défaut *********************\n") ;
     
     
            ZeroMemory(&pfd, sizeof(pfd));
            pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
            pfd.nVersion = 1;
            pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER|PFD_TYPE_RGBA|WGL_SAMPLE_BUFFERS_EXT|WGL_SAMPLES_EXT ;
            pfd.iPixelType = PFD_TYPE_RGBA;
            pfd.cColorBits = 32;
            pfd.cDepthBits = 32;
            pfd.cRedBits = 0;
            pfd.cRedShift = 0;
            pfd.cGreenBits = 0;
            pfd.cGreenShift = 0;
            pfd.cBlueBits = 0;
            pfd.cBlueShift = 0;
            pfd.cAlphaBits = 0;
            pfd.cAlphaShift = 0;
            pfd.cAccumBits = 0;
            pfd.cAccumRedBits = 0;
            pfd.cAccumGreenBits = 0;
            pfd.cAccumBlueBits = 0;
            pfd.cAccumAlphaBits = 0;
            pfd.cStencilBits = 0;
            pfd.cAuxBuffers = 0;
            pfd.iLayerType = PFD_MAIN_PLANE;
            pfd.bReserved = 0;
            pfd.dwLayerMask = 0;
            pfd.dwVisibleMask = 0;
            pfd.dwDamageMask = 0;
     
     
        // On créer le contexte OpenGl par défaut
     
            MMechostr(1, "***************** Contexte openGL par defaut!!!****************************\n") ;
                if(!(pf = ChoosePixelFormat(hdc, &pfd)))
                        {
                             MMechostr(1, "Failed to choose pixel format." );
                             return NULL;
                         }
     
                    if(!SetPixelFormat(hdc, pf, &pfd))
                         {
                             MMechostr(1, "Failed to set pixel format." );
                            return NULL ;
                        }
     
                mainBPP        = 1;
                mainDEPTH    = pfd.cColorBits;
                mainDBLBUF    = 1;
                mainPIXELFORMAT = pf;
                mainhdc     = hdc;
     
                mainglrc = wglCreateContext(hdc);
     
                if(wglGetCurrentContext()!=mainglrc)        wglMakeCurrent(hdc,mainglrc);
            if ( detect.WGLisExtensionSupported ("GL_ARB_multisample") == false)
            {
                MMechostr(1, "***************** Le multisampling n'est pas pris en charge****************************\n") ;
                arbMultisampleSupported = false ;
                mainhwnd = hwnd;
                return mainglrc ;
            }
            // Création du nouveau contexte avec prise en charge du multisampling
     
        if ( detect.WGLisExtensionSupported ("GL_ARB_multisample") == true)
            {
                MMechostr(1, "***************** Le format de pixel multisampling est pris en charge!!!****************************\n") ;    
                arbMultisampleSupported = true ;
                int        valid;
                UINT    numFormats;
                float    fAttributes[] = {0,0};
     
                int iAttributes[] =
            {
                WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
                WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
                WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
                WGL_COLOR_BITS_ARB,24,
                WGL_ALPHA_BITS_ARB,8,
                WGL_DEPTH_BITS_ARB,16,
                WGL_STENCIL_BITS_ARB,0,
                WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
                WGL_SAMPLE_BUFFERS_ARB,GL_TRUE,
                WGL_SAMPLES_ARB,4,
                0,0
            };
     
            PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
                MMechostr(1, "--> Chargement du process : OK\n" );
            // First We Check To See If We Can Get A Pixel Format For 4 Samples
            valid = wglChoosePixelFormatARB(hdc,iAttributes,fAttributes,1,&pf,&numFormats) ;
                mainBPP        = 1;
                mainDEPTH    = pfd.cColorBits;
                mainDBLBUF    = 1;
                mainPIXELFORMAT = pf;
                mainhdc     = hdc;
                mainglrc = wglCreateContext(hdc);
                if(wglGetCurrentContext()!=mainglrc)        wglMakeCurrent(hdc,mainglrc);
     
        if(mainglrc)
        {
            if(wglMakeCurrent(NULL,NULL)==FALSE)        MMechostr(1, "------ Can't set the current rendering context to NULL ! ------\n" );
     
            if(wglDeleteContext(mainglrc)==FALSE)        MMechostr(1, "------ Can't delete the MAIN rendering context ! ------\n" );
            else                                        MMechostr(1, "--> mainglrc released : OK\n" );
        }
     
        if(mainhdc) 
        {
            if(ReleaseDC(mainhwnd, mainhdc)==0)            MMechostr(1, "------ Can't release the MAIN device context ! ------\n" );
            else                                        MMechostr(1, "--> mainhdc released : OK\n" );
        }
     
        if(mainhwnd)
        {
            if(DestroyWindow(mainhwnd)==0)                MMechostr(1, "------ Can't destroy the MAIN window ! ------\n" );
            else                                        MMechostr(1, "--> mainhwnd released : OK\n" );
        }
     
                mainhwnd = hwnd;
                return mainglrc ;
                return mainglrc ;
        }
     
     
    }

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    366
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 366
    Points : 440
    Points
    440
    Par défaut
    j ai survole rapidemement ton code et j ai bien l impression que le probleme est que tu cherches a attribuer a une meme fenetre windows (meme HDC) deux fois de suite deux context openGL differents (evec le but d ecraser la premiere attribution par la seconde).

    Pour avoir deja eu le probleme, ce n est pas possible :

    -il te faut creer une seconde fenetre et detruire la premiere

    Par ailleurs, j ai deja vu un code comparable a ce que tu veux (dans le SDK ati ou nvidia je crois) et effectivement ils detruisent la premiere fenetre

  3. #3
    Membre régulier
    Inscrit en
    Juillet 2005
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2005
    Messages : 80
    Points : 85
    Points
    85

  4. #4
    Candidat au Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 5
    Points : 4
    Points
    4
    Par défaut
    Bonjour par ici,

    je déterre ce topic car, évidemment, je rencontre un problème similaire.

    Je connais la solution proposée par smashy et qui fonctionne bien, mais je la trouve un peu radicale.
    La solution proposée par gybe me parait idéale, mais impossible de la faire fonctionner.

    wglChoosePixelFormatARB me renvoie un format qui parait valide (en utilisant DescribePixelFormat et wglGetPixelFormatAttribivARB pour vérifier).
    Mais SetPixelFormat me retourne systèmatiquement 0.

    Je fais comme gybe le décris ici :
    1- Tu te crées un context bidon.

    2- Dans ce Context tu vas chercher la fonction
    wglChoosePixelFormatARB

    3- Tu supprimes ce context.
    4- Ensuite tu crées un nouveau context en utilisant wglChoosePixelFormatARB pour choisir le pixel format

    5- Tu spécifies les attributs du pixel format un peu comme ça:
    Le point 4 ne me parait pas très clair...
    Une fois le ReleaseDC, quand et comment le réactive-t-on ?

Discussions similaires

  1. [DirectX 10] Sauver un backbuffer avec multisampling
    Par korsakoff69 dans le forum DirectX
    Réponses: 0
    Dernier message: 20/11/2012, 10h55
  2. Multisampling avec JOGL sous SWT
    Par goast dans le forum OpenGL
    Réponses: 0
    Dernier message: 08/07/2008, 09h14
  3. Lister les modes de multisampling (avec SDL)
    Par RaphAstronome dans le forum OpenGL
    Réponses: 1
    Dernier message: 19/06/2006, 09h42
  4. Multisampling avec SDL/OpenGl
    Par RaphAstronome dans le forum OpenGL
    Réponses: 2
    Dernier message: 22/05/2006, 17h02
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo