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: https://svn.code.sf.net/p/freeglut/code/trunk@1855 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
jtsiomb 2019-09-25 10:08:07 +00:00
parent ff0bded3ea
commit dda17d2506
4 changed files with 12 additions and 6 deletions

View File

@ -1166,7 +1166,7 @@ SFG_Proc fgPlatformGetProcAddress( const char *procName );
#define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);} #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
int fghMapBit( int mask, int from, int to ); int fghMapBit( int mask, int from, int to );
int fghIsLegacyContextRequested( void ); int fghIsLegacyContextRequested( SFG_Window *win );
void fghContextCreationError( void ); void fghContextCreationError( void );
int fghNumberOfAuxBuffersRequested( void ); int fghNumberOfAuxBuffersRequested( void );

View File

@ -62,9 +62,15 @@ extern void fgPlatformGlutSetIconTitle( const char* title );
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- 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 ) int fghNumberOfAuxBuffersRequested( void )

View File

@ -145,7 +145,7 @@ void fgNewWGLCreateContext( SFG_Window* window )
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
/* If nothing fancy has been required, leave the context as it is */ /* If nothing fancy has been required, leave the context as it is */
if ( fghIsLegacyContextRequested() ) if ( fghIsLegacyContextRequested(window) )
{ {
return; return;
} }

View File

@ -220,14 +220,14 @@ GLXContext fghCreateNewContext( SFG_Window* window )
CreateContextAttribsProc createContextAttribs = (CreateContextAttribsProc) fgPlatformGetProcAddress( "glXCreateContextAttribsARB" ); CreateContextAttribsProc createContextAttribs = (CreateContextAttribsProc) fgPlatformGetProcAddress( "glXCreateContextAttribsARB" );
/* glXCreateContextAttribsARB not found, yet the user has requested the new context creation */ /* 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" ); fgWarning( "OpenGL >2.1 context requested but glXCreateContextAttribsARB is not available! Falling back to legacy context creation" );
fgState.MajorVersion = 2; fgState.MajorVersion = 2;
fgState.MinorVersion = 1; fgState.MinorVersion = 1;
} }
/* If nothing fancy has been required, simply use the old context creation GLX API entry */ /* 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 ); context = glXCreateNewContext( dpy, config, render_type, share_list, direct );
if ( context == NULL ) { if ( context == NULL ) {