aboutsummaryrefslogtreecommitdiffstats
path: root/src/glut/dos/init.c
diff options
context:
space:
mode:
authorDaniel Borca <[email protected]>2005-02-14 15:04:52 +0000
committerDaniel Borca <[email protected]>2005-02-14 15:04:52 +0000
commit84396a72dffd04115e2952847793261143ba1f09 (patch)
tree84631079a7d54a69464a36d2a3afd07f2af80cb3 /src/glut/dos/init.c
parent0340663eb732d39a64b8e047cab3b2bfa19ce912 (diff)
separated DOS GLUT from GLX GLUT.
added a few FreeGLUT specific functions.
Diffstat (limited to 'src/glut/dos/init.c')
-rw-r--r--src/glut/dos/init.c380
1 files changed, 138 insertions, 242 deletions
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
index 85f5da629dc..3a98dcf0a4b 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.c
@@ -1,62 +1,87 @@
/*
- * Mesa 3-D graphics library
- * Version: 4.0
- * Copyright (C) 1995-1998 Brian Paul
+ * DOS/DJGPP Mesa Utility Toolkit
+ * Version: 1.0
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * Copyright (C) 2005 Daniel Borca All Rights Reserved.
*
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * DOS/DJGPP glut driver v1.5 for Mesa
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
*
- * Copyright (C) 2002 - Daniel Borca
- * Email : [email protected]
- * Web : http://www.geocities.com/dborca
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include "glutint.h"
+#include "internal.h"
+
-#define DEFAULT_WIDTH 300
-#define DEFAULT_HEIGHT 300
-#define DEFAULT_BPP 16
+char *__glutProgramName = NULL;
-#define ALPHA_SIZE 8
-#define DEPTH_SIZE 16
-#define STENCIL_SIZE 8
-#define ACCUM_SIZE 16
+GLUTvisual _glut_visual = {
+ 16, 8, 16, 8, 16, /* bpp, alpha, depth, stencil, accum */
+ { 0, 0 }, 0, /* geometry */
-GLuint g_bpp = DEFAULT_BPP;
-GLuint g_alpha = ALPHA_SIZE;
-GLuint g_depth = DEPTH_SIZE;
-GLuint g_stencil = STENCIL_SIZE;
-GLuint g_accum = ACCUM_SIZE;
-GLuint g_refresh = 0;
-GLuint g_screen_w, g_screen_h;
-GLint g_driver_caps;
+ 0 /* flags */
+};
-GLuint g_fps = 0;
+GLUTdefault _glut_default = {
+ 0, 0, /* glutInitWindowPosition */
+ 300, 300, /* glutInitWindowSize */
+ 0 /* glutInitDisplayMode */
+};
-GLuint g_display_mode = 0;
-int g_init_x = 0, g_init_y = 0;
-GLuint g_init_w = DEFAULT_WIDTH, g_init_h = DEFAULT_HEIGHT;
+GLuint _glut_fps = 0;
-char *__glutProgramName = NULL;
+static char *init_string;
+
+
+void
+_glut_fatal (char *format,...)
+{
+ va_list args;
+
+ va_start(args, format);
+ fprintf(stderr, "GLUT: Fatal Error in %s: ",
+ __glutProgramName ? __glutProgramName : "(unamed)");
+ vfprintf(stderr, format, args);
+ va_end(args);
+ putc('\n', stderr);
+ exit(1);
+}
+
+
+/* strdup is actually not a standard ANSI C or POSIX routine
+ * so implement a private one for GLUT.
+ */
+static char *
+_glut_strdup (const char *string)
+{
+ if (string != NULL) {
+ int len = strlen(string) + 1;
+ char *p = malloc(len);
+ if (p != NULL) {
+ return strcpy(p, string);
+ }
+ }
+ return NULL;
+}
void APIENTRY
@@ -66,22 +91,22 @@ glutInit (int *argc, char **argv)
const char *env;
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
- g_bpp = atoi(env);
+ _glut_visual.bpp = atoi(env);
}
if ((env = getenv("DMESA_GLUT_ALPHA")) != NULL) {
- g_alpha = atoi(env);
+ _glut_visual.alpha = atoi(env);
}
if ((env = getenv("DMESA_GLUT_DEPTH")) != NULL) {
- g_depth = atoi(env);
+ _glut_visual.depth = atoi(env);
}
if ((env = getenv("DMESA_GLUT_STENCIL")) != NULL) {
- g_stencil = atoi(env);
+ _glut_visual.stencil = atoi(env);
}
if ((env = getenv("DMESA_GLUT_ACCUM")) != NULL) {
- g_accum = atoi(env);
+ _glut_visual.accum = atoi(env);
}
if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
- g_refresh = atoi(env);
+ _glut_visual.refresh = atoi(env);
}
/* Determine program name. */
@@ -91,12 +116,12 @@ glutInit (int *argc, char **argv)
} else {
str++;
}
- __glutProgramName = __glutStrdup(str);
+ __glutProgramName = _glut_strdup(str);
/* check if GLUT_FPS env var is set */
if ((env = getenv("GLUT_FPS")) != NULL) {
- if ((g_fps = atoi(env)) <= 0) {
- g_fps = 5000; /* 5000 milliseconds */
+ if ((_glut_fps = atoi(env)) <= 0) {
+ _glut_fps = 5000; /* 5000 milliseconds */
}
}
@@ -108,220 +133,91 @@ glutInit (int *argc, char **argv)
void APIENTRY
glutInitDisplayMode (unsigned int mode)
{
- g_display_mode = mode;
+ _glut_default.mode = mode;
}
void APIENTRY
glutInitWindowPosition (int x, int y)
{
- g_init_x = x;
- g_init_y = y;
+ _glut_default.x = x;
+ _glut_default.y = y;
}
void APIENTRY
glutInitWindowSize (int width, int height)
{
- g_init_w = width;
- g_init_h = height;
+ _glut_default.width = width;
+ _glut_default.height = height;
}
-#define DO_REDISPLAY(w, ccin, ccout) \
- do { \
- if (w->redisplay && w->display) { \
- int rv = GL_TRUE; \
- \
- idle = GL_FALSE; \
- w->redisplay = GL_FALSE; \
- \
- /* test IN condition (whether we need to `MakeCurrent') */\
- if (ccin) { \
- rv = DMesaMakeCurrent(w->context, w->buffer); \
- } \
- \
- /* do the display only if `MakeCurrent' didn't failed */ \
- if (rv) { \
- if (w->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {\
- /* XXX scare mouse */ \
- w->display(); \
- /* XXX unscare mouse */ \
- } else { \
- w->display(); \
- } \
- \
- /* update OUT condition */ \
- ccout; \
- } \
- } \
- } while (0)
+void APIENTRY
+glutInitDisplayString (const char *string)
+{
+ init_string = _glut_strdup(string);
+}
void APIENTRY
-glutMainLoop (void)
+glutSetOption (GLenum pname, int value)
{
- int i, n;
- GLUTwindow *w;
- GLboolean idle;
- static int old_mouse_x = 0;
- static int old_mouse_y = 0;
- static int old_mouse_b = 0;
-
- {
- GLint screen_size[2];
- DMesaGetIntegerv(DMESA_GET_SCREEN_SIZE, screen_size);
- g_screen_w = screen_size[0];
- g_screen_h = screen_size[1];
- DMesaGetIntegerv(DMESA_GET_DRIVER_CAPS, &g_driver_caps);
+ switch (pname) {
+ case GLUT_INIT_WINDOW_X:
+ _glut_default.x = value;
+ break;
+ case GLUT_INIT_WINDOW_Y:
+ _glut_default.y = value;
+ break;
}
+}
- pc_install_keyb();
- __glutInitMouse();
-
- for (i = 0; i < MAX_WINDOWS; i++) {
- w = g_windows[i];
- if (w != NULL) {
- glutSetWindow(w->num);
- glutPostRedisplay();
- if (w->reshape) {
- w->reshape(w->width, w->height);
- }
- if (w->visibility) {
- w->visibility(GLUT_VISIBLE);
- }
- }
- }
- while (GL_TRUE) {
- idle = GL_TRUE;
-
- n = 0;
- for (i = 0; i < MAX_WINDOWS; i++) {
- w = g_windows[i];
- if ((w != NULL) && (w != g_curwin)) {
- /* 1) redisplay `w'
- * 2) `MakeCurrent' always
- * 3) update number of non-default windows
- */
- DO_REDISPLAY(w, GL_TRUE, n++);
- }
- }
- /* 1) redisplay `g_curwin'
- * 2) `MakeCurrent' only if we previously did non-default windows
- * 3) don't update anything
- */
- DO_REDISPLAY(g_curwin, n, n);
-
- if (g_mouse) {
- int mouse_x;
- int mouse_y;
- int mouse_z;
- int mouse_b;
-
- /* query mouse */
- mouse_b = pc_query_mouse(&mouse_x, &mouse_y, &mouse_z);
-
- /* relative to window coordinates */
- g_mouse_x = mouse_x - g_curwin->xpos;
- g_mouse_y = mouse_y - g_curwin->ypos;
-
- /* mouse was moved? */
- if ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y)) {
- idle = GL_FALSE;
- old_mouse_x = mouse_x;
- old_mouse_y = mouse_y;
-
- if (mouse_b) {
- /* any button pressed */
- if (g_curwin->motion) {
- g_curwin->motion(g_mouse_x, g_mouse_y);
- }
- } else {
- /* no button pressed */
- if (g_curwin->passive) {
- g_curwin->passive(g_mouse_x, g_mouse_y);
- }
- }
- }
-
- /* button state changed? */
- if (mouse_b != old_mouse_b) {
- GLUTmouseCB mouse_func;
-
- if ((mouse_func = g_curwin->mouse)) {
- if ((old_mouse_b & 1) && !(mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
- else if (!(old_mouse_b & 1) && (mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
-
- if ((old_mouse_b & 2) && !(mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
- else if (!(old_mouse_b & 2) && (mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
-
- if ((old_mouse_b & 4) && !(mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);
- else if (!(old_mouse_b & 3) && (mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);
- }
-
- idle = GL_FALSE;
- old_mouse_b = mouse_b;
- }
- }
+void APIENTRY
+glutForceJoystickFunc (void)
+{
+}
- if (pc_keypressed()) {
- int key;
- int glut_key;
-
- idle = GL_FALSE;
- key = pc_readkey();
-
- switch (key>>16) {
- case KEY_F1: glut_key = GLUT_KEY_F1; goto special;
- case KEY_F2: glut_key = GLUT_KEY_F2; goto special;
- case KEY_F3: glut_key = GLUT_KEY_F3; goto special;
- case KEY_F4: glut_key = GLUT_KEY_F4; goto special;
- case KEY_F5: glut_key = GLUT_KEY_F5; goto special;
- case KEY_F6: glut_key = GLUT_KEY_F6; goto special;
- case KEY_F7: glut_key = GLUT_KEY_F7; goto special;
- case KEY_F8: glut_key = GLUT_KEY_F8; goto special;
- case KEY_F9: glut_key = GLUT_KEY_F9; goto special;
- case KEY_F10: glut_key = GLUT_KEY_F10; goto special;
- case KEY_F11: glut_key = GLUT_KEY_F11; goto special;
- case KEY_F12: glut_key = GLUT_KEY_F12; goto special;
- case KEY_LEFT: glut_key = GLUT_KEY_LEFT; goto special;
- case KEY_UP: glut_key = GLUT_KEY_UP; goto special;
- case KEY_RIGHT: glut_key = GLUT_KEY_RIGHT; goto special;
- case KEY_DOWN: glut_key = GLUT_KEY_DOWN; goto special;
- case KEY_PGUP: glut_key = GLUT_KEY_PAGE_UP; goto special;
- case KEY_PGDN: glut_key = GLUT_KEY_PAGE_DOWN; goto special;
- case KEY_HOME: glut_key = GLUT_KEY_HOME; goto special;
- case KEY_END: glut_key = GLUT_KEY_END; goto special;
- case KEY_INSERT: glut_key = GLUT_KEY_INSERT; goto special;
- special:
- if (g_curwin->special) {
- g_curwin->special(glut_key, g_mouse_x, g_mouse_y);
- }
- break;
- default:
- if (g_curwin->keyboard) {
- g_curwin->keyboard(key & 0xFF, g_mouse_x, g_mouse_y);
- }
- }
- }
- if (idle && g_idle_func)
- g_idle_func();
+void APIENTRY
+glutIgnoreKeyRepeat (int ignore)
+{
+}
- for (i = 0; i < MAX_SSHOT_CB; i++) {
- int time = glutGet(GLUT_ELAPSED_TIME);
- GLUTSShotCB *cb = &g_sscb[i];
- if (cb->func && (time >= cb->time)) {
- cb->func(cb->value);
- cb->func = NULL;
- }
- }
- }
+
+void APIENTRY
+glutSetKeyRepeat (int repeatMode)
+{
+}
+
+
+void APIENTRY
+glutVideoPan (int x, int y, int w, int h)
+{
+}
+
+
+int APIENTRY
+glutVideoResizeGet( GLenum eWhat )
+{
+ return 0;
+}
+
+
+void APIENTRY
+glutSetupVideoResizing (void)
+{
+}
+
+
+void APIENTRY
+glutStopVideoResizing (void)
+{
+}
+
+
+void APIENTRY
+glutVideoResize (int x, int y, int w, int h)
+{
}