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_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
*/
@ -49,6 +55,8 @@
#define GLUT_VERSION 0x01FC
#define GLUT_RENDERING_CONTEXT 0x01FD
/*
* Process loop function, see freeglut_main.c
*/

View File

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

View File

@ -219,6 +219,7 @@ struct tagSFG_State
GLboolean TryDirectContext; /* What about giving a try to? */
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 XSyncSwitch; /* X11 sync protocol switch */
@ -260,6 +261,11 @@ struct tagSFG_Display
Atom DeleteWindow; /* The window deletion atom */
#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 */
int DisplayModeClock; /* The display mode's refresh rate */
#endif

View File

@ -1175,8 +1175,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
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 );
/*
@ -1287,8 +1290,20 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
*/
if( fgStructure.Window == window )
{
int used = FALSE ;
SFG_Window *iter ;
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 ;
break ;
case GLUT_RENDERING_CONTEXT: fgState.UseCurrentContext = ( value == GLUT_USE_CURRENT_CONTEXT ) ? TRUE : FALSE ;
break ;
case GLUT_WINDOW_CURSOR:
if( fgStructure.Window != NULL ) fgStructure.Window->State.Cursor = value ;
break ;
@ -364,8 +367,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
/*
* ...then we've got to correct the results we've just received...
*/
if (fgStructure.GameMode != fgStructure.Window &&
fgStructure.Window->Parent == NULL )
if ( ( fgStructure.GameMode != fgStructure.Window ) && ( fgStructure.Window->Parent == NULL ) )
{
winRect.left += GetSystemMetrics( SM_CXSIZEFRAME );
winRect.right -= GetSystemMetrics( SM_CXSIZEFRAME );
@ -452,10 +454,13 @@ int FGAPIENTRY glutGet( GLenum eWhat )
return( fgListLength( &fgStructure.Menu->Entries ) );
case GLUT_ACTION_ON_WINDOW_CLOSE:
return fgState.ActionOnWindowClose;
return fgState.ActionOnWindowClose ;
case GLUT_VERSION:
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
case GLUT_VERSION :
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:
/*

View File

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