Addressing Feature Request #1307049 that "freeglut" should return 0 if "glutGetWindow...
authorJohn F. Fay <johnffay@nettally.com>
Tue, 18 Sep 2007 02:32:53 +0000 (02:32 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Tue, 18 Sep 2007 02:32:53 +0000 (02:32 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@718 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_window.c

index 5ab924f..7236c91 100644 (file)
@@ -904,7 +904,14 @@ void FGAPIENTRY glutSetWindow( int ID )
 int FGAPIENTRY glutGetWindow( void )
 {
     SFG_Window *win = fgStructure.CurrentWindow;
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetWindow" );
+    /*
+     * Since GLUT did not throw an error if this function was called without a prior call to
+     * "glutInit", this function shouldn't do so here.  Instead let us return a zero.
+     * See Feature Request "[ 1307049 ] glutInit check".
+     */
+    if ( ! fgState.Initialised )
+        return 0;
+
     while ( win && win->IsMenu )
         win = win->Parent;
     return win ? win->ID : 0;