Refactoring only (replace nested conditionals with guard clauses), making the normal path of execution much clearer.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@770 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
3a8ad4ac32
commit
c6a956ed14
@ -302,58 +302,66 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar
|
|||||||
|
|
||||||
GLboolean fgNewWGLCreateContext( SFG_Window* window )
|
GLboolean fgNewWGLCreateContext( SFG_Window* window )
|
||||||
{
|
{
|
||||||
|
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetEntensionsStringARB;
|
||||||
|
|
||||||
if( (fgState.ContextFlags & GLUT_FORWARD_COMPATIBLE) &&
|
if( (fgState.ContextFlags & GLUT_FORWARD_COMPATIBLE) &&
|
||||||
(fgState.MajorVersion > 2) )
|
(fgState.MajorVersion > 2) )
|
||||||
{
|
{
|
||||||
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetEntensionsStringARB=NULL;
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
wglMakeCurrent( window->Window.Device,
|
wglMakeCurrent( window->Window.Device,
|
||||||
window->Window.Context );
|
window->Window.Context );
|
||||||
|
|
||||||
wglGetEntensionsStringARB=(PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
|
wglGetEntensionsStringARB=(PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
if (wglGetEntensionsStringARB)
|
if ( wglGetEntensionsStringARB == NULL )
|
||||||
{
|
{
|
||||||
const char * pWglExtString=wglGetEntensionsStringARB(window->Window.Device);
|
return GL_TRUE;
|
||||||
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;
|
const char * pWglExtString=wglGetEntensionsStringARB(window->Window.Device);
|
||||||
attribs[1] = fgState.MajorVersion;
|
if ( pWglExtString == NULL )
|
||||||
attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
{
|
||||||
attribs[3] = fgState.MinorVersion;
|
return GL_TRUE;
|
||||||
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 ( strstr(pWglExtString, "WGL_ARB_create_context") == NULL )
|
||||||
if ( wglCreateContextAttribsARB == NULL )
|
{
|
||||||
{
|
return GL_TRUE;
|
||||||
fgError( "wglCreateContextAttribsARB not found" );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context = wglCreateContextAttribsARB( window->Window.Device, 0, attribs );
|
/* new context creation */
|
||||||
if ( context == NULL )
|
HGLRC context;
|
||||||
{
|
int attribs[7];
|
||||||
fgError( "Unable to create OpenGL %d.%d context (flags %x)",
|
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||||
fgState.MajorVersion, fgState.MinorVersion, fgState.ContextFlags );
|
|
||||||
}
|
attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB;
|
||||||
else
|
attribs[1] = fgState.MajorVersion;
|
||||||
{
|
attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
||||||
fgWarning( "Success 3.0" );
|
attribs[3] = fgState.MinorVersion;
|
||||||
wglMakeCurrent( NULL, NULL );
|
attribs[4] = WGL_CONTEXT_FLAGS_ARB;
|
||||||
wglDeleteContext( window->Window.Context );
|
attribs[5] = ((fgState.ContextFlags & GLUT_DEBUG) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0) |
|
||||||
window->Window.Context = context;
|
((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 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgWarning( "Success 3.0" );
|
||||||
|
wglMakeCurrent( NULL, NULL );
|
||||||
|
wglDeleteContext( window->Window.Context );
|
||||||
|
window->Window.Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
Reference in New Issue
Block a user