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 */
|
{ 300, 300, GL_TRUE }, /* Size */
|
||||||
GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
|
GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */
|
||||||
GL_FALSE, /* Initialised */
|
GL_FALSE, /* Initialised */
|
||||||
GL_FALSE, /* ForceDirectContext */
|
GLUT_TRY_DIRECT_CONTEXT, /* DirectContext */
|
||||||
GL_TRUE, /* TryDirectContext */
|
|
||||||
GL_FALSE, /* ForceIconic */
|
GL_FALSE, /* ForceIconic */
|
||||||
GL_FALSE, /* UseCurrentContext */
|
GL_FALSE, /* UseCurrentContext */
|
||||||
GL_FALSE, /* GLDebugSwitch */
|
GL_FALSE, /* GLDebugSwitch */
|
||||||
@ -273,8 +272,7 @@ void fgDeinitialize( void )
|
|||||||
|
|
||||||
fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
|
fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
|
||||||
|
|
||||||
fgState.ForceDirectContext = GL_FALSE;
|
fgState.DirectContext = GLUT_TRY_DIRECT_CONTEXT;
|
||||||
fgState.TryDirectContext = GL_TRUE;
|
|
||||||
fgState.ForceIconic = GL_FALSE;
|
fgState.ForceIconic = GL_FALSE;
|
||||||
fgState.UseCurrentContext = GL_FALSE;
|
fgState.UseCurrentContext = GL_FALSE;
|
||||||
fgState.GLDebugSwitch = GL_FALSE;
|
fgState.GLDebugSwitch = GL_FALSE;
|
||||||
@ -570,21 +568,21 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
}
|
}
|
||||||
else if( strcmp( argv[ i ], "-direct" ) == 0)
|
else if( strcmp( argv[ i ], "-direct" ) == 0)
|
||||||
{
|
{
|
||||||
if( ! fgState.TryDirectContext )
|
if( fgState.DirectContext == GLUT_FORCE_INDIRECT_CONTEXT )
|
||||||
fgError( "parameters ambiguity, -direct and -indirect "
|
fgError( "parameters ambiguity, -direct and -indirect "
|
||||||
"cannot be both specified" );
|
"cannot be both specified" );
|
||||||
|
|
||||||
fgState.ForceDirectContext = GL_TRUE;
|
fgState.DirectContext = GLUT_FORCE_DIRECT_CONTEXT;
|
||||||
argv[ i ] = NULL;
|
argv[ i ] = NULL;
|
||||||
( *pargc )--;
|
( *pargc )--;
|
||||||
}
|
}
|
||||||
else if( strcmp( argv[ i ], "-indirect" ) == 0 )
|
else if( strcmp( argv[ i ], "-indirect" ) == 0 )
|
||||||
{
|
{
|
||||||
if( fgState.ForceDirectContext )
|
if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
|
||||||
fgError( "parameters ambiguity, -direct and -indirect "
|
fgError( "parameters ambiguity, -direct and -indirect "
|
||||||
"cannot be both specified" );
|
"cannot be both specified" );
|
||||||
|
|
||||||
fgState.TryDirectContext = GL_FALSE;
|
fgState.DirectContext = GLUT_FORCE_INDIRECT_CONTEXT;
|
||||||
argv[ i ] = NULL;
|
argv[ i ] = NULL;
|
||||||
(*pargc)--;
|
(*pargc)--;
|
||||||
}
|
}
|
||||||
|
@ -222,8 +222,7 @@ struct tagSFG_State
|
|||||||
|
|
||||||
GLboolean Initialised; /* freeglut has been initialised */
|
GLboolean Initialised; /* freeglut has been initialised */
|
||||||
|
|
||||||
GLboolean ForceDirectContext; /* Force direct rendering? */
|
int DirectContext; /* Direct rendering state */
|
||||||
GLboolean TryDirectContext; /* What about giving a try to? */
|
|
||||||
|
|
||||||
GLboolean ForceIconic; /* New top windows are iconified */
|
GLboolean ForceIconic; /* New top windows are iconified */
|
||||||
GLboolean UseCurrentContext; /* New windows share with current */
|
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;
|
( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GLUT_DIRECT_RENDERING:
|
||||||
|
fgState.DirectContext = value;
|
||||||
|
break;
|
||||||
|
|
||||||
case GLUT_WINDOW_CURSOR:
|
case GLUT_WINDOW_CURSOR:
|
||||||
if( fgStructure.Window != NULL )
|
if( fgStructure.Window != NULL )
|
||||||
fgStructure.Window->State.Cursor = value;
|
fgStructure.Window->State.Cursor = value;
|
||||||
@ -463,6 +467,10 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
|||||||
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
|
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
|
||||||
: GLUT_CREATE_NEW_CONTEXT;
|
: GLUT_CREATE_NEW_CONTEXT;
|
||||||
|
|
||||||
|
case GLUT_DIRECT_RENDERING:
|
||||||
|
return fgState.DirectContext;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
|
fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
|
||||||
break;
|
break;
|
||||||
|
@ -389,14 +389,14 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
|||||||
fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
|
fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
|
||||||
fgStructure.MenuContext->Context = glXCreateContext(
|
fgStructure.MenuContext->Context = glXCreateContext(
|
||||||
fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
|
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 = fgStructure.MenuContext->Context; */
|
||||||
window->Window.Context = glXCreateContext(
|
window->Window.Context = glXCreateContext(
|
||||||
fgDisplay.Display, window->Window.VisualInfo,
|
fgDisplay.Display, window->Window.VisualInfo,
|
||||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if( fgState.UseCurrentContext )
|
else if( fgState.UseCurrentContext )
|
||||||
@ -406,19 +406,24 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
|||||||
if( ! window->Window.Context )
|
if( ! window->Window.Context )
|
||||||
window->Window.Context = glXCreateContext(
|
window->Window.Context = glXCreateContext(
|
||||||
fgDisplay.Display, window->Window.VisualInfo,
|
fgDisplay.Display, window->Window.VisualInfo,
|
||||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
window->Window.Context = glXCreateContext(
|
window->Window.Context = glXCreateContext(
|
||||||
fgDisplay.Display, window->Window.VisualInfo,
|
fgDisplay.Display, window->Window.VisualInfo,
|
||||||
NULL, fgState.ForceDirectContext | fgState.TryDirectContext
|
NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
|
||||||
);
|
);
|
||||||
|
|
||||||
if( fgState.ForceDirectContext &&
|
if( !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
|
||||||
!glXIsDirect( fgDisplay.Display, window->Window.Context ) )
|
{
|
||||||
fgError( "unable to force direct context rendering for window '%s'",
|
if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
|
||||||
|
fgError( "Unable to force direct context rendering for window '%s'",
|
||||||
title );
|
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(
|
glXMakeCurrent(
|
||||||
fgDisplay.Display,
|
fgDisplay.Display,
|
||||||
|
Reference in New Issue
Block a user