Moving the platform-specific FBConfig and device context variables into platform-specific parts of the code
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1014 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
9d8d27aa4f
commit
d918fca3c0
@ -255,6 +255,12 @@ struct tagSFG_PlatformDisplay
|
||||
*/
|
||||
typedef Window SFG_WindowHandleType ;
|
||||
typedef GLXContext SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
GLXFBConfig* FBConfig; /* The window's FBConfig */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@ -438,11 +444,7 @@ struct tagSFG_Context
|
||||
SFG_WindowHandleType Handle; /* The window's handle */
|
||||
SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
|
||||
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
GLXFBConfig* FBConfig; /* The window's FBConfig */
|
||||
#elif TARGET_HOST_MS_WINDOWS
|
||||
HDC Device; /* The window's device context */
|
||||
#endif
|
||||
SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
|
||||
|
||||
int DoubleBuffered; /* Treat the window as double-buffered */
|
||||
};
|
||||
|
@ -66,7 +66,7 @@ static int fghGetConfig( int attribute )
|
||||
|
||||
if( fgStructure.CurrentWindow )
|
||||
result = glXGetFBConfigAttrib( fgDisplay.Display,
|
||||
*(fgStructure.CurrentWindow->Window.FBConfig),
|
||||
*(fgStructure.CurrentWindow->Window.pContext.FBConfig),
|
||||
attribute,
|
||||
&returnValue );
|
||||
|
||||
@ -125,7 +125,7 @@ int fgPlatformGlutGet ( GLenum eWhat )
|
||||
else
|
||||
{
|
||||
const GLXFBConfig * fbconfig =
|
||||
fgStructure.CurrentWindow->Window.FBConfig;
|
||||
fgStructure.CurrentWindow->Window.pContext.FBConfig;
|
||||
|
||||
XVisualInfo * visualInfo =
|
||||
glXGetVisualFromFBConfig( fgDisplay.Display, *fbconfig );
|
||||
|
@ -63,7 +63,7 @@ static void fghClearCallBacks( SFG_Window *window )
|
||||
#if TARGET_HOST_POSIX_X11
|
||||
void fgPlatformCreateWindow ( SFG_Window *window )
|
||||
{
|
||||
window->Window.FBConfig = NULL;
|
||||
window->Window.pContext.FBConfig = NULL;
|
||||
|
||||
window->State.OldHeight = window->State.OldWidth = -1;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ static GLXContext fghCreateNewContext( SFG_Window* window )
|
||||
|
||||
/* "classic" context creation */
|
||||
Display *dpy = fgDisplay.Display;
|
||||
GLXFBConfig config = *(window->Window.FBConfig);
|
||||
GLXFBConfig config = *(window->Window.pContext.FBConfig);
|
||||
int render_type = ( !menu && index_mode ) ? GLX_COLOR_INDEX_TYPE : GLX_RGBA_TYPE;
|
||||
GLXContext share_list = NULL;
|
||||
Bool direct = ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT );
|
||||
@ -548,12 +548,12 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
||||
if( window->IsMenu && ( ! fgStructure.MenuContext ) )
|
||||
fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ;
|
||||
|
||||
window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
|
||||
if( window->IsMenu && ( ! fgStructure.MenuContext ) )
|
||||
fgState.DisplayMode = current_DisplayMode ;
|
||||
|
||||
if( ! window->Window.FBConfig )
|
||||
if( ! window->Window.pContext.FBConfig )
|
||||
{
|
||||
/*
|
||||
* The "fgChooseFBConfig" returned a null meaning that the visual
|
||||
@ -563,25 +563,25 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
||||
if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
|
||||
{
|
||||
fgState.DisplayMode |= GLUT_DOUBLE ;
|
||||
window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
fgState.DisplayMode &= ~GLUT_DOUBLE;
|
||||
}
|
||||
|
||||
if( fgState.DisplayMode & GLUT_MULTISAMPLE )
|
||||
{
|
||||
fgState.DisplayMode &= ~GLUT_MULTISAMPLE ;
|
||||
window->Window.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
window->Window.pContext.FBConfig = fgChooseFBConfig( &num_FBConfigs );
|
||||
fgState.DisplayMode |= GLUT_MULTISAMPLE;
|
||||
}
|
||||
}
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.FBConfig != NULL,
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.pContext.FBConfig != NULL,
|
||||
"FBConfig with necessary capabilities not found", "fgOpenWindow" );
|
||||
|
||||
/* Get the X visual. */
|
||||
for (i = 0; i < num_FBConfigs; i++) {
|
||||
visualInfo = glXGetVisualFromFBConfig( fgDisplay.Display,
|
||||
window->Window.FBConfig[i] );
|
||||
window->Window.pContext.FBConfig[i] );
|
||||
if (visualInfo)
|
||||
break;
|
||||
}
|
||||
@ -750,7 +750,7 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
||||
{
|
||||
if( window->Window.Context )
|
||||
glXDestroyContext( fgDisplay.Display, window->Window.Context );
|
||||
XFree( window->Window.FBConfig );
|
||||
XFree( window->Window.pContext.FBConfig );
|
||||
|
||||
if( window->Window.Handle ) {
|
||||
XDestroyWindow( fgDisplay.Display, window->Window.Handle );
|
||||
|
@ -33,5 +33,5 @@
|
||||
|
||||
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
|
||||
{
|
||||
SwapBuffers( CurrentWindow->Window.Device );
|
||||
SwapBuffers( CurrentWindow->Window.pContext.Device );
|
||||
}
|
||||
|
@ -42,6 +42,12 @@ struct tagSFG_PlatformDisplay
|
||||
*/
|
||||
typedef HWND SFG_WindowHandleType ;
|
||||
typedef HGLRC SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
HDC Device; /* The window's device context */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -329,7 +329,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
"fgPlatformWindowProc" );
|
||||
|
||||
window->Window.Handle = hWnd;
|
||||
window->Window.Device = GetDC( hWnd );
|
||||
window->Window.pContext.Device = GetDC( hWnd );
|
||||
if( window->IsMenu )
|
||||
{
|
||||
unsigned int current_DisplayMode = fgState.DisplayMode;
|
||||
@ -340,7 +340,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
fgState.DisplayMode = current_DisplayMode;
|
||||
|
||||
if( fgStructure.MenuContext )
|
||||
wglMakeCurrent( window->Window.Device,
|
||||
wglMakeCurrent( window->Window.pContext.Device,
|
||||
fgStructure.MenuContext->MContext
|
||||
);
|
||||
else
|
||||
@ -348,11 +348,11 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
fgStructure.MenuContext =
|
||||
(SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
|
||||
fgStructure.MenuContext->MContext =
|
||||
wglCreateContext( window->Window.Device );
|
||||
wglCreateContext( window->Window.pContext.Device );
|
||||
}
|
||||
|
||||
/* window->Window.Context = wglGetCurrentContext (); */
|
||||
window->Window.Context = wglCreateContext( window->Window.Device );
|
||||
window->Window.Context = wglCreateContext( window->Window.pContext.Device );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -362,13 +362,13 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
|
||||
if( ! fgState.UseCurrentContext )
|
||||
window->Window.Context =
|
||||
wglCreateContext( window->Window.Device );
|
||||
wglCreateContext( window->Window.pContext.Device );
|
||||
else
|
||||
{
|
||||
window->Window.Context = wglGetCurrentContext( );
|
||||
if( ! window->Window.Context )
|
||||
window->Window.Context =
|
||||
wglCreateContext( window->Window.Device );
|
||||
wglCreateContext( window->Window.pContext.Device );
|
||||
}
|
||||
|
||||
#if !defined(_WIN32_WCE)
|
||||
@ -391,7 +391,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
ReleaseDC( window->Window.Handle, window->Window.Device );
|
||||
ReleaseDC( window->Window.Handle, window->Window.pContext.Device );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
/* Take over button handling */
|
||||
|
@ -229,7 +229,7 @@ int fgPlatformGlutGet ( GLenum eWhat )
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
#if !defined(_WIN32_WCE)
|
||||
if( fgStructure.CurrentWindow != NULL )
|
||||
return GetPixelFormat( fgStructure.CurrentWindow->Window.Device );
|
||||
return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device );
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
return 0;
|
||||
|
||||
|
@ -169,9 +169,9 @@ void fgNewWGLCreateContext( SFG_Window* window )
|
||||
return;
|
||||
}
|
||||
|
||||
wglMakeCurrent( window->Window.Device, window->Window.Context );
|
||||
wglMakeCurrent( window->Window.pContext.Device, window->Window.Context );
|
||||
|
||||
if ( !fghIsExtensionSupported( window->Window.Device, "WGL_ARB_create_context" ) )
|
||||
if ( !fghIsExtensionSupported( window->Window.pContext.Device, "WGL_ARB_create_context" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -185,7 +185,7 @@ void fgNewWGLCreateContext( SFG_Window* window )
|
||||
fgError( "wglCreateContextAttribsARB not found" );
|
||||
}
|
||||
|
||||
context = wglCreateContextAttribsARB( window->Window.Device, 0, attributes );
|
||||
context = wglCreateContextAttribsARB( window->Window.pContext.Device, 0, attributes );
|
||||
if ( context == NULL )
|
||||
{
|
||||
fghContextCreationError();
|
||||
@ -296,7 +296,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
|
||||
if (checkOnly)
|
||||
current_hDC = CreateDC(TEXT("DISPLAY"), NULL ,NULL ,NULL);
|
||||
else
|
||||
current_hDC = window->Window.Device;
|
||||
current_hDC = window->Window.pContext.Device;
|
||||
|
||||
fghFillPFD( ppfd, current_hDC, layer_type );
|
||||
pixelformat = ChoosePixelFormat( current_hDC, ppfd );
|
||||
@ -370,13 +370,13 @@ void fgPlatformSetWindow ( SFG_Window *window )
|
||||
{
|
||||
if( fgStructure.CurrentWindow )
|
||||
ReleaseDC( fgStructure.CurrentWindow->Window.Handle,
|
||||
fgStructure.CurrentWindow->Window.Device );
|
||||
fgStructure.CurrentWindow->Window.pContext.Device );
|
||||
|
||||
if ( window )
|
||||
{
|
||||
window->Window.Device = GetDC( window->Window.Handle );
|
||||
window->Window.pContext.Device = GetDC( window->Window.Handle );
|
||||
wglMakeCurrent(
|
||||
window->Window.Device,
|
||||
window->Window.pContext.Device,
|
||||
window->Window.Context
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user