XF86 game mode fixes, context sharing option. (John Fay)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@108 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
brianp 2003-06-27 15:10:06 +00:00
parent 261ab8820d
commit 482f4b2bc5
6 changed files with 57 additions and 22 deletions

View File

@ -39,6 +39,12 @@
#define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1 #define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1
#define GLUT_ACTION_CONTINUE_EXECUTION 2 #define GLUT_ACTION_CONTINUE_EXECUTION 2
/*
* Create a new rendering context when the user opens a new window?
*/
#define GLUT_CREATE_NEW_CONTEXT 0
#define GLUT_USE_CURRENT_CONTEXT 1
/* /*
* GLUT API Extension macro definitions -- the glutGet parameters * GLUT API Extension macro definitions -- the glutGet parameters
*/ */
@ -49,6 +55,8 @@
#define GLUT_VERSION 0x01FC #define GLUT_VERSION 0x01FC
#define GLUT_RENDERING_CONTEXT 0x01FD
/* /*
* Process loop function, see freeglut_main.c * Process loop function, see freeglut_main.c
*/ */

View File

@ -61,6 +61,7 @@ SFG_State fgState = { { -1, -1, FALSE }, /* Position */
FALSE, /* ForceDirectContext */ FALSE, /* ForceDirectContext */
TRUE, /* TryDirectContext */ TRUE, /* TryDirectContext */
FALSE, /* ForceIconic */ FALSE, /* ForceIconic */
FALSE, /* UseCurrentContext */
FALSE, /* GLDebugSwitch */ FALSE, /* GLDebugSwitch */
FALSE, /* XSyncSwitch */ FALSE, /* XSyncSwitch */
TRUE, /* IgnoreKeyRepeat */ TRUE, /* IgnoreKeyRepeat */
@ -306,6 +307,7 @@ void fgDeinitialize( void )
fgState.ForceDirectContext = FALSE; fgState.ForceDirectContext = FALSE;
fgState.TryDirectContext = TRUE; fgState.TryDirectContext = TRUE;
fgState.ForceIconic = FALSE; fgState.ForceIconic = FALSE;
fgState.UseCurrentContext = FALSE;
fgState.GLDebugSwitch = FALSE; fgState.GLDebugSwitch = FALSE;
fgState.XSyncSwitch = FALSE; fgState.XSyncSwitch = FALSE;
fgState.ActionOnWindowClose = GLUT_ACTION_EXIT ; fgState.ActionOnWindowClose = GLUT_ACTION_EXIT ;
@ -395,7 +397,8 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
/* check if GLUT_FPS env var is set */ /* check if GLUT_FPS env var is set */
{ {
const char *fps = getenv ( "GLUT_FPS" ); const char *fps = getenv ( "GLUT_FPS" );
if (fps) { if ( fps )
{
sscanf ( fps, "%d", &fgState.FPSInterval ) ; sscanf ( fps, "%d", &fgState.FPSInterval ) ;
if ( fgState.FPSInterval <= 0 ) if ( fgState.FPSInterval <= 0 )
fgState.FPSInterval = 5000 ; /* 5000 milliseconds */ fgState.FPSInterval = 5000 ; /* 5000 milliseconds */

View File

@ -219,6 +219,7 @@ struct tagSFG_State
GLboolean TryDirectContext; /* What about giving a try to? */ GLboolean TryDirectContext; /* What about giving a try to? */
GLboolean ForceIconic; /* All new top windows are iconified */ GLboolean ForceIconic; /* All new top windows are iconified */
GLboolean UseCurrentContext; /* New windows use current window's rendering context */
GLboolean GLDebugSwitch; /* OpenGL state debugging switch */ GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
GLboolean XSyncSwitch; /* X11 sync protocol switch */ GLboolean XSyncSwitch; /* X11 sync protocol switch */
@ -260,6 +261,11 @@ struct tagSFG_Display
Atom DeleteWindow; /* The window deletion atom */ Atom DeleteWindow; /* The window deletion atom */
#ifdef X_XF86VidModeGetModeLine #ifdef X_XF86VidModeGetModeLine
/*
* XF86VidMode may be compilable even if it fails at runtime. Therefore,
* the validity of the VidMode has to be tracked
*/
int DisplayModeValid; /* Flag that indicates runtime status*/
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */ XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
int DisplayModeClock; /* The display mode's refresh rate */ int DisplayModeClock; /* The display mode's refresh rate */
#endif #endif

View File

@ -1175,8 +1175,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE ); fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
/* /*
* Create the OpenGL rendering context now * Create or get the OpenGL rendering context now
*/ */
if ( fgState.UseCurrentContext == TRUE )
window->Window.Context = wglGetCurrentContext();
else
window->Window.Context = wglCreateContext( window->Window.Device ); window->Window.Context = wglCreateContext( window->Window.Device );
/* /*
@ -1287,8 +1290,20 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
*/ */
if( fgStructure.Window == window ) if( fgStructure.Window == window )
{ {
int used = FALSE ;
SFG_Window *iter ;
wglMakeCurrent( NULL, NULL ); wglMakeCurrent( NULL, NULL );
wglDeleteContext( window->Window.Context ); /* Step through the list of windows. If the rendering context is notbeing used
* by another window, then we delete it.
*/
for ( iter = fgStructure.Windows.First; iter; iter = iter->Node.Next )
{
if ( ( iter->Window.Context == window->Window.Context ) && ( iter != window ) )
used = TRUE ;
}
if ( used == FALSE ) wglDeleteContext( window->Window.Context );
} }
/* /*

View File

@ -104,6 +104,9 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
case GLUT_ACTION_ON_WINDOW_CLOSE: fgState.ActionOnWindowClose = value ; case GLUT_ACTION_ON_WINDOW_CLOSE: fgState.ActionOnWindowClose = value ;
break ; break ;
case GLUT_RENDERING_CONTEXT: fgState.UseCurrentContext = ( value == GLUT_USE_CURRENT_CONTEXT ) ? TRUE : FALSE ;
break ;
case GLUT_WINDOW_CURSOR: case GLUT_WINDOW_CURSOR:
if( fgStructure.Window != NULL ) fgStructure.Window->State.Cursor = value ; if( fgStructure.Window != NULL ) fgStructure.Window->State.Cursor = value ;
break ; break ;
@ -364,8 +367,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
/* /*
* ...then we've got to correct the results we've just received... * ...then we've got to correct the results we've just received...
*/ */
if (fgStructure.GameMode != fgStructure.Window && if ( ( fgStructure.GameMode != fgStructure.Window ) && ( fgStructure.Window->Parent == NULL ) )
fgStructure.Window->Parent == NULL )
{ {
winRect.left += GetSystemMetrics( SM_CXSIZEFRAME ); winRect.left += GetSystemMetrics( SM_CXSIZEFRAME );
winRect.right -= GetSystemMetrics( SM_CXSIZEFRAME ); winRect.right -= GetSystemMetrics( SM_CXSIZEFRAME );
@ -457,6 +459,9 @@ int FGAPIENTRY glutGet( GLenum eWhat )
case GLUT_VERSION : case GLUT_VERSION :
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH ; return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH ;
case GLUT_RENDERING_CONTEXT:
return ( fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT : GLUT_CREATE_NEW_CONTEXT ) ;
default: default:
/* /*
* Just have it reported, so that we can see what needs to be implemented * Just have it reported, so that we can see what needs to be implemented

View File

@ -2,9 +2,7 @@
/* This file has been automatically generated by the genstroke utility. */ /* This file has been automatically generated by the genstroke utility. */
#include "freeglut_internal.h" #include "freeglut_internal.h"
//#ifdef TARGET_HOST_WIN32
//#pragma warning ( once:4305 )
//#endif
/* char: 0x20 */ /* char: 0x20 */
static const SFG_StrokeStrip ch32st[] = static const SFG_StrokeStrip ch32st[] =