John Fay: Implement the modified logic of the direct/indirect rendering context.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@501 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
c28e19b830
commit
ae113a8850
@ -59,8 +59,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
||||
{ 300, 300, GL_TRUE }, /* Size */
|
||||
GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
|
||||
GL_FALSE, /* Initialised */
|
||||
GL_FALSE, /* ForceDirectContext */
|
||||
GL_TRUE, /* TryDirectContext */
|
||||
GLUT_TRY_DIRECT_CONTEXT, /* DirectContext */
|
||||
GL_FALSE, /* ForceIconic */
|
||||
GL_FALSE, /* UseCurrentContext */
|
||||
GL_FALSE, /* GLDebugSwitch */
|
||||
@ -273,8 +272,7 @@ void fgDeinitialize( void )
|
||||
|
||||
fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
|
||||
|
||||
fgState.ForceDirectContext = GL_FALSE;
|
||||
fgState.TryDirectContext = GL_TRUE;
|
||||
fgState.DirectContext = GLUT_TRY_DIRECT_CONTEXT;
|
||||
fgState.ForceIconic = GL_FALSE;
|
||||
fgState.UseCurrentContext = GL_FALSE;
|
||||
fgState.GLDebugSwitch = GL_FALSE;
|
||||
@ -570,21 +568,21 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
||||
}
|
||||
else if( strcmp( argv[ i ], "-direct" ) == 0)
|
||||
{
|
||||
if( ! fgState.TryDirectContext )
|
||||
if( fgState.DirectContext == GLUT_FORCE_INDIRECT_CONTEXT )
|
||||
fgError( "parameters ambiguity, -direct and -indirect "
|
||||
"cannot be both specified" );
|
||||
|
||||
fgState.ForceDirectContext = GL_TRUE;
|
||||
fgState.DirectContext = GLUT_FORCE_DIRECT_CONTEXT;
|
||||
argv[ i ] = NULL;
|
||||
( *pargc )--;
|
||||
}
|
||||
else if( strcmp( argv[ i ], "-indirect" ) == 0 )
|
||||
{
|
||||
if( fgState.ForceDirectContext )
|
||||
if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
|
||||
fgError( "parameters ambiguity, -direct and -indirect "
|
||||
"cannot be both specified" );
|
||||
|
||||
fgState.TryDirectContext = GL_FALSE;
|
||||
fgState.DirectContext = GLUT_FORCE_INDIRECT_CONTEXT;
|
||||
argv[ i ] = NULL;
|
||||
(*pargc)--;
|
||||
}
|
||||
|
@ -222,8 +222,7 @@ struct tagSFG_State
|
||||
|
||||
GLboolean Initialised; /* freeglut has been initialised */
|
||||
|
||||
GLboolean ForceDirectContext; /* Force direct rendering? */
|
||||
GLboolean TryDirectContext; /* What about giving a try to? */
|
||||
int DirectContext; /* Direct rendering state */
|
||||
|
||||
GLboolean ForceIconic; /* New top windows are iconified */
|
||||
GLboolean UseCurrentContext; /* New windows share with current */
|
||||
|
@ -108,6 +108,10 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
|
||||
( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
fgState.DirectContext = value;
|
||||
break;
|
||||
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
if( fgStructure.Window != NULL )
|
||||
fgStructure.Window->State.Cursor = value;
|
||||
@ -463,6 +467,10 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
||||
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
|
||||
: GLUT_CREATE_NEW_CONTEXT;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
return fgState.DirectContext;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
|
||||
break;
|
||||
|
@ -389,14 +389,14 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
|
||||
fgStructure.MenuContext->Context = glXCreateContext(
|
||||
fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
|
||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
||||
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||
);
|
||||
}
|
||||
|
||||
/* window->Window.Context = fgStructure.MenuContext->Context; */
|
||||
window->Window.Context = glXCreateContext(
|
||||
fgDisplay.Display, window->Window.VisualInfo,
|
||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
||||
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||
);
|
||||
}
|
||||
else if( fgState.UseCurrentContext )
|
||||
@ -406,19 +406,24 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
if( ! window->Window.Context )
|
||||
window->Window.Context = glXCreateContext(
|
||||
fgDisplay.Display, window->Window.VisualInfo,
|
||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
||||
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||
);
|
||||
}
|
||||
else
|
||||
window->Window.Context = glXCreateContext(
|
||||
fgDisplay.Display, window->Window.VisualInfo,
|
||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
||||
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||
);
|
||||
|
||||
if( fgState.ForceDirectContext &&
|
||||
!glXIsDirect( fgDisplay.Display, window->Window.Context ) )
|
||||
fgError( "unable to force direct context rendering for window '%s'",
|
||||
if( !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
|
||||
{
|
||||
if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
|
||||
fgError( "Unable to force direct context rendering for window '%s'",
|
||||
title );
|
||||
else if( fgState.DirectContext == GLUT_TRY_DIRECT_CONTEXT )
|
||||
fgWarning( "Unable to create direct context rendering for window '%s'\nThis may hurt performance.",
|
||||
title );
|
||||
}
|
||||
|
||||
glXMakeCurrent(
|
||||
fgDisplay.Display,
|
||||
|
Reference in New Issue
Block a user