[haiku-commits] r37820 - haiku/trunk/src/libs/mesa/glut

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Jul 2010 13:57:26 +0200 (CEST)

Author: phoudoin
Date: 2010-07-30 13:57:26 +0200 (Fri, 30 Jul 2010)
New Revision: 37820
Changeset: http://dev.haiku-os.org/changeset/37820

Added:
   haiku/trunk/src/libs/mesa/glut/glutGameMode.cpp
   haiku/trunk/src/libs/mesa/glut/glutGameMode.h
Modified:
   haiku/trunk/src/libs/mesa/glut/Jamfile
   haiku/trunk/src/libs/mesa/glut/glutCallback.cpp
   haiku/trunk/src/libs/mesa/glut/glutState.h
   haiku/trunk/src/libs/mesa/glut/glutWindow.cpp
   haiku/trunk/src/libs/mesa/glut/glut_ext.c
Log:
Initiate game mode support

Modified: haiku/trunk/src/libs/mesa/glut/Jamfile
===================================================================
--- haiku/trunk/src/libs/mesa/glut/Jamfile      2010-07-30 09:20:09 UTC (rev 
37819)
+++ haiku/trunk/src/libs/mesa/glut/Jamfile      2010-07-30 11:57:26 UTC (rev 
37820)
@@ -20,7 +20,7 @@
        glutCursor.cpp
        glutMenu.cpp
        glutDstr.cpp
-       # glutGameMode.cpp
+       glutGameMode.cpp
        beos_x11.cpp
 
        # C sources

Modified: haiku/trunk/src/libs/mesa/glut/glutCallback.cpp
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glutCallback.cpp     2010-07-30 09:20:09 UTC 
(rev 37819)
+++ haiku/trunk/src/libs/mesa/glut/glutCallback.cpp     2010-07-30 11:57:26 UTC 
(rev 37820)
@@ -22,7 +22,7 @@
 /***********************************************************
  *     Window related callbacks
  ***********************************************************/
-void APIENTRY 
+void APIENTRY
 glutDisplayFunc(GLUTdisplayCB displayFunc)
 {
   /* XXX Remove the warning after GLUT 3.0. */
@@ -31,49 +31,49 @@
   gState.currentWindow->display = displayFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutKeyboardFunc(GLUTkeyboardCB keyboardFunc)
 {
   gState.currentWindow->keyboard = keyboardFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutKeyboardUpFunc(GLUTkeyboardCB keyboardUpFunc)
 {
   gState.currentWindow->keyboardUp = keyboardUpFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutSpecialFunc(GLUTspecialCB specialFunc)
 {
   gState.currentWindow->special = specialFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutSpecialUpFunc(GLUTspecialCB specialUpFunc)
 {
   gState.currentWindow->specialUp = specialUpFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutMouseFunc(GLUTmouseCB mouseFunc)
 {
   gState.currentWindow->mouse = mouseFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutMotionFunc(GLUTmotionCB motionFunc)
 {
   gState.currentWindow->motion = motionFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutPassiveMotionFunc(GLUTpassiveCB passiveMotionFunc)
 {
   gState.currentWindow->passive = passiveMotionFunc;
 }
 
-void APIENTRY 
+void APIENTRY
 glutEntryFunc(GLUTentryCB entryFunc)
 {
   gState.currentWindow->entry = entryFunc;
@@ -97,7 +97,7 @@
     gState.currentWindow->visibility(GLUT_VISIBLE);
 }
 
-void APIENTRY 
+void APIENTRY
 glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
 {
   gState.currentWindow->visibility = visibilityFunc;
@@ -107,7 +107,7 @@
     glutWindowStatusFunc(NULL);
 }
 
-void APIENTRY 
+void APIENTRY
 glutReshapeFunc(GLUTreshapeCB reshapeFunc)
 {
   if (reshapeFunc) {

Added: haiku/trunk/src/libs/mesa/glut/glutGameMode.cpp
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glutGameMode.cpp                             
(rev 0)
+++ haiku/trunk/src/libs/mesa/glut/glutGameMode.cpp     2010-07-30 11:57:26 UTC 
(rev 37820)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2010, Haiku Inc.
+ * Authors:
+ *             Philippe Houdoin <phoudoin %at% haiku-os %dot% org>
+ *
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include <GL/glut.h>
+#include "glutint.h"
+#include "glutState.h"
+#include "glutBlocker.h"
+#include <stdio.h>
+
+
+void APIENTRY
+glutGameModeString(const char *string)
+{
+       // TODO
+}
+
+
+int APIENTRY
+glutEnterGameMode(void)
+{
+       // TODO
+       return 0;
+}
+
+
+void APIENTRY
+glutLeaveGameMode(void)
+{
+       // TODO
+}
+
+
+int APIENTRY
+glutGameModeGet(GLenum pname)
+{
+       int ret = -1;
+
+       switch( pname ) {
+       case GLUT_GAME_MODE_ACTIVE:
+               ret = gState.gameMode != NULL;
+               break;
+
+       case GLUT_GAME_MODE_POSSIBLE:
+               // TODO
+               break;
+
+       case GLUT_GAME_MODE_WIDTH:
+               if (gState.gameMode)
+                       ret = gState.gameMode->width;
+               break;
+
+       case GLUT_GAME_MODE_HEIGHT:
+               if (gState.gameMode)
+                       ret = gState.gameMode->height;
+               break;
+
+           case GLUT_GAME_MODE_PIXEL_DEPTH:
+               if (gState.gameMode)
+                       ret = gState.gameMode->pixelDepth;
+               break;
+
+           case GLUT_GAME_MODE_REFRESH_RATE:
+               if (gState.gameMode)
+                       ret = gState.gameMode->refreshRate;
+           break;
+
+           case GLUT_GAME_MODE_DISPLAY_CHANGED:
+                       // TODO
+               break;
+
+       default:
+               __glutWarning( "Unknown gamemode get: %d", pname );
+               break;
+    }
+
+    return ret;
+}
+
+
+void APIENTRY
+glutForceJoystickFunc(void)
+{
+       /*
+       Forces a joystick poll and callback.
+
+       Forces the OpenGLUT joystick code to poll your
+       joystick(s) and to call your joystick callbacks
+       with the result.  The operation completes, including
+       callbacks, before glutForceJoystickFunc() returns.
+
+    See also glutJoystickFunc()
+       */
+
+       // TODO
+}

Added: haiku/trunk/src/libs/mesa/glut/glutGameMode.h
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glutGameMode.h                               
(rev 0)
+++ haiku/trunk/src/libs/mesa/glut/glutGameMode.h       2010-07-30 11:57:26 UTC 
(rev 37820)
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2010, Haiku Inc.
+ * Authors:
+ *             Philippe Houdoin <phoudoin %at% haiku-os %dot% org>
+ *
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <GL/glut.h>
+
+
+/*!    All information needed for game mode and
+       subwindows (handled as similarly as possible).
+*/
+class GlutGameMode {
+public:
+       int     width;
+       int     height;
+       int     pixelDepth;
+       int     refreshRate;
+};

Modified: haiku/trunk/src/libs/mesa/glut/glutState.h
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glutState.h  2010-07-30 09:20:09 UTC (rev 
37819)
+++ haiku/trunk/src/libs/mesa/glut/glutState.h  2010-07-30 11:57:26 UTC (rev 
37820)
@@ -17,8 +17,10 @@
  ***********************************************************/
 #include <GL/glut.h>
 #include <Application.h>
+
 #include "glutWindow.h"
 #include "glutMenu.h"
+#include "glutGameMode.h"
 
 /***********************************************************
  *     CLASS:  GlutState
@@ -45,7 +47,7 @@
        int modifierKeys;                               // only valid during 
keyboard callback
        int keyRepeatMode;                              // global repeat
 
-       bool    gameMode;                       // game mode is active
+       GlutGameMode* gameMode;
 
        bool debug;                                     // call glGetError
        bool quitAll;                           // quit
@@ -57,14 +59,15 @@
                initWidth = initHeight = 300;
                displayMode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
                displayString = 0;
-               currentWindow = 0;
-               currentMenu = 0;
-               windowList = 0;
+               currentWindow = NULL;
+               currentMenu = NULL;
+               windowList = NULL;
                windowListSize = 0;
                idle = 0;
                menuStatus = 0;
                modifierKeys = ~0;
                keyRepeatMode = GLUT_KEY_REPEAT_DEFAULT;
+               gameMode = NULL;
                debug = quitAll = false;
        }
 };

Modified: haiku/trunk/src/libs/mesa/glut/glutWindow.cpp
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glutWindow.cpp       2010-07-30 09:20:09 UTC 
(rev 37819)
+++ haiku/trunk/src/libs/mesa/glut/glutWindow.cpp       2010-07-30 11:57:26 UTC 
(rev 37820)
@@ -103,16 +103,16 @@
        // clear callbacks
        display = __glutDefaultDisplay;
        reshape = __glutDefaultReshape;
-       mouse = 0;
-       motion = 0;
-       passive = 0;
-       entry = 0;
-       keyboard = 0;
-       keyboardUp = 0;
-       visibility = 0;
-       special = 0;
-       specialUp = 0;
-       windowStatus = 0;
+       mouse = NULL;
+       motion = NULL;
+       passive = NULL;
+       entry = NULL;
+       keyboard = NULL;
+       keyboardUp = NULL;
+       visibility = NULL;
+       special = NULL;
+       specialUp = NULL;
+       windowStatus = NULL;
 
        // clear event counters
        anyevents = 1;
@@ -124,7 +124,7 @@
        entryEvent = 0;
        keybEvent = 0;
        keybUpEvent = 0;
-       windowStatusEvent = 0; // DirectConnected() will report change in 
+       windowStatusEvent = 0; // DirectConnected() will report change in
        visState = -1;         // visibility
        specialEvent = 0;
        specialUpEvent = 0;
@@ -132,7 +132,7 @@
        menuEvent = 0;
        visible = true;
        ignoreKeyRepeat = (gState.keyRepeatMode == GLUT_KEY_REPEAT_OFF);
-       
+
        gBlock.QuickNewEvent();
 
        // if i'm a subwindow, add me to my parent view
@@ -218,7 +218,7 @@
 glutSetWindow(int win)
 {
        GlutWindow *window;
-       
+
        if (win < 1 || win > gState.windowListSize) {
                __glutWarning("glutSetWindow attempted on bogus window.");
                return;
@@ -270,7 +270,7 @@
                        cur = cur->siblings;
                }
        }
-       
+
        // finally, check if we are the current window, and set to 0
        if (gState.currentWindow == window)
                gState.currentWindow = 0;
@@ -484,7 +484,7 @@
 {
        if (gState.currentWindow->parent)
                __glutFatalError("can't iconify a subwindow");
-               
+
        gState.currentWindow->Window()->Lock();
        gState.currentWindow->Window()->Minimize(true);
        gState.currentWindow->Window()->Unlock();
@@ -494,7 +494,7 @@
 /*!    Sets the window title */
 void
 glutSetWindowTitle(const char *name)
-{ 
+{
        if (gState.currentWindow->parent)
                __glutFatalError("glutSetWindowTitle: isn't a top-level 
window");
 
@@ -545,7 +545,7 @@
                        newoptions |= BGL_STENCIL;
                *options = newoptions;
        }
-       
+
        if (gState.displayMode & GLUT_INDEX) {
                __glutWarning("BeOS doesn't support indexed color");
                return 0;
@@ -625,7 +625,7 @@
                Hide();
 
        Sync();
-}      
+}
 
 
 bool

Modified: haiku/trunk/src/libs/mesa/glut/glut_ext.c
===================================================================
--- haiku/trunk/src/libs/mesa/glut/glut_ext.c   2010-07-30 09:20:09 UTC (rev 
37819)
+++ haiku/trunk/src/libs/mesa/glut/glut_ext.c   2010-07-30 11:57:26 UTC (rev 
37820)
@@ -11,7 +11,7 @@
 #include "glutint.h"
 
 /* CENTRY */
-int GLUTAPIENTRY 
+int GLUTAPIENTRY
 glutExtensionSupported(const char *extension)
 {
   static const GLubyte *extensions = NULL;
@@ -125,7 +125,7 @@
    { "glutWindowStatusFunc", (const GLUTproc) glutWindowStatusFunc },
    { "glutKeyboardUpFunc", (const GLUTproc) glutKeyboardUpFunc },
    { "glutSpecialUpFunc", (const GLUTproc) glutSpecialUpFunc },
-//   { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc },
+   { "glutJoystickFunc", (const GLUTproc) glutJoystickFunc },
    { "glutSetColor", (const GLUTproc) glutSetColor },
    { "glutGetColor", (const GLUTproc) glutGetColor },
    { "glutCopyColormap", (const GLUTproc) glutCopyColormap },
@@ -167,17 +167,17 @@
    { "glutReportErrors", (const GLUTproc) glutReportErrors },
    { "glutIgnoreKeyRepeat", (const GLUTproc) glutIgnoreKeyRepeat },
    { "glutSetKeyRepeat", (const GLUTproc) glutSetKeyRepeat },
-//   { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
-//   { "glutGameModeString", (const GLUTproc) glutGameModeString },
-//   { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
-//   { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode },
-//   { "glutGameModeGet", (const GLUTproc) glutGameModeGet },
+   { "glutForceJoystickFunc", (const GLUTproc) glutForceJoystickFunc },
+   { "glutGameModeString", (const GLUTproc) glutGameModeString },
+   { "glutEnterGameMode", (const GLUTproc) glutEnterGameMode },
+   { "glutLeaveGameMode", (const GLUTproc) glutLeaveGameMode },
+   { "glutGameModeGet", (const GLUTproc) glutGameModeGet },
    { NULL, NULL }
-};   
+};
 
 
 /* XXX This isn't an official GLUT function, yet */
-GLUTproc GLUTAPIENTRY 
+GLUTproc GLUTAPIENTRY
 glutGetProcAddress(const char *procName)
 {
    /* Try GLUT functions first */


Other related posts:

  • » [haiku-commits] r37820 - haiku/trunk/src/libs/mesa/glut - philippe . houdoin