X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_window.c;h=8027e6b4aeb5d8715cf606d46a925104e8cbe1be;hb=aa51f2a733292a31345da9aa5167558496ef1915;hp=b474bf9860a9b81f204f1f35fc7c9782af22b4d4;hpb=cee42b093ecb1b342236464ba5d051f08904a36e;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index b474bf9..8027e6b 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -300,63 +300,61 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar #endif -GLboolean fgNewWGLCreateContext( SFG_Window* window ) +void fgNewWGLCreateContext( SFG_Window* window ) { - if( (fgState.ContextFlags & GLUT_FORWARD_COMPATIBLE) && - (fgState.MajorVersion > 2) ) + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetEntensionsStringARB; + HGLRC context; + int attribs[7]; + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; + const char * pWglExtString; + + /* If nothing fancy has been required, leave the context as it is */ + if ( fgState.MajorVersion == 1 && fgState.MinorVersion == 0 && fgState.ContextFlags == 0 ) { - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetEntensionsStringARB=NULL; + return; + } - wglMakeCurrent( window->Window.Device, - window->Window.Context ); + wglMakeCurrent( window->Window.Device, + window->Window.Context ); - wglGetEntensionsStringARB=(PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); - if (wglGetEntensionsStringARB) - { - const char * pWglExtString=wglGetEntensionsStringARB(window->Window.Device); - if (pWglExtString) - { - if (strstr(pWglExtString, "WGL_ARB_create_context")) - { - /* new context creation */ - HGLRC context; - int attribs[7]; - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; - - attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB; - attribs[1] = fgState.MajorVersion; - attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB; - attribs[3] = fgState.MinorVersion; - attribs[4] = WGL_CONTEXT_FLAGS_ARB; - attribs[5] = ((fgState.ContextFlags & GLUT_DEBUG) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0) | - ((fgState.ContextFlags & GLUT_FORWARD_COMPATIBLE) ? WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB : 0); - attribs[6] = 0; - - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress( "wglCreateContextAttribsARB" ); - if ( wglCreateContextAttribsARB == NULL ) - { - fgError( "wglCreateContextAttribsARB not found" ); - } + wglGetEntensionsStringARB=(PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); + if ( wglGetEntensionsStringARB == NULL ) + { + return; + } - context = wglCreateContextAttribsARB( window->Window.Device, 0, attribs ); - if ( context == NULL ) - { - fgError( "Unable to create OpenGL %d.%d context (flags %x)", - fgState.MajorVersion, fgState.MinorVersion, fgState.ContextFlags ); - } - else - { - fgWarning( "Success 3.0" ); - wglMakeCurrent( NULL, NULL ); - wglDeleteContext( window->Window.Context ); - window->Window.Context = context; - } - } - } - } + pWglExtString=wglGetEntensionsStringARB(window->Window.Device); + if (( pWglExtString == NULL ) || ( strstr(pWglExtString, "WGL_ARB_create_context") == NULL )) + { + return; } - return GL_TRUE; + /* new context creation */ + attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB; + attribs[1] = fgState.MajorVersion; + attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB; + attribs[3] = fgState.MinorVersion; + attribs[4] = WGL_CONTEXT_FLAGS_ARB; + attribs[5] = ((fgState.ContextFlags & GLUT_DEBUG) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0) | + ((fgState.ContextFlags & GLUT_FORWARD_COMPATIBLE) ? WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB : 0); + attribs[6] = 0; + + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress( "wglCreateContextAttribsARB" ); + if ( wglCreateContextAttribsARB == NULL ) + { + fgError( "wglCreateContextAttribsARB not found" ); + } + + context = wglCreateContextAttribsARB( window->Window.Device, 0, attribs ); + if ( context == NULL ) + { + fgError( "Unable to create OpenGL %d.%d context (flags %x)", + fgState.MajorVersion, fgState.MinorVersion, fgState.ContextFlags ); + } + + wglMakeCurrent( NULL, NULL ); + wglDeleteContext( window->Window.Context ); + window->Window.Context = context; }