begin process at 2008 07 20 23:10:53
1 213 505 membres
406 nouveaux aujourd'hui
14 167 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : Pb Multisampling [ Linux / OpenGL ] (mehdithe)

Pb Multisampling le 07/05/2007 14:50:23

mehdithe
//////////////////////////////////////////////////////////////////////////////////////////////
///        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 ;
    }
                
    
}



Classé sous : hdc, pfd, arb, mmechostr, wgl

Participer à cet échange

Pub



Appels d'offres

Dessins techniques
Budget : 60€
Animation Flash - Doma...
Budget : 370€
Application flash medi...
Budget : 1 000€

Snippets en rapport

CalendriCode

Juillet 2008
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS