now have a default reshape callback function that is used if the user didn't set...
authorDiederick Niehorster <dcnieho@gmail.com>
Wed, 6 Mar 2013 09:17:13 +0000 (09:17 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Wed, 6 Mar 2013 09:17:13 +0000 (09:17 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1557 7f0cb862-5218-0410-a997-914c9d46530a

src/fg_callbacks.c
src/fg_main.c
src/fg_structure.c
src/mswin/fg_window_mswin.c
src/x11/fg_main_x11.c

index c83b3f0..c62d37c 100644 (file)
@@ -121,7 +121,6 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback )               \
 #define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a)
 
 /* Implement all these callback setter functions... */
-IMPLEMENT_CALLBACK_FUNC(Reshape);
 IMPLEMENT_CALLBACK_FUNC(Position);
 IMPLEMENT_CALLBACK_FUNC(Keyboard);
 IMPLEMENT_CALLBACK_FUNC(KeyboardUp);
@@ -163,6 +162,21 @@ void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
     SET_CALLBACK( Display );
 }
 
+void fghDefaultReshape(int width, int height)
+{
+    glViewport( 0, 0, width, height );
+}
+
+void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
+{
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
+    
+    if( !callback )
+        callback = fghDefaultReshape;
+
+    SET_CALLBACK( Reshape );
+}
+
 /*
  * Sets the Visibility callback for the current window.
  * NB: the Visibility func is deprecated in favor of the WindowStatus func,
index f6a94a6..9acfc31 100644 (file)
@@ -74,13 +74,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height )
 
        fgPlatformReshapeWindow ( window, width, height );
 
-    if( FETCH_WCB( *window, Reshape ) )
-        INVOKE_WCB( *window, Reshape, ( width, height ) );
-    else
-    {
-        fgSetWindow( window );
-        glViewport( 0, 0, width, height );
-    }
+    INVOKE_WCB( *window, Reshape, ( width, height ) );
 
     /*
      * Force a window redraw.  In Windows at least this is only a partial
index e779037..be9d1ce 100644 (file)
@@ -49,6 +49,7 @@ SFG_Structure fgStructure = { { NULL, NULL },  /* The list of windows       */
 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
 
 extern void fgPlatformCreateWindow ( SFG_Window *window );
+extern void fghDefaultReshape(int width, int height);
 
 static void fghClearCallBacks( SFG_Window *window )
 {
@@ -77,6 +78,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
        fgPlatformCreateWindow ( window );
 
     fghClearCallBacks( window );
+    SET_WCB( *window, Reshape, fghDefaultReshape);
 
     /* Initialize the object properties */
     window->ID = ++fgStructure.WindowID;
@@ -94,7 +96,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
     window->State.Cursor    = GLUT_CURSOR_INHERIT;
 
     /* Mark window as menu if a menu is to be created */
-    window->IsMenu = isMenu;
+    window->IsMenu          = isMenu;
 
     /*
      * Open the window now. The fgOpenWindow() function is system
index 518e0d3..8342503 100644 (file)
@@ -742,6 +742,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
 
 void fgPlatformDisplayWindow ( SFG_Window *window )
 {
+    /* This immediately generates a WM_PAINT message upon which we call the display callbacks to redraw the window */
     RedrawWindow(
         window->Window.Handle, NULL, NULL,
         RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
index c803b2b..0bf967d 100644 (file)
@@ -662,13 +662,7 @@ void fgPlatformProcessSingleEvent ( void )
 
                     window->State.pWState.OldWidth = width;
                     window->State.pWState.OldHeight = height;
-                    if( FETCH_WCB( *window, Reshape ) )
-                        INVOKE_WCB( *window, Reshape, ( width, height ) );
-                    else
-                    {
-                        fgSetWindow( window );
-                        glViewport( 0, 0, width, height );
-                    }
+                    INVOKE_WCB( *window, Reshape, ( width, height ) );
                     glutPostRedisplay( );
                     if( window->IsMenu )
                         fgSetWindow( current_window );