bump versions to 2.0
[freeglut] / freeglut-1.3 / freeglut_window.c
index 7d67b61..9e4a9e3 100644 (file)
@@ -361,11 +361,6 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
     freeglut_assert_ready;
 
     /*
-     * Save the window's single- or double-buffering state
-     */
-    window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
-
-    /*
      * Here we are upon the stage. Have the visual selected.
      */
     window->Window.VisualInfo = fgChooseVisual();
@@ -541,15 +536,6 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
 #       endif
     }
 
-    /*
-     * If it's not double-buffered, make sure the rendering is done to the front buffer.
-     */
-    if ( ! window->Window.DoubleBuffered )
-    {
-      glDrawBuffer ( GL_FRONT ) ;
-      glReadBuffer ( GL_FRONT ) ;
-    }
-
 #elif TARGET_HOST_WIN32
 
        WNDCLASS wc;
@@ -569,12 +555,10 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
       if ( !isSubWindow )
       {
         /*
-         * Update the window position and dimensions, taking account of window decorations
+         * Update the window dimensions, taking account of window decorations.
+         * "freeglut" is to create the window with the outside of its border at (x,y)
+         * and with dimensions (w,h).
          */
-
-                   x -= (GetSystemMetrics( SM_CXSIZEFRAME ) ); 
-               y -= (GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) );
-        if ( y < 0 ) y = 0 ;
                w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
                h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
       }
@@ -637,6 +621,20 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i
 #endif
 
     /*
+     * Save the window's single- or double-buffering state
+     */
+    window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
+
+    /*
+     * If it's not double-buffered, make sure the rendering is done to the front buffer.
+     */
+    if ( ! window->Window.DoubleBuffered )
+    {
+      glDrawBuffer ( GL_FRONT ) ;
+      glReadBuffer ( GL_FRONT ) ;
+    }
+
+    /*
      * Set the newly created window as the current one
      */
     fgSetWindow( window );
@@ -1030,8 +1028,8 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
       /*
        * Adjust the size of the window to allow for the size of the frame
        */
-               width += (GetSystemMetrics( SM_CXSIZEFRAME ) - 1)*2;
-               height += (GetSystemMetrics( SM_CYSIZEFRAME ) - 1)*2 + GetSystemMetrics( SM_CYCAPTION );
+               width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
+               height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
     }
     else  /* This is a subwindow, get the parent window's position and subtract it off */
     {
@@ -1078,16 +1076,6 @@ void FGAPIENTRY glutPositionWindow( int x, int y )
                 */
                GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
 
-    if ( fgStructure.Window->Parent == NULL )  /* If this is not a subwindow ... */
-    {
-      /*
-       * Adjust the position of the window to allow for the size of the frame
-       */
-               x -= (GetSystemMetrics( SM_CXSIZEFRAME ) - 1); 
-               y -= (GetSystemMetrics( SM_CYSIZEFRAME ) - 1 + GetSystemMetrics( SM_CYCAPTION ));
-      if ( y < 0 ) y = 0 ;
-    }
-
     /*
                 * Reposition the window, forcing a redraw to happen
                 */
@@ -1176,6 +1164,19 @@ void FGAPIENTRY glutFullScreen( void )
     );
 }
 
+/*
+ * A.Donev: Set and retrieve the window's user data
+ */
+void* FGAPIENTRY glutGetWindowData( void )
+{
+   return(fgStructure.Window->UserData);
+}
+
+void FGAPIENTRY glutSetWindowData(void* data)
+{
+  fgStructure.Window->UserData=data;
+}
+
 /*** END OF FILE ***/