From: John Tsiombikas Date: Wed, 25 Sep 2019 10:08:07 +0000 (+0000) Subject: Fixed bug #252: menu windows are drawn with immediate mode and the fixed X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=7ab67cb06e3e8f5ea8608f30a2973a7a5e351416;hp=3d4680fc4be412ef0cbb62f96fc4f358fb3f9b16;p=freeglut Fixed bug #252: menu windows are drawn with immediate mode and the fixed function pipeline, and therefore we must make sure the context created for them is not a core profile context. Previously if the user requested a core profile context, this would apply to menu windows too, and they would appear black. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1855 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/fg_internal.h b/src/fg_internal.h index 238f8de..2131f4a 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -1166,7 +1166,7 @@ SFG_Proc fgPlatformGetProcAddress( const char *procName ); #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);} int fghMapBit( int mask, int from, int to ); -int fghIsLegacyContextRequested( void ); +int fghIsLegacyContextRequested( SFG_Window *win ); void fghContextCreationError( void ); int fghNumberOfAuxBuffersRequested( void ); diff --git a/src/fg_window.c b/src/fg_window.c index 366bbf3..6efff54 100644 --- a/src/fg_window.c +++ b/src/fg_window.c @@ -62,9 +62,15 @@ extern void fgPlatformGlutSetIconTitle( const char* title ); /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ -int fghIsLegacyContextRequested( void ) +int fghIsLegacyContextRequested( SFG_Window *win ) { - return fgState.MajorVersion < 2 || (fgState.MajorVersion == 2 && fgState.MinorVersion <= 1); + int vmajor = fgState.MajorVersion; + int vminor = fgState.MinorVersion; + /* XXX: menu windows are drawn with the fixed function pipeline, therefore + * the context created for them can't be a modern core-profile context. + * Force the traditional context creation for menu windows. + */ + return vmajor < 2 || (vmajor == 2 && vminor <= 1) || win->IsMenu; } int fghNumberOfAuxBuffersRequested( void ) diff --git a/src/mswin/fg_window_mswin.c b/src/mswin/fg_window_mswin.c index 69a698d..f622630 100644 --- a/src/mswin/fg_window_mswin.c +++ b/src/mswin/fg_window_mswin.c @@ -145,7 +145,7 @@ void fgNewWGLCreateContext( SFG_Window* window ) PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; /* If nothing fancy has been required, leave the context as it is */ - if ( fghIsLegacyContextRequested() ) + if ( fghIsLegacyContextRequested(window) ) { return; } diff --git a/src/x11/fg_window_x11_glx.c b/src/x11/fg_window_x11_glx.c index bbabb75..eccf1d1 100644 --- a/src/x11/fg_window_x11_glx.c +++ b/src/x11/fg_window_x11_glx.c @@ -220,14 +220,14 @@ GLXContext fghCreateNewContext( SFG_Window* window ) CreateContextAttribsProc createContextAttribs = (CreateContextAttribsProc) fgPlatformGetProcAddress( "glXCreateContextAttribsARB" ); /* glXCreateContextAttribsARB not found, yet the user has requested the new context creation */ - if ( !createContextAttribs && !fghIsLegacyContextRequested() ) { + if ( !createContextAttribs && !fghIsLegacyContextRequested(window) ) { fgWarning( "OpenGL >2.1 context requested but glXCreateContextAttribsARB is not available! Falling back to legacy context creation" ); fgState.MajorVersion = 2; fgState.MinorVersion = 1; } /* If nothing fancy has been required, simply use the old context creation GLX API entry */ - if ( fghIsLegacyContextRequested() || !createContextAttribs ) + if ( fghIsLegacyContextRequested(window) || !createContextAttribs ) { context = glXCreateNewContext( dpy, config, render_type, share_list, direct ); if ( context == NULL ) {