begin process at 2012 02 10 18:24:04
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C

 > 

Linux

 > 

OpenGL

 > 

Pb Multisampling


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Pb Multisampling

lundi 7 mai 2007 à 14:50:23 | Pb Multisampling

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



Cette discussion est classée dans : hdc, pfd, arb, mmechostr, wgl


Répondre à ce message

Sujets en rapport avec ce message

probleme openGl niveau debutant [ par AmK ] salut je debute en openGL et j'ai du mal a creer une fenetre le compilateur me mets 2 erreurs :PS: les erreurs du compilateur(vc++ 6.0)sont plus bas ! De l'openGL sur le bureau [ par Alcantornet ] Hello le peuple, J'ai fait une petite horloge en openGL et j'aimerais pouvoir la mettre à la place de l'arrière plan. Je pense qu'il faut que je lie Plusieurs contexte [ par charliejo ] Bonjour, J'ai le code suivant pour créer plusieurs context.   int pf, maxpf;    PIXELFORMATDESCRIPTOR pfd;    LAYERPLANEDESCRIPTOR&n Choosepixelformat & Setpixelformat [ par mondrone ] Voila, je developpe actuellement sur dev-c++, et l'utilisation de ces deux fonctions me renvoie une erreur de linkage. Je voudrais donc savoir ce qui redimentionnement d'image, aidez-moi svp [ par sousou_one ] salut à tous,je veux construire une bitmap par copie d'une région d'une bitmap source, je dois prendre les nouvelles dimensions en sélectionnant la ré OpenGL map blending [ par dletozeun ] bonjour, Dans mon projet je genere un terrain sur lequel j'applique une texture (roche par exemple) avec opengl. Maintenant je voudrais gerer le mult scintillement et HDC [ par DormeurDev ] Pour éviter le scintillement dû au rafraîchissement dans des appliqcation graphique on utilise un buffer pour dessiner avant d'afficher. Comment mett Probleme avec une fonction de rotation [ par SnOOpss ] voila ma fonction HBITMAP rotate90(HBITMAP hbmp) { BITMAP bm; GetObject((HBITMAP)hbmp, sizeof(bm), &bm); BITMAPINFO bi,biNew; biNew.bmiHeader.biSiz Clignotement avec GDI [ par unrealgun ] Bonjour,Je viens de commencer la programmation en C++, j'utilise DEV-CPP et j'ai un probleme avec GDI : j'utilise la fonction RECANGLE pour dessiner, HBTMAP de l'écran [ par clem0338 ] Bonjour, J'essaie de récupérer un Handle du bitmap de l'écran HDC hDC = GetDC( 0 ); // DC de l'écran HBITMAP hBm; GetObject( hDC, sizeof( hBm ), &h


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 4,274 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales