summaryrefslogtreecommitdiff
path: root/src/glut
diff options
context:
space:
mode:
authorPhilippe Houdoin <phoudoin@freedesktop.org>2004-08-14 10:27:08 +0000
committerPhilippe Houdoin <phoudoin@freedesktop.org>2004-08-14 10:27:08 +0000
commita041e62418a72f0fd379e50263e1c9d2e6c6bb55 (patch)
tree578847e0704507461122c73f5fff867e284a5c37 /src/glut
parentfad0e5d448d9a2b55a7faa3fcb569470c381fb4b (diff)
Update to Jake Hamby's BeOS GLUT 3.7 port.
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/beos/beos_x11.cpp7
-rw-r--r--src/glut/beos/glutBlocker.cpp6
-rw-r--r--src/glut/beos/glutBlocker.h8
-rw-r--r--src/glut/beos/glutCallback.cpp28
-rw-r--r--src/glut/beos/glutColor.cpp9
-rw-r--r--src/glut/beos/glutCursor.cpp9
-rw-r--r--src/glut/beos/glutDstr.cpp12
-rw-r--r--src/glut/beos/glutEvent.cpp64
-rw-r--r--src/glut/beos/glutGet.cpp9
-rw-r--r--src/glut/beos/glutInit.cpp39
-rw-r--r--src/glut/beos/glutMenu.cpp6
-rw-r--r--src/glut/beos/glutMenu.h7
-rw-r--r--src/glut/beos/glutOverlay.cpp13
-rw-r--r--src/glut/beos/glutState.h18
-rw-r--r--src/glut/beos/glutWindow.cpp178
-rw-r--r--src/glut/beos/glutWindow.h28
-rw-r--r--src/glut/beos/glutbitmap.h7
-rw-r--r--src/glut/beos/glutint.h819
-rw-r--r--src/glut/beos/glutstroke.h5
19 files changed, 1103 insertions, 169 deletions
diff --git a/src/glut/beos/beos_x11.cpp b/src/glut/beos/beos_x11.cpp
index 20c75036d5..2d1bc655cb 100644
--- a/src/glut/beos/beos_x11.cpp
+++ b/src/glut/beos/beos_x11.cpp
@@ -37,6 +37,8 @@ suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
*/
+#if 0 // Not used currently...
+
/*
*Returns pointer to first char ins search which is also in what, else NULL.
*/
@@ -45,13 +47,16 @@ static char *strscan (char *search, char *what)
int i, len = strlen (what);
char c;
- while ((c = *(search++)) != (int)NULL)
+ while ((c = *(search++))) {
for (i = 0; i < len; i++)
if (c == what [i])
return (--search);
+ }
return (NULL);
}
+#endif
+
/*
* XParseGeometry parses strings of the form
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
diff --git a/src/glut/beos/glutBlocker.cpp b/src/glut/beos/glutBlocker.cpp
index e2cfcf7b39..aa948522b9 100644
--- a/src/glut/beos/glutBlocker.cpp
+++ b/src/glut/beos/glutBlocker.cpp
@@ -1,5 +1,9 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
*
* FILE: glutBlocker.cpp
*
diff --git a/src/glut/beos/glutBlocker.h b/src/glut/beos/glutBlocker.h
index e6d1f4e049..fc9e4cc309 100644
--- a/src/glut/beos/glutBlocker.h
+++ b/src/glut/beos/glutBlocker.h
@@ -1,5 +1,9 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
*
* FILE: glutBlocker.h
*
@@ -40,4 +44,4 @@ private:
/***********************************************************
* Global variable
***********************************************************/
-extern GlutBlocker gBlock; \ No newline at end of file
+extern GlutBlocker gBlock;
diff --git a/src/glut/beos/glutCallback.cpp b/src/glut/beos/glutCallback.cpp
index 82707d5db2..cf3daaaf36 100644
--- a/src/glut/beos/glutCallback.cpp
+++ b/src/glut/beos/glutCallback.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutCallback.cpp
*
@@ -65,10 +70,29 @@ glutEntryFunc(GLUTentryCB entryFunc)
}
}
+void APIENTRY
+glutWindowStatusFunc(GLUTwindowStatusCB windowStatusFunc)
+{
+ gState.currentWindow->windowStatus = windowStatusFunc;
+}
+
+static void
+visibilityHelper(int status)
+{
+ if (status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED)
+ gState.currentWindow->visibility(GLUT_NOT_VISIBLE);
+ else
+ gState.currentWindow->visibility(GLUT_VISIBLE);
+}
+
void APIENTRY
glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
{
gState.currentWindow->visibility = visibilityFunc;
+ if (visibilityFunc)
+ glutWindowStatusFunc(visibilityHelper);
+ else
+ glutWindowStatusFunc(NULL);
}
void APIENTRY
@@ -144,4 +168,4 @@ glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc)
void APIENTRY
glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc)
{
-} \ No newline at end of file
+}
diff --git a/src/glut/beos/glutColor.cpp b/src/glut/beos/glutColor.cpp
index 5979deafca..d9f7739ae5 100644
--- a/src/glut/beos/glutColor.cpp
+++ b/src/glut/beos/glutColor.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutColor.cpp
*
@@ -24,4 +29,4 @@ GLfloat glutGetColor(int cell, int component) {
void glutCopyColormap(int win) {
__glutWarning("glutCopyColormap: color index not supported in BeOS");
-} \ No newline at end of file
+}
diff --git a/src/glut/beos/glutCursor.cpp b/src/glut/beos/glutCursor.cpp
index e8debe800e..3081fff44b 100644
--- a/src/glut/beos/glutCursor.cpp
+++ b/src/glut/beos/glutCursor.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutCursor.cpp
*
@@ -82,4 +87,4 @@ void __glutSetCursor(int cursor) {
* DESCRIPTION: move the mouse pointer to a new location
* (note: can't do this in BeOS!)
***********************************************************/
-void glutWarpPointer(int x, int y) { } \ No newline at end of file
+void glutWarpPointer(int x, int y) { }
diff --git a/src/glut/beos/glutDstr.cpp b/src/glut/beos/glutDstr.cpp
index c594cfdafd..281a039701 100644
--- a/src/glut/beos/glutDstr.cpp
+++ b/src/glut/beos/glutDstr.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutDstr.cpp
*
@@ -46,8 +51,7 @@ glutInitDisplayString(const char *string)
* RETURNS: 1 if the current display mode is possible, else 0
***********************************************************/
int __glutConvertDisplayModeFromString(unsigned long *options) {
- ulong newoptions = BGL_DOUBLE;
- gState.swapHack = true; // assume single buffered
+ ulong newoptions = 0;
char *word = strtok(gState.displayString, " \t");
do {
@@ -66,7 +70,7 @@ int __glutConvertDisplayModeFromString(unsigned long *options) {
} else if(!strcmp(word, "depth")) {
newoptions |= BGL_DEPTH;
} else if(!strcmp(word, "double")) {
- gState.swapHack = false;
+ newoptions |= BGL_DOUBLE;
} else if(!strcmp(word, "stencil")) {
newoptions |= BGL_STENCIL;
}
diff --git a/src/glut/beos/glutEvent.cpp b/src/glut/beos/glutEvent.cpp
index 20b1cad23f..cffbc1aa54 100644
--- a/src/glut/beos/glutEvent.cpp
+++ b/src/glut/beos/glutEvent.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutEvent.cpp
*
@@ -111,12 +116,14 @@ processEventsAndTimeouts(void)
// immediately, otherwise wait forever
gBlock.ClearEvents();
+ if(gState.quitAll)
+ exit(0); // exit handler cleans up windows and quits nicely
+
if (gState.currentWindow)
gState.currentWindow->LockGL();
for(int i=0; i<gState.windowListSize; i++) {
if (gState.windowList[i]) {
GlutWindow *win = gState.windowList[i];
- win->Window()->Lock();
// NOTE: we can use win as a shortcut for gState.windowList[i]
// in callbacks, EXCEPT we need to check the original variable
// after each callback to make sure the window hasn't been destroyed
@@ -134,11 +141,6 @@ processEventsAndTimeouts(void)
win->displayEvent = false;
__glutSetWindow(win);
win->display();
- if (gState.windowList[i] && win->swapHack) {
- // fake single buffering by swapping buffers
- __glutSetWindow(win);
- win->SwapBuffers();
- }
}
if (!gState.windowList[i])
continue; // window was destroyed by callback!
@@ -229,17 +231,15 @@ processEventsAndTimeouts(void)
if (!gState.windowList[i])
continue; // window was destroyed by callback!
- if (win->visEvent) {
- win->visEvent = false;
+ if (win->windowStatusEvent) {
+ win->windowStatusEvent = false;
__glutSetWindow(win);
- if (win->visibility)
- win->visibility(win->visState);
+ if (win->windowStatus)
+ win->windowStatus(win->visState);
}
if (!gState.windowList[i])
continue; // window was destroyed by callback!
}
- if(gState.windowList[i]) // window hasn't been destroyed
- win->Window()->Unlock();
}
}
if (gState.currentWindow)
@@ -304,8 +304,9 @@ idleWait(void)
/* Make sure idle func still exists! */
if(gState.currentWindow)
gState.currentWindow->LockGL();
- if (gState.idle)
+ if (gState.idle) {
gState.idle();
+ }
if(gState.currentWindow)
gState.currentWindow->UnlockGL();
}
@@ -604,7 +605,7 @@ void GlutWindow::MouseMoved(BPoint point,
void GlutWindow::FrameResized(float width, float height)
{
BGLView::FrameResized(width, height);
- if (visState == GLUT_VISIBLE) {
+ if (visible) {
anyevents = reshapeEvent = true;
m_width = (int)(width)+1;
m_height = (int)(height)+1;
@@ -626,39 +627,12 @@ void GlutWindow::Draw(BRect updateRect)
if (m_width != (frame.Width()+1) || m_height != (frame.Height()+1)) {
FrameResized(frame.Width(), frame.Height());
}
- if (visState == GLUT_VISIBLE) {
+ Window()->Lock();
+ if (visible) {
anyevents = displayEvent = true;
gBlock.NewEvent();
}
-}
-
-/***********************************************************
- * CLASS: GlutWindow
- *
- * FUNCTION: Hide
- * Show
- *
- * DESCRIPTION: handles visibility event
- ***********************************************************/
-void GlutWindow::Hide()
-{
- BGLView::Hide();
- if (visibility) {
- anyevents = visEvent = true;
- visState = GLUT_NOT_VISIBLE;
- displayEvent = false; // display callbacks not allowed when hidden
- gBlock.NewEvent();
- }
-}
-
-void GlutWindow::Show()
-{
- BGLView::Show();
- if (visibility) {
- anyevents = visEvent = true;
- visState = GLUT_VISIBLE;
- gBlock.NewEvent();
- }
+ Window()->Unlock();
}
/***********************************************************
diff --git a/src/glut/beos/glutGet.cpp b/src/glut/beos/glutGet.cpp
index 33355afb83..45d07f7e46 100644
--- a/src/glut/beos/glutGet.cpp
+++ b/src/glut/beos/glutGet.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutGet.cpp
*
@@ -12,6 +17,8 @@
#include <GL/glut.h>
#include <string.h>
#include <Autolock.h>
+#include <Screen.h>
+
#include "glutint.h"
#include "glutState.h"
diff --git a/src/glut/beos/glutInit.cpp b/src/glut/beos/glutInit.cpp
index 9aa0f4787d..401081328f 100644
--- a/src/glut/beos/glutInit.cpp
+++ b/src/glut/beos/glutInit.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutInit.cpp
*
@@ -12,14 +17,17 @@
#include <GL/glut.h>
#include <string.h>
#include <stdlib.h>
+#include <signal.h>
#include "glutint.h"
#include "glutState.h"
+#include "glutBlocker.h"
#include "beos_x11.h"
/***********************************************************
* Global variables
***********************************************************/
GlutState gState;
+char *__glutProgramName = NULL;
/***********************************************************
* Private variables
@@ -73,6 +81,16 @@ static int32 bAppThread(void *arg) {
}
/***********************************************************
+ * FUNCTION: sigHandler
+ *
+ * DESCRIPTION: shuts down the app on CTRL-C
+ ***********************************************************/
+static void sigHandler(int) {
+ gState.quitAll = true;
+ gBlock.NewEvent();
+}
+
+/***********************************************************
* FUNCTION: glutInit (2.1)
*
* DESCRIPTION: create BApplication, parse cmd-line arguments,
@@ -89,9 +107,9 @@ void glutInit(int *argcp, char **argv) {
/* Determine temporary program name. */
str = strrchr(argv[0], '/');
if (str == NULL) {
- gState.programName = argv[0];
+ __glutProgramName = argv[0];
} else {
- gState.programName = str + 1;
+ __glutProgramName = str + 1;
}
/* Make private copy of command line arguments. */
@@ -108,9 +126,9 @@ void glutInit(int *argcp, char **argv) {
/* determine permanent program name */
str = strrchr(__glutArgv[0], '/');
if (str == NULL) {
- gState.programName = __glutArgv[0];
+ __glutProgramName = __glutArgv[0];
} else {
- gState.programName = str + 1;
+ __glutProgramName = str + 1;
}
/* parse arguments for standard options */
@@ -201,11 +219,18 @@ void __glutInit() {
// open BApplication
gState.display = new BApplication("application/x-glut-demo");
be_app->Unlock();
- thread_id appthread = spawn_thread(bAppThread, "BApplication", B_NORMAL_PRIORITY, 0);
- resume_thread(appthread);
+ gState.appthread = spawn_thread(bAppThread, "BApplication", B_NORMAL_PRIORITY, 0);
+ resume_thread(gState.appthread);
bigtime_t unused;
__glutInitTime(&unused);
+
+ /* set atexit() function to destroy all windows before exiting */
+ if(atexit(__glutDestroyAllWindows))
+ __glutFatalError("can't set exit handler");
+
+ /* similarly, destroy all windows on CTRL-C */
+ signal(SIGINT, sigHandler);
}
/***********************************************************
diff --git a/src/glut/beos/glutMenu.cpp b/src/glut/beos/glutMenu.cpp
index 1dad5970c9..2f9e6a2c67 100644
--- a/src/glut/beos/glutMenu.cpp
+++ b/src/glut/beos/glutMenu.cpp
@@ -1,5 +1,9 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
*
* FILE: glutMenu.cpp
*
diff --git a/src/glut/beos/glutMenu.h b/src/glut/beos/glutMenu.h
index f61b9aaaf7..1ee170694b 100644
--- a/src/glut/beos/glutMenu.h
+++ b/src/glut/beos/glutMenu.h
@@ -1,5 +1,9 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
*
* FILE: glutMenu.h
*
@@ -12,6 +16,7 @@
#include <GL/glut.h>
#include <Menu.h>
#include <MenuItem.h>
+#include <PopUpMenu.h>
/***********************************************************
* Definitions
diff --git a/src/glut/beos/glutOverlay.cpp b/src/glut/beos/glutOverlay.cpp
index eaabb8373a..fed757fe95 100644
--- a/src/glut/beos/glutOverlay.cpp
+++ b/src/glut/beos/glutOverlay.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutOverlay.cpp
*
@@ -35,4 +40,8 @@ void glutShowOverlay() {
void glutHideOverlay() {
// ignore
-} \ No newline at end of file
+}
+
+void glutPostWindowOverlayRedisplay(int win) {
+ // ignore
+}
diff --git a/src/glut/beos/glutState.h b/src/glut/beos/glutState.h
index c9a9a52127..9c44eb6b53 100644
--- a/src/glut/beos/glutState.h
+++ b/src/glut/beos/glutState.h
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutState.h
*
@@ -22,7 +27,8 @@
***********************************************************/
struct GlutState {
BApplication *display;
- char *programName; // used in error messages
+ thread_id appthread;
+
int initX, initY; // initial window position
int initWidth, initHeight; // initial window size
unsigned int displayMode; // initial display mode
@@ -39,11 +45,11 @@ struct GlutState {
int modifierKeys; // only valid during keyboard callback
bool debug; // call glGetError
- bool swapHack;
+ bool quitAll; // quit
GlutState() {
display = 0;
- programName = 0;
+ appthread = 0;
initX = initY = -1;
initWidth = initHeight = 300;
displayMode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH;
@@ -55,11 +61,11 @@ struct GlutState {
idle = 0;
menuStatus = 0;
modifierKeys = ~0;
- debug = swapHack = false;
+ debug = quitAll = false;
}
};
/***********************************************************
* Global variable (declared in glutInit.cpp)
***********************************************************/
-extern GlutState gState; \ No newline at end of file
+extern GlutState gState;
diff --git a/src/glut/beos/glutWindow.cpp b/src/glut/beos/glutWindow.cpp
index dbdd3b84a8..66ea2a00a8 100644
--- a/src/glut/beos/glutWindow.cpp
+++ b/src/glut/beos/glutWindow.cpp
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutWindow.cpp
*
@@ -117,10 +122,8 @@ GlutWindow::GlutWindow(GlutWindow *nparent, char *name,
keyboard = 0;
visibility = 0;
special = 0;
-
- // faked out single buffering
- swapHack = gState.swapHack;
-
+ windowStatus = 0;
+
// clear event counters
anyevents = 1;
displayEvent = 1; // get a reshape and a display event right away
@@ -130,11 +133,12 @@ GlutWindow::GlutWindow(GlutWindow *nparent, char *name,
passiveEvent = 0;
entryEvent = 0;
keybEvent = 0;
- visEvent = 1; // we also get a visibility event
- visState = GLUT_VISIBLE;
+ windowStatusEvent = 0; // DirectConnected() will report change in
+ visState = -1; // visibility
specialEvent = 0;
statusEvent = 0;
menuEvent = 0;
+ visible = true;
gBlock.QuickNewEvent();
// if i'm a subwindow, add me to my parent view
@@ -147,6 +151,7 @@ GlutWindow::GlutWindow(GlutWindow *nparent, char *name,
GlutBWindow *mybwindow = new GlutBWindow(
BRect(x,y,x+width-1,y+height-1), name);
mybwindow->AddChild(this);
+ mybwindow->bgl = this;
mybwindow->Show();
}
@@ -291,22 +296,27 @@ __glutDestroyWindow(GlutWindow *window, GlutWindow *initialWindow) {
***********************************************************/
void glutDestroyWindow(int win) {
// can't destroy a window if another window has the GL context
- gState.currentWindow->UnlockGL();
-
+ if (gState.currentWindow)
+ gState.currentWindow->UnlockGL();
+
// lock the window
GlutWindow *window = gState.windowList[win-1];
BWindow *bwindow = window->Window();
bwindow->Lock();
- // if win is the current window, set current window to 0 and unlock GL
+ // if win is the current window, set current window to 0
if (gState.currentWindow == window) {
-
gState.currentWindow = 0;
}
// recursively set child entries to 0
__glutDestroyWindow(window, window);
-
+
+ // try flushing OpenGL
+ window->LockGL();
+ glFlush();
+ window->UnlockGL();
+
// now, if the window was top-level, delete its BWindow
if(!window->parent) {
bwindow->Quit();
@@ -316,13 +326,31 @@ void glutDestroyWindow(int win) {
delete window;
bwindow->Unlock();
}
-
// relock GL if the current window is still valid
if(gState.currentWindow)
gState.currentWindow->LockGL();
}
/***********************************************************
+ * FUNCTION: __glutDestroyAllWindows
+ *
+ * DESCRIPTION: destroy all windows when exit() is called
+ * this seems to be necessary to avoid delays
+ * and crashes when using BDirectWindow
+ ***********************************************************/
+void __glutDestroyAllWindows() {
+ for(int i=0; i<gState.windowListSize; i++) {
+ if (gState.windowList[i]) {
+ glutDestroyWindow(i + 1);
+ }
+ }
+ gState.display->Lock();
+ gState.display->Quit();
+ status_t ignored;
+ wait_for_thread(gState.appthread, &ignored);
+}
+
+/***********************************************************
* FUNCTION: glutPostRedisplay (4.5)
*
* DESCRIPTION: mark window as needing redisplay
@@ -336,6 +364,20 @@ void glutPostRedisplay() {
}
/***********************************************************
+ * FUNCTION: glutPostWindowRedisplay
+ *
+ * DESCRIPTION: mark window as needing redisplay
+ ***********************************************************/
+void glutPostWindowRedisplay(int win) {
+ GlutWindow *gwin = gState.windowList[win - 1];
+ gwin->Window()->Lock();
+ gwin->anyevents = true;
+ gwin->displayEvent = true;
+ gwin->Window()->Unlock();
+ gBlock.QuickNewEvent();
+}
+
+/***********************************************************
* FUNCTION: glutSwapBuffers (4.6)
*
* DESCRIPTION: swap buffers
@@ -350,12 +392,17 @@ void glutSwapBuffers() {
* DESCRIPTION: move window
***********************************************************/
void glutPositionWindow(int x, int y) {
- gState.currentWindow->Window()->Lock();
+ BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
+ win->Lock();
if (gState.currentWindow->parent)
gState.currentWindow->MoveTo(x, y); // move the child view
- else
- gState.currentWindow->Window()->MoveTo(x, y); // move the window
- gState.currentWindow->Window()->Unlock();
+ else {
+ if(win->IsFullScreen()) {
+ win->SetFullScreen(false);
+ }
+ win->MoveTo(x, y); // move the window
+ }
+ win->Unlock();
}
/***********************************************************
@@ -365,26 +412,29 @@ void glutPositionWindow(int x, int y) {
* when the view gets a Draw() message
***********************************************************/
void glutReshapeWindow(int width, int height) {
- gState.currentWindow->Window()->Lock();
+ BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
+ win->Lock();
if (gState.currentWindow->parent)
gState.currentWindow->ResizeTo(width-1, height-1); // resize the child
- else
- gState.currentWindow->Window()->ResizeTo(width-1, height-1); // resize the parent
- gState.currentWindow->Window()->Unlock();
+ else {
+ if(win->IsFullScreen()) {
+ win->SetFullScreen(false);
+ }
+ win->ResizeTo(width-1, height-1); // resize the parent
+ }
+ win->Unlock();
}
/***********************************************************
* FUNCTION: glutFullScreen (4.9)
*
* DESCRIPTION: makes the window full screen
- * NOTE: we could add Game Kit support later?
***********************************************************/
void glutFullScreen() {
- gState.currentWindow->Window()->Lock();
- BRect frame = BScreen(gState.currentWindow->Window()).Frame();
- glutPositionWindow(0, 0);
- glutReshapeWindow((int)(frame.Width()) + 1, (int)(frame.Height()) + 1);
- gState.currentWindow->Window()->Unlock();
+ BDirectWindow *win = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
+ win->Lock();
+ win->SetFullScreen(true);
+ win->Unlock();
}
/***********************************************************
@@ -411,7 +461,8 @@ void glutShowWindow() {
if (gState.currentWindow->parent) // subwindow
gState.currentWindow->Show();
else {
- gState.currentWindow->Window()->Show(); // show the actual BWindow
+ if(gState.currentWindow->Window()->IsHidden())
+ gState.currentWindow->Window()->Show(); // show the actual BWindow
gState.currentWindow->Window()->Minimize(false);
}
gState.currentWindow->Window()->Unlock();
@@ -476,21 +527,20 @@ int __glutConvertDisplayMode(unsigned long *options) {
}
if(options) {
- ulong newoptions = BGL_DOUBLE;
+ ulong newoptions = 0;
if(gState.displayMode & GLUT_ACCUM)
newoptions |= BGL_ACCUM;
if(gState.displayMode & GLUT_ALPHA)
newoptions |= BGL_ALPHA;
if(gState.displayMode & GLUT_DEPTH)
newoptions |= BGL_DEPTH;
+ if(gState.displayMode & GLUT_DOUBLE)
+ newoptions |= BGL_DOUBLE;
if(gState.displayMode & GLUT_STENCIL)
newoptions |= BGL_STENCIL;
*options = newoptions;
}
- // if not GLUT_DOUBLE, turn on the swap hack bit
- gState.swapHack = !(gState.displayMode & GLUT_DOUBLE);
-
if(gState.displayMode & GLUT_INDEX) {
__glutWarning("BeOS doesn't support indexed color");
return 0;
@@ -515,11 +565,69 @@ int __glutConvertDisplayMode(unsigned long *options) {
* DESCRIPTION: very thin wrapper around BWindow
***********************************************************/
GlutBWindow::GlutBWindow(BRect frame, char *name) :
- BWindow(frame, name, B_TITLED_WINDOW, 0) {
+ BDirectWindow(frame, name, B_TITLED_WINDOW, 0) {
+ fConnectionDisabled = false;
+ bgl = 0;
SetPulseRate(100000);
+
+ if (!SupportsWindowMode()) {
+ __glutFatalError("video card doesn't support windowed operation");
+ }
}
+void GlutBWindow::DirectConnected( direct_buffer_info *info ) {
+ bgl->DirectConnected(info);
+ if(bgl && !fConnectionDisabled) {
+ bgl->EnableDirectMode(true);
+ }
+ int newVisState;
+ if((info->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_START) {
+ bgl->visible = true;
+ }
+ if(!bgl->visible || info->buffer_state == B_DIRECT_STOP)
+ newVisState = GLUT_HIDDEN;
+ else {
+ if (info->clip_list_count == 0)
+ newVisState = GLUT_FULLY_COVERED;
+ else if (info->clip_list_count == 1)
+ newVisState = GLUT_FULLY_RETAINED;
+ else
+ newVisState = GLUT_PARTIALLY_RETAINED;
+ }
+ if(newVisState != bgl->visState) {
+ bgl->visState = newVisState;
+ bgl->anyevents = bgl->windowStatusEvent = true;
+ gBlock.NewEvent();
+ }
+}
+
+GlutBWindow::~GlutBWindow() {
+ fConnectionDisabled = true;
+ if(bgl) {
+ bgl->EnableDirectMode(false);
+ }
+ if(!IsHidden())
+ Hide();
+ Sync();
+}
+
bool GlutBWindow::QuitRequested() {
- exit(0); // exit program completely on quit
- return true; // UNREACHED
+ gState.quitAll = true;
+ gBlock.NewEvent();
+ return false; // don't quit now, wait for main thread to do it
+}
+
+void GlutBWindow::Minimize(bool minimize) {
+ bgl->visible = !minimize;
+ BWindow::Minimize(minimize);
+}
+
+void GlutBWindow::Hide() {
+ BWindow::Hide();
+ bgl->visible = false;
+}
+
+void GlutBWindow::Show() {
+ BWindow::Show();
+ bgl->visible = true;
}
diff --git a/src/glut/beos/glutWindow.h b/src/glut/beos/glutWindow.h
index 7a4292e733..d3ac186269 100644
--- a/src/glut/beos/glutWindow.h
+++ b/src/glut/beos/glutWindow.h
@@ -1,5 +1,10 @@
/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
+ * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
+ *
+ * This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain.
+ *
*
* FILE: glutWindow.h
*
@@ -32,8 +37,6 @@ public:
void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
void FrameResized(float width, float height);
void Draw(BRect updateRect);
- void Hide();
- void Show();
void Pulse(); // needed since MouseUp() is broken
void MouseCheck(); // check for button state changes
void ErrorCallback(GLenum errorCode);
@@ -62,6 +65,7 @@ public:
GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */
GLUTvisibilityCB visibility; /* visibility */
GLUTspecialCB special; /* special key */
+ GLUTwindowStatusCB windowStatus; /* window status */
bool anyevents; // were any events received?
bool displayEvent; // call display
@@ -71,13 +75,11 @@ public:
bool passiveEvent; // call passive
bool entryEvent; // call entry
bool keybEvent; // call keyboard
- bool visEvent; // call visibility
+ bool windowStatusEvent; // call visibility
bool specialEvent; // call special
bool statusEvent; // menu status changed
bool menuEvent; // menu selected
- bool swapHack; // faked out single buffering
-
int button, mouseState; // for mouse callback
int mouseX, mouseY; // for mouse callback
int motionX, motionY; // for motion callback
@@ -93,17 +95,25 @@ public:
int statusX, statusY; // for status callback
int menuNumber; // for menu and status callbacks
int menuValue; // for menu callback
+ bool visible; // for visibility callback
};
/***********************************************************
* CLASS: GlutBWindow
*
- * INHERITS FROM: BWindow
+ * INHERITS FROM: BDirectWindow
*
* DESCRIPTION: basically a BWindow that won't quit
***********************************************************/
-class GlutBWindow : public BWindow {
+class GlutBWindow : public BDirectWindow {
public:
GlutBWindow(BRect frame, char *name);
+ ~GlutBWindow();
+ void DirectConnected(direct_buffer_info *info);
bool QuitRequested(); // exits app
-}; \ No newline at end of file
+ void Minimize(bool minimized); // minimized windows are not visible
+ void Hide();
+ void Show();
+ GlutWindow *bgl;
+ bool fConnectionDisabled;
+};
diff --git a/src/glut/beos/glutbitmap.h b/src/glut/beos/glutbitmap.h
index 55d341706c..32bf53c097 100644
--- a/src/glut/beos/glutbitmap.h
+++ b/src/glut/beos/glutbitmap.h
@@ -7,12 +7,7 @@
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
-
-#if defined(WIN32)
-#include <windows.h>
-#pragma warning(disable:4244)
-#endif /* WIN32 */
-#include <GL/gl.h>
+#include <GL/glut.h>
typedef struct {
const GLsizei width;
diff --git a/src/glut/beos/glutint.h b/src/glut/beos/glutint.h
index 5ce2970d24..06b417e9ca 100644
--- a/src/glut/beos/glutint.h
+++ b/src/glut/beos/glutint.h
@@ -1,18 +1,253 @@
-/***********************************************************
- * Copyright (C) 1997, Be Inc. All rights reserved.
- *
- * FILE: glutint.h
- *
- * DESCRIPTION: This is the new glut internal header file.
- * most of the things formerly stored here are now in
- * their own header files as C++ classes.
- ***********************************************************/
+#ifndef __glutint_h__
+#define __glutint_h__
-#include <SupportDefs.h>
+/* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+#if defined(__CYGWIN32__)
+#include <sys/time.h>
+#endif
+
+#if defined(_WIN32)
+#include "glutwin32.h"
+#elif !defined(__BEOS__)
+#ifdef __sgi
+#define SUPPORT_FORTRAN
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+#endif
+
+#include <GL/glut.h>
+
+/* Non-Win32 platforms need APIENTRY defined to nothing
+ because all the GLUT routines have the APIENTRY prefix
+ to make Win32 happy. */
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+#ifdef __vms
+#if ( __VMS_VER < 70000000 )
+struct timeval {
+ __int64 val;
+};
+extern int sys$gettim(struct timeval *);
+#else
+#include <time.h>
+#endif
+#else
+#include <sys/types.h>
+#if !defined(_WIN32)
+#include <sys/time.h>
+#else
+#include <winsock.h>
+#endif
+#endif
+#if defined(__vms) && ( __VMS_VER < 70000000 )
+
+/* For VMS6.2 or lower :
+ One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
+ 0.0001 milliseconds. This means that there are 0.01
+ ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
+ ticks/second. */
+
+#define TICKS_PER_MILLISECOND 10000
+#define TICKS_PER_SECOND 10000000
+
+#define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
+
+#define ADD_TIME(dest, src1, src2) { \
+ (dest).val = (src1).val + (src2).val; \
+}
+
+#define TIMEDELTA(dest, src1, src2) { \
+ (dest).val = (src1).val - (src2).val; \
+}
+
+#define IS_AFTER(t1, t2) ((t2).val > (t1).val)
+
+#define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
+
+#else
+#if defined(SVR4) && !defined(sun) /* Sun claims SVR4, but
+ wants 2 args. */
+#define GETTIMEOFDAY(_x) gettimeofday(_x)
+#else
+#define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
+#endif
+#define ADD_TIME(dest, src1, src2) { \
+ if(((dest).tv_usec = \
+ (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
+ (dest).tv_usec -= 1000000; \
+ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
+ } else { \
+ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
+ if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
+ (dest).tv_sec --;(dest).tv_usec += 1000000; \
+ } \
+ } \
+}
+#define TIMEDELTA(dest, src1, src2) { \
+ if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
+ (dest).tv_usec += 1000000; \
+ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
+ } else { \
+ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
+ } \
+}
+#define IS_AFTER(t1, t2) \
+ (((t2).tv_sec > (t1).tv_sec) || \
+ (((t2).tv_sec == (t1).tv_sec) && \
+ ((t2).tv_usec > (t1).tv_usec)))
+#define IS_AT_OR_AFTER(t1, t2) \
+ (((t2).tv_sec > (t1).tv_sec) || \
+ (((t2).tv_sec == (t1).tv_sec) && \
+ ((t2).tv_usec >= (t1).tv_usec)))
+#endif
+
+#define IGNORE_IN_GAME_MODE() \
+ { if (__glutGameModeWindow) return; }
+
+/* BeOS doesn't need most of this file */
+#ifndef __BEOS__
+
+#define GLUT_WIND_IS_RGB(x) (((x) & GLUT_INDEX) == 0)
+#define GLUT_WIND_IS_INDEX(x) (((x) & GLUT_INDEX) != 0)
+#define GLUT_WIND_IS_SINGLE(x) (((x) & GLUT_DOUBLE) == 0)
+#define GLUT_WIND_IS_DOUBLE(x) (((x) & GLUT_DOUBLE) != 0)
+#define GLUT_WIND_HAS_ACCUM(x) (((x) & GLUT_ACCUM) != 0)
+#define GLUT_WIND_HAS_ALPHA(x) (((x) & GLUT_ALPHA) != 0)
+#define GLUT_WIND_HAS_DEPTH(x) (((x) & GLUT_DEPTH) != 0)
+#define GLUT_WIND_HAS_STENCIL(x) (((x) & GLUT_STENCIL) != 0)
+#define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
+#define GLUT_WIND_IS_STEREO(x) (((x) & GLUT_STEREO) != 0)
+#define GLUT_WIND_IS_LUMINANCE(x) (((x) & GLUT_LUMINANCE) != 0)
+#define GLUT_MAP_WORK (1 << 0)
+#define GLUT_EVENT_MASK_WORK (1 << 1)
+#define GLUT_REDISPLAY_WORK (1 << 2)
+#define GLUT_CONFIGURE_WORK (1 << 3)
+#define GLUT_COLORMAP_WORK (1 << 4)
+#define GLUT_DEVICE_MASK_WORK (1 << 5)
+#define GLUT_FINISH_WORK (1 << 6)
+#define GLUT_DEBUG_WORK (1 << 7)
+#define GLUT_DUMMY_WORK (1 << 8)
+#define GLUT_FULL_SCREEN_WORK (1 << 9)
+#define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
+#define GLUT_REPAIR_WORK (1 << 11)
+#define GLUT_OVERLAY_REPAIR_WORK (1 << 12)
+
+/* Frame buffer capability macros and types. */
+#define RGBA 0
+#define BUFFER_SIZE 1
+#define DOUBLEBUFFER 2
+#define STEREO 3
+#define AUX_BUFFERS 4
+#define RED_SIZE 5 /* Used as mask bit for
+ "color selected". */
+#define GREEN_SIZE 6
+#define BLUE_SIZE 7
+#define ALPHA_SIZE 8
+#define DEPTH_SIZE 9
+#define STENCIL_SIZE 10
+#define ACCUM_RED_SIZE 11 /* Used as mask bit for
+ "acc selected". */
+#define ACCUM_GREEN_SIZE 12
+#define ACCUM_BLUE_SIZE 13
+#define ACCUM_ALPHA_SIZE 14
+#define LEVEL 15
-/***********************************************************
- * GLUT function types
- ***********************************************************/
+#define NUM_GLXCAPS (LEVEL + 1)
+
+#define XVISUAL (NUM_GLXCAPS + 0)
+#define TRANSPARENT (NUM_GLXCAPS + 1)
+#define SAMPLES (NUM_GLXCAPS + 2)
+#define XSTATICGRAY (NUM_GLXCAPS + 3) /* Used as
+ mask bit
+ for "any
+ visual type
+ selected". */
+#define XGRAYSCALE (NUM_GLXCAPS + 4)
+#define XSTATICCOLOR (NUM_GLXCAPS + 5)
+#define XPSEUDOCOLOR (NUM_GLXCAPS + 6)
+#define XTRUECOLOR (NUM_GLXCAPS + 7)
+#define XDIRECTCOLOR (NUM_GLXCAPS + 8)
+#define SLOW (NUM_GLXCAPS + 9)
+#define CONFORMANT (NUM_GLXCAPS + 10)
+
+#define NUM_CAPS (NUM_GLXCAPS + 11)
+
+/* Frame buffer capablities that don't have a corresponding
+ FrameBufferMode entry. These get used as mask bits. */
+#define NUM (NUM_CAPS + 0)
+#define RGBA_MODE (NUM_CAPS + 1)
+#define CI_MODE (NUM_CAPS + 2)
+#define LUMINANCE_MODE (NUM_CAPS + 3)
+
+#define NONE 0
+#define EQ 1
+#define NEQ 2
+#define LTE 3
+#define GTE 4
+#define GT 5
+#define LT 6
+#define MIN 7
+
+typedef struct _Criterion {
+ int capability;
+ int comparison;
+ int value;
+} Criterion;
+
+typedef struct _FrameBufferMode {
+ XVisualInfo *vi;
+#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
+
+ /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
+ (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
+ the visual's fbconfig is OpenGL-capable. The reason for this is typically
+ an RGBA luminance fbconfig such as 16-bit StaticGray that could
+ not be advertised as a GLX visual since StaticGray visuals are
+ required (by the GLX specification) to be color index. The
+ SGIX_fbconfig allows StaticGray visuals to instead advertised as
+ fbconfigs that can provide RGBA luminance support. */
+
+ GLXFBConfigSGIX fbc;
+#endif
+ int valid;
+ int cap[NUM_CAPS];
+} FrameBufferMode;
+
+/* DisplayMode capability macros for game mode. */
+#define DM_WIDTH 0 /* "width" */
+#define DM_HEIGHT 1 /* "height" */
+#define DM_PIXEL_DEPTH 2 /* "bpp" (bits per pixel) */
+#define DM_HERTZ 3 /* "hertz" */
+#define DM_NUM 4 /* "num" */
+
+#define NUM_DM_CAPS (DM_NUM+1)
+
+typedef struct _DisplayMode {
+#ifdef _WIN32
+ DEVMODE devmode;
+#else
+ /* XXX The X Window System does not have a standard
+ mechanism for display setting changes. On SGI
+ systems, GLUT could use the XSGIvc (SGI X video
+ control extension). Perhaps this can be done in
+ a future release of GLUT. */
+#endif
+ int valid;
+ int cap[NUM_DM_CAPS];
+} DisplayMode;
+
+#endif /* BeOS */
+
+/* GLUT function types */
typedef void (*GLUTdisplayCB) (void);
typedef void (*GLUTreshapeCB) (int, int);
typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
@@ -24,8 +259,7 @@ typedef void (*GLUTvisibilityCB) (int);
typedef void (*GLUTwindowStatusCB) (int);
typedef void (*GLUTidleCB) (void);
typedef void (*GLUTtimerCB) (int);
-typedef void (*GLUTmenuStateCB) (int); /* DEPRICATED.
- */
+typedef void (*GLUTmenuStateCB) (int); /* DEPRICATED. */
typedef void (*GLUTmenuStatusCB) (int, int, int);
typedef void (*GLUTselectCB) (int);
typedef void (*GLUTspecialCB) (int, int, int);
@@ -36,40 +270,545 @@ typedef void (*GLUTdialsCB) (int, int);
typedef void (*GLUTbuttonBoxCB) (int, int);
typedef void (*GLUTtabletMotionCB) (int, int);
typedef void (*GLUTtabletButtonCB) (int, int, int, int);
+typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
+#ifdef SUPPORT_FORTRAN
+typedef void (*GLUTdisplayFCB) (void);
+typedef void (*GLUTreshapeFCB) (int *, int *);
+/* NOTE the pressed key is int, not unsigned char for Fortran! */
+typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
+typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
+typedef void (*GLUTmotionFCB) (int *, int *);
+typedef void (*GLUTpassiveFCB) (int *, int *);
+typedef void (*GLUTentryFCB) (int *);
+typedef void (*GLUTvisibilityFCB) (int *);
+typedef void (*GLUTwindowStatusFCB) (int *);
+typedef void (*GLUTidleFCB) (void);
+typedef void (*GLUTtimerFCB) (int *);
+typedef void (*GLUTmenuStateFCB) (int *); /* DEPRICATED. */
+typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
+typedef void (*GLUTselectFCB) (int *);
+typedef void (*GLUTspecialFCB) (int *, int *, int *);
+typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
+typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
+typedef void (*GLUTspaceButtonFCB) (int *, int *);
+typedef void (*GLUTdialsFCB) (int *, int *);
+typedef void (*GLUTbuttonBoxFCB) (int *, int *);
+typedef void (*GLUTtabletMotionFCB) (int *, int *);
+typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
+typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
+#endif
+
+#ifndef __BEOS__
+
+typedef struct _GLUTcolorcell GLUTcolorcell;
+struct _GLUTcolorcell {
+ /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
+ GLfloat component[3];
+};
+
+typedef struct _GLUTcolormap GLUTcolormap;
+struct _GLUTcolormap {
+ Visual *visual; /* visual of the colormap */
+ Colormap cmap; /* X colormap ID */
+ int refcnt; /* number of windows using colormap */
+ int size; /* number of cells in colormap */
+ int transparent; /* transparent pixel, or -1 if opaque */
+ GLUTcolorcell *cells; /* array of cells */
+ GLUTcolormap *next; /* next colormap in list */
+};
+
+typedef struct _GLUTwindow GLUTwindow;
+typedef struct _GLUToverlay GLUToverlay;
+struct _GLUTwindow {
+ int num; /* Small integer window id (0-based). */
+
+ /* Window system related state. */
+#if defined(_WIN32)
+ int pf; /* Pixel format. */
+ HDC hdc; /* Window's Win32 device context. */
+#endif
+ Window win; /* X window for GLUT window */
+ GLXContext ctx; /* OpenGL context GLUT glut window */
+ XVisualInfo *vis; /* visual for window */
+ Bool visAlloced; /* if vis needs deallocate on destroy */
+ Colormap cmap; /* RGB colormap for window; None if CI */
+ GLUTcolormap *colormap; /* colormap; NULL if RGBA */
+ GLUToverlay *overlay; /* overlay; NULL if no overlay */
+#if defined(_WIN32)
+ HDC renderDc; /* Win32's device context for rendering. */
+#endif
+ Window renderWin; /* X window for rendering (might be
+ overlay) */
+ GLXContext renderCtx; /* OpenGL context for rendering (might
+ be overlay) */
+ /* GLUT settable or visible window state. */
+ int width; /* window width in pixels */
+ int height; /* window height in pixels */
+ int cursor; /* cursor name */
+ int visState; /* visibility state (-1 is unknown) */
+ int shownState; /* if window mapped */
+ int entryState; /* entry state (-1 is unknown) */
+#define GLUT_MAX_MENUS 3
+
+ int menu[GLUT_MAX_MENUS]; /* attatched menu nums */
+ /* Window relationship state. */
+ GLUTwindow *parent; /* parent window */
+ GLUTwindow *children; /* list of children */
+ GLUTwindow *siblings; /* list of siblings */
+ /* Misc. non-API visible (hidden) state. */
+ Bool treatAsSingle; /* treat this window as single-buffered
+ (it might be "fake" though) */
+ Bool forceReshape; /* force reshape before display */
+#if !defined(_WIN32)
+ Bool isDirect; /* if direct context (X11 only) */
+#endif
+ Bool usedSwapBuffers; /* if swap buffers used last display */
+ long eventMask; /* mask of X events selected for */
+ int buttonUses; /* number of button uses, ref cnt */
+ int tabletPos[2]; /* tablet position (-1 is invalid) */
+ /* Work list related state. */
+ unsigned int workMask; /* mask of window work to be done */
+ GLUTwindow *prevWorkWin; /* link list of windows to work on */
+ Bool desiredMapState; /* how to mapped window if on map work
+ list */
+ Bool ignoreKeyRepeat; /* if window ignores autorepeat */
+ int desiredConfMask; /* mask of desired window configuration
+ */
+ int desiredX; /* desired X location */
+ int desiredY; /* desired Y location */
+ int desiredWidth; /* desired window width */
+ int desiredHeight; /* desired window height */
+ int desiredStack; /* desired window stack */
+ /* Per-window callbacks. */
+ GLUTdisplayCB display; /* redraw */
+ GLUTreshapeCB reshape; /* resize (width,height) */
+ GLUTmouseCB mouse; /* mouse (button,state,x,y) */
+ GLUTmotionCB motion; /* motion (x,y) */
+ GLUTpassiveCB passive; /* passive motion (x,y) */
+ GLUTentryCB entry; /* window entry/exit (state) */
+ GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */
+ GLUTkeyboardCB keyboardUp; /* keyboard up (ASCII,x,y) */
+ GLUTwindowStatusCB windowStatus; /* window status */
+ GLUTvisibilityCB visibility; /* visibility */
+ GLUTspecialCB special; /* special key */
+ GLUTspecialCB specialUp; /* special up key */
+ GLUTbuttonBoxCB buttonBox; /* button box */
+ GLUTdialsCB dials; /* dials */
+ GLUTspaceMotionCB spaceMotion; /* Spaceball motion */
+ GLUTspaceRotateCB spaceRotate; /* Spaceball rotate */
+ GLUTspaceButtonCB spaceButton; /* Spaceball button */
+ GLUTtabletMotionCB tabletMotion; /* tablet motion */
+ GLUTtabletButtonCB tabletButton; /* tablet button */
+#ifdef _WIN32
+ GLUTjoystickCB joystick; /* joystick */
+ int joyPollInterval; /* joystick polling interval */
+#endif
+#ifdef SUPPORT_FORTRAN
+ /* Special Fortran display unneeded since no
+ parameters! */
+ GLUTreshapeFCB freshape; /* Fortran reshape */
+ GLUTmouseFCB fmouse; /* Fortran mouse */
+ GLUTmotionFCB fmotion; /* Fortran motion */
+ GLUTpassiveFCB fpassive; /* Fortran passive */
+ GLUTentryFCB fentry; /* Fortran entry */
+ GLUTkeyboardFCB fkeyboard; /* Fortran keyboard */
+ GLUTkeyboardFCB fkeyboardUp; /* Fortran keyboard up */
+ GLUTwindowStatusFCB fwindowStatus; /* Fortran visibility
+ */
+ GLUTvisibilityFCB fvisibility; /* Fortran visibility
+ */
+ GLUTspecialFCB fspecial; /* special key */
+ GLUTspecialFCB fspecialUp; /* special key up */
+ GLUTbuttonBoxFCB fbuttonBox; /* button box */
+ GLUTdialsFCB fdials; /* dials */
+ GLUTspaceMotionFCB fspaceMotion; /* Spaceball motion
+ */
+ GLUTspaceRotateFCB fspaceRotate; /* Spaceball rotate
+ */
+ GLUTspaceButtonFCB fspaceButton; /* Spaceball button
+ */
+ GLUTtabletMotionFCB ftabletMotion; /* tablet motion
+ */
+ GLUTtabletButtonFCB ftabletButton; /* tablet button
+ */
+#ifdef _WIN32
+ GLUTjoystickFCB fjoystick; /* joystick */
+#endif
+#endif
+};
-/***********************************************************
- * Prototypes for glutInit.cpp
- ***********************************************************/
+struct _GLUToverlay {
+#if defined(_WIN32)
+ int pf;
+ HDC hdc;
+#endif
+ Window win;
+ GLXContext ctx;
+ XVisualInfo *vis; /* visual for window */
+ Bool visAlloced; /* if vis needs deallocate on destroy */
+ Colormap cmap; /* RGB colormap for window; None if CI */
+ GLUTcolormap *colormap; /* colormap; NULL if RGBA */
+ int shownState; /* if overlay window mapped */
+ Bool treatAsSingle; /* treat as single-buffered */
+#if !defined(_WIN32)
+ Bool isDirect; /* if direct context */
+#endif
+ int transparentPixel; /* transparent pixel value */
+ GLUTdisplayCB display; /* redraw */
+ /* Special Fortran display unneeded since no
+ parameters! */
+};
+
+typedef struct _GLUTstale GLUTstale;
+struct _GLUTstale {
+ GLUTwindow *window;
+ Window win;
+ GLUTstale *next;
+};
+
+extern GLUTstale *__glutStaleWindowList;
+
+#define GLUT_OVERLAY_EVENT_FILTER_MASK \
+ (ExposureMask | \
+ StructureNotifyMask | \
+ EnterWindowMask | \
+ LeaveWindowMask)
+#define GLUT_DONT_PROPAGATE_FILTER_MASK \
+ (ButtonReleaseMask | \
+ ButtonPressMask | \
+ KeyPressMask | \
+ KeyReleaseMask | \
+ PointerMotionMask | \
+ Button1MotionMask | \
+ Button2MotionMask | \
+ Button3MotionMask)
+#define GLUT_HACK_STOP_PROPAGATE_MASK \
+ (KeyPressMask | \
+ KeyReleaseMask)
+
+typedef struct _GLUTmenu GLUTmenu;
+typedef struct _GLUTmenuItem GLUTmenuItem;
+struct _GLUTmenu {
+ int id; /* small integer menu id (0-based) */
+ Window win; /* X window for the menu */
+ GLUTselectCB select; /* function of menu */
+ GLUTmenuItem *list; /* list of menu entries */
+ int num; /* number of entries */
+#if !defined(_WIN32)
+ Bool managed; /* are the InputOnly windows size
+ validated? */
+ Bool searched; /* help detect menu loops */
+ int pixheight; /* height of menu in pixels */
+ int pixwidth; /* width of menu in pixels */
+#endif
+ int submenus; /* number of submenu entries */
+ GLUTmenuItem *highlighted; /* pointer to highlighted menu
+ entry, NULL not highlighted */
+ GLUTmenu *cascade; /* currently cascading this menu */
+ GLUTmenuItem *anchor; /* currently anchored to this entry */
+ int x; /* current x origin relative to the
+ root window */
+ int y; /* current y origin relative to the
+ root window */
+#ifdef SUPPORT_FORTRAN
+ GLUTselectFCB fselect; /* function of menu */
+#endif
+};
+
+struct _GLUTmenuItem {
+ Window win; /* InputOnly X window for entry */
+ GLUTmenu *menu; /* menu entry belongs to */
+ Bool isTrigger; /* is a submenu trigger? */
+ int value; /* value to return for selecting this
+ entry; doubles as submenu id
+ (0-base) if submenu trigger */
+#if defined(_WIN32)
+ UINT unique; /* unique menu item id (Win32 only) */
+#endif
+ char *label; /* __glutStrdup'ed label string */
+ int len; /* length of label string */
+ int pixwidth; /* width of X window in pixels */
+ GLUTmenuItem *next; /* next menu entry on list for menu */
+};
+
+typedef struct _GLUTtimer GLUTtimer;
+struct _GLUTtimer {
+ GLUTtimer *next; /* list of timers */
+ struct timeval timeout; /* time to be called */
+ GLUTtimerCB func; /* timer (value) */
+ int value; /* return value */
+#ifdef SUPPORT_FORTRAN
+ GLUTtimerFCB ffunc; /* Fortran timer */
+#endif
+};
+
+typedef struct _GLUTeventParser GLUTeventParser;
+struct _GLUTeventParser {
+ int (*func) (XEvent *);
+ GLUTeventParser *next;
+};
+
+/* Declarations to implement glutFullScreen support with
+ mwm/4Dwm. */
+
+/* The following X property format is defined in Motif 1.1's
+ Xm/MwmUtils.h, but GLUT should not depend on that header
+ file. Note: Motif 1.2 expanded this structure with
+ uninteresting fields (to GLUT) so just stick with the
+ smaller Motif 1.1 structure. */
+typedef struct {
+#define MWM_HINTS_DECORATIONS 2
+ long flags;
+ long functions;
+ long decorations;
+ long input_mode;
+} MotifWmHints;
+
+/* Make current and buffer swap macros. */
+#ifdef _WIN32
+#define MAKE_CURRENT_LAYER(window) \
+ { \
+ HGLRC currentContext = wglGetCurrentContext(); \
+ HDC currentDc = wglGetCurrentDC(); \
+ \
+ if (currentContext != window->renderCtx \
+ || currentDc != window->renderDc) { \
+ wglMakeCurrent(window->renderDc, window->renderCtx); \
+ } \
+ }
+#define MAKE_CURRENT_WINDOW(window) \
+ { \
+ HGLRC currentContext = wglGetCurrentContext(); \
+ HDC currentDc = wglGetCurrentDC(); \
+ \
+ if (currentContext != window->ctx || currentDc != window->hdc) { \
+ wglMakeCurrent(window->hdc, window->ctx); \
+ } \
+ }
+#define MAKE_CURRENT_OVERLAY(overlay) \
+ wglMakeCurrent(overlay->hdc, overlay->ctx)
+#define UNMAKE_CURRENT() \
+ wglMakeCurrent(NULL, NULL)
+#define SWAP_BUFFERS_WINDOW(window) \
+ SwapBuffers(window->hdc)
+#define SWAP_BUFFERS_LAYER(window) \
+ SwapBuffers(window->renderDc)
+#else
+#define MAKE_CURRENT_LAYER(window) \
+ glXMakeCurrent(__glutDisplay, window->renderWin, window->renderCtx)
+#define MAKE_CURRENT_WINDOW(window) \
+ glXMakeCurrent(__glutDisplay, window->win, window->ctx)
+#define MAKE_CURRENT_OVERLAY(overlay) \
+ glXMakeCurrent(__glutDisplay, overlay->win, overlay->ctx)
+#define UNMAKE_CURRENT() \
+ glXMakeCurrent(__glutDisplay, None, NULL)
+#define SWAP_BUFFERS_WINDOW(window) \
+ glXSwapBuffers(__glutDisplay, window->win)
+#define SWAP_BUFFERS_LAYER(window) \
+ glXSwapBuffers(__glutDisplay, window->renderWin)
+#endif
+
+/* private variables from glut_event.c */
+extern GLUTwindow *__glutWindowWorkList;
+extern int __glutWindowDamaged;
+#ifdef SUPPORT_FORTRAN
+extern GLUTtimer *__glutTimerList;
+extern GLUTtimer *__glutNewTimer;
+#endif
+extern GLUTmenu *__glutMappedMenu;
+
+extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
+#if !defined(_WIN32)
+extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
+ int num, int type);
+extern void (*__glutFinishMenu)(Window win, int x, int y);
+extern void (*__glutPaintMenu)(GLUTmenu * menu);
+extern void (*__glutStartMenu)(GLUTmenu * menu,
+ GLUTwindow * window, int x, int y, int x_win, int y_win);
+extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
+extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
+ Window win, int *which);
+extern GLUTmenu * (*__glutGetMenu)(Window win);
+#endif
+
+/* private variables from glut_init.c */
+extern Atom __glutWMDeleteWindow;
+extern Display *__glutDisplay;
+extern unsigned int __glutDisplayMode;
+extern char *__glutDisplayString;
+extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
+ Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
+extern GLboolean __glutDebug;
+extern GLboolean __glutForceDirect;
+extern GLboolean __glutIconic;
+extern GLboolean __glutTryDirect;
+extern Window __glutRoot;
+extern XSizeHints __glutSizeHints;
+extern char **__glutArgv;
+#endif /* BeOS */
+extern char *__glutProgramName;
+#ifndef __BEOS__
+extern int __glutArgc;
+extern int __glutConnectionFD;
+extern int __glutInitHeight;
+extern int __glutInitWidth;
+extern int __glutInitX;
+extern int __glutInitY;
+extern int __glutScreen;
+extern int __glutScreenHeight;
+extern int __glutScreenWidth;
+extern Atom __glutMotifHints;
+extern unsigned int __glutModifierMask;
+
+/* private variables from glut_menu.c */
+extern GLUTmenuItem *__glutItemSelected;
+extern GLUTmenu **__glutMenuList;
+extern void (*__glutMenuStatusFunc) (int, int, int);
+extern void __glutMenuModificationError(void);
+extern void __glutSetMenuItem(GLUTmenuItem * item,
+ const char *label, int value, Bool isTrigger);
+
+/* private variables from glut_win.c */
+extern GLUTwindow **__glutWindowList;
+extern GLUTwindow *__glutCurrentWindow;
+extern GLUTwindow *__glutMenuWindow;
+extern GLUTmenu *__glutCurrentMenu;
+extern int __glutWindowListSize;
+extern void (*__glutFreeOverlayFunc) (GLUToverlay *);
+extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
+ Bool * visAlloced, void **fbc);
+
+/* private variables from glut_mesa.c */
+extern int __glutMesaSwapHackSupport;
+
+/* private variables from glut_gamemode.c */
+extern GLUTwindow *__glutGameModeWindow;
+
+/* private routines from glut_cindex.c */
+extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
+extern void __glutFreeColormap(GLUTcolormap *);
+
+/* private routines from glut_cmap.c */
+extern void __glutSetupColormap(
+ XVisualInfo * vi,
+ GLUTcolormap ** colormap,
+ Colormap * cmap);
+#if !defined(_WIN32)
+extern void __glutEstablishColormapsProperty(
+ GLUTwindow * window);
+extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
+#endif
+
+/* private routines from glut_cursor.c */
+extern void __glutSetCursor(GLUTwindow *window);
+
+/* private routines from glut_event.c */
+extern void __glutPutOnWorkList(GLUTwindow * window,
+ int work_mask);
+extern void __glutRegisterEventParser(GLUTeventParser * parser);
+extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
+
+/* private routines from glut_init.c */
+#if !defined(_WIN32)
+extern void __glutOpenXConnection(char *display);
+#else
+extern void __glutOpenWin32Connection(char *display);
+#endif
+extern void __glutInitTime(struct timeval *beginning);
+
+/* private routines for glut_menu.c (or win32_menu.c) */
+#if defined(_WIN32)
+extern GLUTmenu *__glutGetMenu(Window win);
+extern GLUTmenu *__glutGetMenuByNum(int menunum);
+extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
+ Window win, int *which);
+extern void __glutStartMenu(GLUTmenu * menu,
+ GLUTwindow * window, int x, int y, int x_win, int y_win);
+extern void __glutFinishMenu(Window win, int x, int y);
+#endif
+extern void __glutSetMenu(GLUTmenu * menu);
+
+#endif /* BeOS */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* private routines from glut_util.c */
+extern char * __glutStrdup(const char *string);
+extern void __glutWarning(char *format,...);
+extern void __glutFatalError(char *format,...);
+extern void __glutFatalUsage(char *format,...);
+#ifdef __cplusplus
+}
+#endif
+#ifndef __BEOS__
+
+/* private routines from glut_win.c */
+extern GLUTwindow *__glutGetWindow(Window win);
+extern void __glutChangeWindowEventMask(long mask, Bool add);
+extern XVisualInfo *__glutDetermineVisual(
+ unsigned int mode,
+ Bool * fakeSingle,
+ XVisualInfo * (getVisualInfo) (unsigned int));
+extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
+extern void __glutSetWindow(GLUTwindow * window);
+extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
+ int callingConvention);
+extern void __glutDefaultReshape(int, int);
+extern GLUTwindow *__glutCreateWindow(
+ GLUTwindow * parent,
+ int x, int y, int width, int height, int gamemode);
+extern void __glutDestroyWindow(
+ GLUTwindow * window,
+ GLUTwindow * initialWindow);
+
+#if !defined(_WIN32)
+/* private routines from glut_glxext.c */
+extern int __glutIsSupportedByGLX(char *);
+#endif
+
+/* private routines from glut_input.c */
+extern void __glutUpdateInputDeviceMask(GLUTwindow * window);
+
+/* private routines from glut_mesa.c */
+extern void __glutDetermineMesaSwapHackSupport(void);
+
+/* private routines from glut_gameglut.c */
+extern void __glutCloseDownGameMode(void);
+
+#if defined(_WIN32)
+/* private routines from win32_*.c */
+extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
+extern HDC XHDC;
+#endif
+
+#else /* BeOS */
+/* BeOS specific C++ function prototypes */
+#ifdef __cplusplus
+
+#include <SupportDefs.h>
+
+/* private routines from glutInit.cpp */
void __glutInitTime(bigtime_t *beginning);
void __glutInit();
-/***********************************************************
- * Prototypes for glut_util.c
- ***********************************************************/
-void __glutWarning(char *format,...);
-void __glutFatalError(char *format,...);
-void __glutFatalUsage(char *format,...);
-
-/***********************************************************
- * Prototypes for glutMenu.cpp
- ***********************************************************/
-class GlutMenu; // avoid including glutMenu.h
+/* private routines from glutMenu.cpp */
+class GlutMenu; // avoid including glutMenu.h
GlutMenu *__glutGetMenuByNum(int menunum);
-
-/***********************************************************
- * Prototypes for glutWindow.cpp
- ***********************************************************/
+
+/* private routines from glutWindow.cpp */
int __glutConvertDisplayMode(unsigned long *options);
void __glutDefaultReshape(int width, int height);
-class GlutWindow; // avoid including glutWindow.h in every source file
+class GlutWindow; // avoid including glutWindow.h in every source file
void __glutSetWindow(GlutWindow * window);
+void __glutDestroyAllWindows();
-/***********************************************************
- * Prototypes for glutDstr.cpp
- ***********************************************************/
+/* private routines from glutDstr.cpp */
int __glutConvertDisplayModeFromString(unsigned long *options);
-/***********************************************************
- * Prototypes for glutCursor.cpp
- ***********************************************************/
+/* private routines from glutCursor.cpp */
void __glutSetCursor(int cursor);
+
+#endif /* __cplusplus */
+#endif /* BeOS */
+
+#endif /* __glutint_h__ */
diff --git a/src/glut/beos/glutstroke.h b/src/glut/beos/glutstroke.h
index 4712ebbde9..cbc9e156fe 100644
--- a/src/glut/beos/glutstroke.h
+++ b/src/glut/beos/glutstroke.h
@@ -7,8 +7,9 @@
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
-#if defined(WIN32)
-#pragma warning (disable:4244)
+#if defined(_WIN32)
+#pragma warning (disable:4244) /* disable bogus conversion warnings */
+#pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
#endif
typedef struct {