X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreeglut_window.c;h=3723520ec24916690ad56dcb1dea9035c6b277fa;hb=d6ccf7c81bdad11e6902a258e8e21fdbe6b9f968;hp=f99b673763577b185fe0e489eefdd659a0b7d598;hpb=fc5b93fd6592f84aa605e18cb6456a1af770e483;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index f99b673..3723520 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -29,7 +29,7 @@ #include "config.h" #endif -#include "../include/GL/freeglut.h" +#include #include "freeglut_internal.h" /* @@ -203,7 +203,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL ); ppfd = &pfd; - + pixelformat = ChoosePixelFormat( window->Window.Device, ppfd ); if( pixelformat == 0 ) return GL_FALSE; @@ -235,8 +235,8 @@ void fgSetWindow ( SFG_Window *window ) if ( window ) { window->Window.Device = GetDC( window->Window.Handle ); - wglMakeCurrent( - window->Window.Device, + wglMakeCurrent( + window->Window.Device, window->Window.Context ); } @@ -268,11 +268,12 @@ void fgOpenWindow( SFG_Window* window, const char* title, * XXX simplify this. */ if( !window->IsMenu ) - window->Window.VisualInfo = fgChooseVisual( ); + window->Window.VisualInfo = fgChooseVisual( ); else if( fgStructure.MenuContext ) window->Window.VisualInfo = fgChooseVisual( ); else { + /* XXX Why are menus double- and depth-buffered? */ unsigned int current_DisplayMode = fgState.DisplayMode ; fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ; window->Window.VisualInfo = fgChooseVisual( ); @@ -292,7 +293,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, window->Window.VisualInfo = fgChooseVisual( ); fgState.DisplayMode &= ~GLUT_DOUBLE; } - + /* * GLUT also checks for multi-sampling, but I don't see that * anywhere else in FREEGLUT so I won't bother with it for the moment. @@ -310,7 +311,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, window->State.IsOffscreen = GL_FALSE; if( fgState.DisplayMode & GLUT_OFFSCREEN ) { - window->State.IsOffscreen = GL_TRUE; + window->State.IsOffscreen = GL_TRUE; window->Window.Pixmap = XCreatePixmap( fgDisplay.Display, fgDisplay.RootWindow, w, h, @@ -336,11 +337,8 @@ void fgOpenWindow( SFG_Window* window, const char* title, * XXX A: Not appreciably, but it WILL make it easier to debug. * XXX Try tracing old GLUT and try tracing freeglut. Old GLUT * XXX turns off events that it doesn't need and is a whole lot - * XXX more pleasant to trace. (Hint: Think mouse-motion!) - * XXX - * XXX It may make a difference in networked environments or on - * XXX some very slow systems, but I think that that is secondary - * XXX to making debugging easier. + * XXX more pleasant to trace. (Think mouse-motion! Tons of + * XXX ``bonus'' GUI events stream in.) */ winAttr.event_mask = StructureNotifyMask | SubstructureNotifyMask | ExposureMask | @@ -395,7 +393,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, ); } -/* window->Window.Context = fgStructure.MenuContext->Context ; */ + /* window->Window.Context = fgStructure.MenuContext->Context; */ window->Window.Context = glXCreateContext( fgDisplay.Display, window->Window.VisualInfo, NULL, fgState.ForceDirectContext | fgState.TryDirectContext @@ -473,27 +471,28 @@ void fgOpenWindow( SFG_Window* window, const char* title, &wmHints, NULL ); - + XSetWMProtocols( fgDisplay.Display, window->Window.Handle, &fgDisplay.DeleteWindow, 1 ); - + XMapWindow( fgDisplay.Display, window->Window.Handle ); } - + #elif TARGET_HOST_WIN32 WNDCLASS wc; - int flags; + DWORD flags; + DWORD exFlags = 0; ATOM atom; freeglut_assert_ready; - + /* * Grab the window class we have registered on glutInit(): */ atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc ); assert( atom != 0 ); - + if( gameMode ) { assert( window->Parent == NULL ); @@ -536,14 +535,18 @@ void fgOpenWindow( SFG_Window* window, const char* title, flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; if ( window->IsMenu ) - flags |= WS_POPUP ; + { + flags |= WS_POPUP; + exFlags |= WS_EX_TOOLWINDOW; + } else if( window->Parent == NULL ) flags |= WS_OVERLAPPEDWINDOW; else flags |= WS_CHILD; } - window->Window.Handle = CreateWindow( + window->Window.Handle = CreateWindowEx( + exFlags, "FREEGLUT", title, flags, @@ -645,14 +648,20 @@ int FGAPIENTRY glutCreateWindow( const char* title ) */ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h ) { - SFG_Window* window = NULL; - SFG_Window* parent = NULL; + int ret = 0; - freeglut_assert_ready; - parent = fgWindowByID( parentID ); - freeglut_return_val_if_fail( parent != NULL, 0 ); - window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE ); - return window->ID; + if( GL_FALSE == fgStructure.Window->State.IsOffscreen ) + { + SFG_Window* window = NULL; + SFG_Window* parent = NULL; + + freeglut_assert_ready; + parent = fgWindowByID( parentID ); + freeglut_return_val_if_fail( parent != NULL, 0 ); + window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE ); + ret = window->ID; + } + return ret; } /* @@ -795,18 +804,18 @@ void FGAPIENTRY glutSetWindowTitle( const char* title ) #if TARGET_HOST_UNIX_X11 XTextProperty text; - + text.value = (unsigned char *) title; text.encoding = XA_STRING; text.format = 8; text.nitems = strlen( title ); - + XSetWMName( fgDisplay.Display, fgStructure.Window->Window.Handle, &text ); - + XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ #elif TARGET_HOST_WIN32 @@ -831,7 +840,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title ) #if TARGET_HOST_UNIX_X11 XTextProperty text; - + text.value = (unsigned char *) title; text.encoding = XA_STRING; text.format = 8; @@ -889,7 +898,7 @@ void FGAPIENTRY glutPositionWindow( int x, int y ) #elif TARGET_HOST_WIN32 RECT winRect; - + GetWindowRect( fgStructure.Window->Window.Handle, &winRect ); MoveWindow( fgStructure.Window->Window.Handle, @@ -1029,7 +1038,7 @@ void FGAPIENTRY glutFullScreen( void ) rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER - ); + ); #endif } }