summaryrefslogtreecommitdiff
path: root/src/glut
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-02-04 02:43:27 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-02-04 02:43:27 +0000
commit398c6b7980ac52ba15af78f45e71f49f33ded1aa (patch)
tree3e93472cfbe4de6c5478bf5c8bdc39f3f685e7d7 /src/glut
parent657a9d64d74d987af0d6c9c847af98cc65d9d76e (diff)
DOS updates (Daniel Borca)
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/dos/Makefile.DJ23
-rw-r--r--src/glut/dos/PC_HW/pc_hw.c15
-rw-r--r--src/glut/dos/PC_HW/pc_hw.h7
-rw-r--r--src/glut/dos/PC_HW/pc_keyb.c7
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c17
-rw-r--r--src/glut/dos/PC_HW/pc_timer.c4
-rw-r--r--src/glut/dos/callback.c92
-rw-r--r--src/glut/dos/color.c7
-rw-r--r--src/glut/dos/extens.c63
-rw-r--r--src/glut/dos/glutint.h147
-rw-r--r--src/glut/dos/init.c223
-rw-r--r--src/glut/dos/menu.c36
-rw-r--r--src/glut/dos/mouse.c58
-rw-r--r--src/glut/dos/overlay.c35
-rw-r--r--src/glut/dos/state.c84
-rw-r--r--src/glut/dos/window.c107
16 files changed, 722 insertions, 203 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index fed1f42e8c..2fb1bee27d 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -54,10 +54,10 @@ GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
CC = gcc
-CFLAGS += -I$(TOP)/include -I$(MKGLUT)
+CFLAGS += -I- -I$(TOP)/include -I. -I$(MKGLUT) -IPC_HW
AR = ar
-ARFLAGS = ru
+ARFLAGS = rus
ifneq ($(wildcard $(DJDIR)/lib/dxe3.ld),)
DXE3GEN = $(wildcard $(addsuffix /dxe3gen.exe,$(subst ;, ,$(PATH))))
@@ -66,16 +66,14 @@ endif
RM = del
CORE_SOURCES = \
- bitmap.c \
callback.c \
color.c \
- globals.c \
+ extens.c \
init.c \
menu.c \
- models.c \
+ mouse.c \
overlay.c \
state.c \
- teapot.c \
window.c
PC_HW_SOURCES = \
@@ -86,13 +84,22 @@ PC_HW_SOURCES = \
PC_HW/pc_irq.S
MKGLUT_SOURCES = \
+ $(MKGLUT)/glut_bitmap.c \
+ $(MKGLUT)/glut_bwidth.c \
+ $(MKGLUT)/glut_stroke.c \
+ $(MKGLUT)/glut_swidth.c \
+ $(MKGLUT)/glut_shapes.c \
+ $(MKGLUT)/glut_teapot.c \
$(MKGLUT)/glut_8x13.c \
$(MKGLUT)/glut_9x15.c \
$(MKGLUT)/glut_hel10.c \
$(MKGLUT)/glut_hel12.c \
$(MKGLUT)/glut_hel18.c \
$(MKGLUT)/glut_tr10.c \
- $(MKGLUT)/glut_tr24.c
+ $(MKGLUT)/glut_tr24.c \
+ $(MKGLUT)/glut_roman.c \
+ $(MKGLUT)/glut_mroman.c \
+ $(MKGLUT)/glut_util.c
SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MKGLUT_SOURCES)
@@ -115,7 +122,7 @@ ifeq ($(DXE3GEN),)
$(warning Missing DXE3GEN and/or DXE3.LD! You must have DXE3GEN)
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)
else
- -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E glut -X -P gl.dxe -P glu.dxe -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $(OBJECTS)
endif
clean:
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c
index 867daf89b0..f08286d4c4 100644
--- a/src/glut/dos/PC_HW/pc_hw.c
+++ b/src/glut/dos/PC_HW/pc_hw.c
@@ -73,9 +73,6 @@ void *pc_malloc (size_t size)
/*
* standard redirection
*/
-#define STDOUT 1
-#define STDERR 2
-
static char outname[L_tmpnam];
static int h_out, h_outbak;
static char errname[L_tmpnam];
@@ -86,9 +83,9 @@ int pc_open_stdout (void)
tmpnam(outname);
if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
- h_outbak = dup(STDOUT);
+ h_outbak = dup(STDOUT_FILENO);
fflush(stdout);
- dup2(h_out, STDOUT);
+ dup2(h_out, STDOUT_FILENO);
}
return h_out;
@@ -100,7 +97,7 @@ void pc_close_stdout (void)
char *line = alloca(512);
if (h_out > 0) {
- dup2(h_outbak, STDOUT);
+ dup2(h_outbak, STDOUT_FILENO);
close(h_out);
close(h_outbak);
@@ -119,9 +116,9 @@ int pc_open_stderr (void)
tmpnam(errname);
if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
- h_errbak = dup(STDERR);
+ h_errbak = dup(STDERR_FILENO);
fflush(stderr);
- dup2(h_err, STDERR);
+ dup2(h_err, STDERR_FILENO);
}
return h_err;
@@ -133,7 +130,7 @@ void pc_close_stderr (void)
char *line = alloca(512);
if (h_err > 0) {
- dup2(h_errbak, STDERR);
+ dup2(h_errbak, STDERR_FILENO);
close(h_err);
close(h_errbak);
diff --git a/src/glut/dos/PC_HW/pc_hw.h b/src/glut/dos/PC_HW/pc_hw.h
index 77572e6441..c38c8959b6 100644
--- a/src/glut/dos/PC_HW/pc_hw.h
+++ b/src/glut/dos/PC_HW/pc_hw.h
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.2 for DOS/DJGPP
+ * PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -39,6 +39,7 @@ int pc_clexit (VFUNC f);
#define ENDOFUNC(x) static void x##_end() { }
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))
+#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)
void *pc_malloc (size_t size);
@@ -194,6 +195,7 @@ void pc_remove_keyb (void);
int pc_keypressed (void);
int pc_readkey (void);
int pc_keydown (int code);
+int pc_keyshifts (void);
/*
* timer
@@ -210,9 +212,6 @@ MFUNC pc_install_mouse_handler (MFUNC handler);
void pc_mouse_area (int x1, int y1, int x2, int y2);
void pc_mouse_speed (int xspeed, int yspeed);
int pc_query_mouse (int *x, int *y);
-void pc_show_mouse (void);
-void pc_scare_mouse (void);
-void pc_unscare_mouse (void);
/*
* standard redirection
diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c
index fb22923d63..333ca757f5 100644
--- a/src/glut/dos/PC_HW/pc_keyb.c
+++ b/src/glut/dos/PC_HW/pc_keyb.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.1 for DOS/DJGPP
+ * PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -445,6 +445,11 @@ int pc_keydown (int code)
return pc_key[code];
}
+int pc_keyshifts (void)
+{
+ return key_shifts;
+}
+
void pc_remove_keyb (void)
{
if (keyboard_installed) {
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
index 01e9502dd0..3ed7650906 100644
--- a/src/glut/dos/PC_HW/pc_mouse.c
+++ b/src/glut/dos/PC_HW/pc_mouse.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.2 for DOS/DJGPP
+ * PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -212,22 +212,9 @@ int pc_query_mouse (int *x, int *y)
return pc_mouse_b;
}
-void pc_show_mouse (void)
-{
- /* not implemented */
-}
-void pc_scare_mouse (void)
-{
- /* not implemented */
-}
-void pc_unscare_mouse (void)
-{
- /* not implemented */
-}
-
__asm("\n\
.text \n\
- .balign 4 \n\
+ .p2align 5,,31 \n\
.global _mouse_wrapper \n\
_mouse_wrapper: \n\
cld \n\
diff --git a/src/glut/dos/PC_HW/pc_timer.c b/src/glut/dos/PC_HW/pc_timer.c
index ec348e278b..36c02910a3 100644
--- a/src/glut/dos/PC_HW/pc_timer.c
+++ b/src/glut/dos/PC_HW/pc_timer.c
@@ -1,5 +1,5 @@
/*
- * PC/HW routine collection v1.0 for DOS/DJGPP
+ * PC/HW routine collection v1.3 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -27,7 +27,7 @@ typedef struct {
volatile void *parm;
} TIMER;
-TIMER timer_main, timer_func[MAX_TIMERS];
+static TIMER timer_main, timer_func[MAX_TIMERS];
static int timer ()
{
diff --git a/src/glut/dos/callback.c b/src/glut/dos/callback.c
index a9260cbe7c..6e3f5a77c7 100644
--- a/src/glut/dos/callback.c
+++ b/src/glut/dos/callback.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -27,126 +27,138 @@
*/
-#include "GL/glut.h"
-#include "internal.h"
+#include "glutint.h"
-void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))
-{
- display_func = func;
-}
+GLUTidleCB g_idle_func = NULL;
-void APIENTRY glutReshapeFunc (void (GLUTCALLBACK *func) (int width, int height))
-{
- reshape_func = func;
-}
-void APIENTRY glutKeyboardFunc (void (GLUTCALLBACK *func) (unsigned char key, int x, int y))
+void APIENTRY glutDisplayFunc (GLUTdisplayCB func)
{
- keyboard_func = func;
+ g_curwin->display = func;
}
-void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
+
+void APIENTRY glutReshapeFunc (GLUTreshapeCB func)
{
- mouse_func = func;
+ g_curwin->reshape = func;
}
-void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+
+void APIENTRY glutKeyboardFunc (GLUTkeyboardCB func)
{
- motion_func = func;
+ g_curwin->keyboard = func;
}
-void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+
+void APIENTRY glutMouseFunc (GLUTmouseCB func)
{
- passive_motion_func = func;
+ g_curwin->mouse = func;
}
-void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))
+
+void APIENTRY glutMotionFunc (GLUTmotionCB func)
{
- entry_func = func;
+ g_curwin->motion = func;
}
-void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))
+
+void APIENTRY glutPassiveMotionFunc (GLUTpassiveCB func)
{
- visibility_func = func;
+ g_curwin->passive = func;
}
-void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))
+
+void APIENTRY glutEntryFunc (GLUTentryCB func)
{
- idle_func = func;
+ g_curwin->entry = func;
}
-void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)
+
+void APIENTRY glutVisibilityFunc (GLUTvisibilityCB func)
{
+ g_curwin->visibility = func;
}
-void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))
+
+void APIENTRY glutWindowStatusFunc (GLUTwindowStatusCB func)
{
- menu_state_func = func;
}
-void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))
+
+void APIENTRY glutIdleFunc (GLUTidleCB func)
{
- special_func = func;
+ g_idle_func = func;
}
-void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
+
+void APIENTRY glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)
{
}
-void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
+
+void APIENTRY glutSpecialFunc (GLUTspecialCB func)
{
+ g_curwin->special = func;
}
-void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))
+
+void APIENTRY glutSpaceballMotionFunc (GLUTspaceMotionCB func)
{
}
-void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))
+
+void APIENTRY glutSpaceballRotateFunc (GLUTspaceRotateCB func)
{
}
-void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))
+
+void APIENTRY glutSpaceballButtonFunc (GLUTspaceButtonCB func)
{
}
-void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+
+void APIENTRY glutDialsFunc (GLUTdialsCB func)
{
}
-void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
+
+void APIENTRY glutButtonBoxFunc (GLUTbuttonBoxCB func)
{
}
-void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))
+
+void APIENTRY glutTabletMotionFunc (GLUTtabletMotionCB func)
{
}
-void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))
+
+void APIENTRY glutTabletButtonFunc (GLUTtabletButtonCB func)
{
}
-void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))
+
+void APIENTRY glutJoystickFunc (GLUTjoystickCB func, int interval)
{
}
diff --git a/src/glut/dos/color.c b/src/glut/dos/color.c
index f1f529521d..2e8ed3f95b 100644
--- a/src/glut/dos/color.c
+++ b/src/glut/dos/color.c
@@ -27,9 +27,8 @@
*/
-#include "GL/glut.h"
+#include "glutint.h"
#include "GL/dmesa.h"
-#include "internal.h"
@@ -40,7 +39,9 @@
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
if (g_display_mode & GLUT_INDEX) {
- DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));
+ if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) {
+ DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));
+ }
}
}
diff --git a/src/glut/dos/extens.c b/src/glut/dos/extens.c
new file mode 100644
index 0000000000..ae8e44f408
--- /dev/null
+++ b/src/glut/dos/extens.c
@@ -0,0 +1,63 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.4
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.3 for Mesa 5.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <string.h>
+
+#include "GL/glut.h"
+
+
+
+int APIENTRY glutExtensionSupported (const char *extension)
+{
+ static const GLubyte *extensions = NULL;
+ const GLubyte *last, *where;
+
+ /* Extension names should not have spaces. */
+ if (strchr(extension, ' ') || *extension == '\0') {
+ return GL_FALSE;
+ }
+
+ /* Not my problem if you don't have a valid OpenGL context */
+ if (!extensions) {
+ extensions = glGetString(GL_EXTENSIONS);
+ }
+
+ /* Take care of sub-strings etc. */
+ for (last = extensions;;) {
+ if ((where = (GLubyte *)strstr((const char *)last, extension)) == NULL) {
+ return GL_FALSE;
+ }
+ last = where + strlen(extension);
+ if (where == extensions || *(where - 1) == ' ') {
+ if (*last == ' ' || *last == '\0') {
+ return GL_TRUE;
+ }
+ }
+ }
+}
diff --git a/src/glut/dos/glutint.h b/src/glut/dos/glutint.h
new file mode 100644
index 0000000000..77a8322c44
--- /dev/null
+++ b/src/glut/dos/glutint.h
@@ -0,0 +1,147 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.3 for Mesa 5.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef __glutint_h__
+#define __glutint_h__
+
+#include <GL/glut.h>
+
+#include "GL/dmesa.h"
+
+
+
+/* GLUT function types */
+typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
+typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
+typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
+typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTentryCB) (int);
+typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
+typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
+typedef void (GLUTCALLBACK *GLUTidleCB) (void);
+typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
+typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int); /* DEPRECATED. */
+typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
+typedef void (GLUTCALLBACK *GLUTselectCB) (int);
+typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
+typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
+typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
+typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
+typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
+typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);
+
+typedef struct GLUTwindow {
+ int num; /* window id */
+
+ DMesaBuffer buffer;
+
+ int show_mouse;
+
+ /* GLUT settable or visible window state. */
+ int xpos;
+ int ypos;
+ int width; /* window width in pixels */
+ int height; /* window height in pixels */
+
+ /* 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 */
+ GLUTjoystickCB joystick; /* joystick */
+} GLUTwindow;
+
+extern GLUTidleCB g_idle_func;
+extern GLUTmenuStatusCB g_menu_status_func;
+
+extern GLboolean g_redisplay;
+
+extern GLuint g_bpp; /* HW: bits per pixel */
+extern GLuint g_refresh; /* HW: vertical refresh rate */
+extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */
+
+extern GLuint g_display_mode; /* display bits */
+extern int g_init_x, g_init_y; /* initial window position */
+extern GLuint g_init_w, g_init_h; /* initial window size */
+
+extern int g_mouse; /* non-zero if mouse installed */
+extern int g_mouse_x, g_mouse_y; /* mouse coords, relative to current win */
+
+extern GLUTwindow *g_curwin; /* current window */
+
+extern char *__glutProgramName; /* program name */
+
+extern void __glutInitMouse (void);
+
+/* 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,...);
+
+
+
+/* hmmm... */
+#include "pc_hw/pc_hw.h"
+
+
+
+#define MAX_WINDOWS 2
+
+#define DEFAULT_WIDTH 300
+#define DEFAULT_HEIGHT 300
+#define DEFAULT_BPP 16
+
+#define DEPTH_SIZE 16
+#define STENCIL_SIZE 8
+#define ACCUM_SIZE 16
+
+#define RESERVED_COLORS 0
+
+#endif /* __glutint_h__ */
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
index 4ee939b487..0f848f6f36 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.c
@@ -27,12 +27,29 @@
*/
-#include "GL/glut.h"
-#include "internal.h"
+#include <string.h>
+#include "glutint.h"
-void APIENTRY glutInit (int *argcp, char **argv)
+
+
+GLboolean g_redisplay = GL_FALSE;
+
+GLuint g_bpp = DEFAULT_BPP;
+GLuint g_refresh = 0;
+GLuint g_screen_w, g_screen_h;
+
+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;
+
+char *__glutProgramName = NULL;
+
+
+
+void APIENTRY glutInit (int *argc, char **argv)
{
+ char *str;
const char *env;
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
@@ -42,33 +59,44 @@ void APIENTRY glutInit (int *argcp, char **argv)
g_refresh = atoi(env);
}
+ /* Determine program name. */
+ str = strrchr(argv[0], '/');
+ if (str == NULL) {
+ str = argv[0];
+ } else {
+ str++;
+ }
+ __glutProgramName = __glutStrdup(str);
+
+ /* Initialize timer */
glutGet(GLUT_ELAPSED_TIME);
}
+
void APIENTRY glutInitDisplayMode (unsigned int mode)
{
g_display_mode = mode;
-
- pc_install_keyb();
- g_mouse = pc_install_mouse();
}
+
void APIENTRY glutInitWindowPosition (int x, int y)
{
- g_xpos = x;
- g_ypos = y;
+ g_init_x = x;
+ g_init_y = y;
}
+
void APIENTRY glutInitWindowSize (int width, int height)
{
- g_width = width;
- g_height = height;
+ g_init_w = width;
+ g_init_h = height;
}
+
void APIENTRY glutMainLoop (void)
{
GLboolean idle;
@@ -76,52 +104,37 @@ void APIENTRY glutMainLoop (void)
static int old_mouse_y = 0;
static int old_mouse_b = 0;
+ {
+ GLint screen_size[2];
+ DMesaGetIntegerv(DMESA_SCREEN_SIZE, screen_size);
+ g_screen_w = screen_size[0];
+ g_screen_h = screen_size[1];
+ }
+
+ pc_install_keyb();
+ __glutInitMouse();
+
glutPostRedisplay();
- if (reshape_func) reshape_func(g_width, g_height);
- if (visibility_func) visibility_func(GLUT_VISIBLE);
- if (g_mouse) pc_show_mouse();
+ if (g_curwin->reshape) {
+ g_curwin->reshape(g_curwin->width, g_curwin->height);
+ }
+ if (g_curwin->visibility) {
+ g_curwin->visibility(GLUT_VISIBLE);
+ }
while (GL_TRUE) {
idle = GL_TRUE;
- if (g_redisplay && display_func) {
+ if (g_redisplay && g_curwin->display) {
idle = GL_FALSE;
g_redisplay = GL_FALSE;
- if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse();
- display_func();
- if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse();
- }
-
- if (pc_keypressed()) {
- int key;
-
- idle = GL_FALSE;
- key = pc_readkey();
-
- switch (key>>16) {
- case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break;
- case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break;
- case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break;
- case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break;
- case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break;
- case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break;
- case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break;
- case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break;
- case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break;
- case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break;
- case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break;
- case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break;
- case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break;
- case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break;
- case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break;
- case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break;
- case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break;
- case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break;
- case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break;
- case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break;
- case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break;
- default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0);
+ if (g_curwin->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {
+ /* XXX scare mouse */
+ g_curwin->display();
+ /* XXX unscare mouse */
+ } else {
+ g_curwin->display();
}
}
@@ -129,41 +142,101 @@ void APIENTRY glutMainLoop (void)
int mouse_x;
int mouse_y;
int mouse_b;
-
+
+ /* query mouse */
mouse_b = pc_query_mouse(&mouse_x, &mouse_y);
-
- if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) {
+
+ /* 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;
-
- motion_func(old_mouse_x, old_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);
+ }
+ }
}
-
- if (mouse_func && (mouse_b != old_mouse_b)) {
- int new_mouse_b = mouse_b;
-
- if ((old_mouse_b & 1) && !(new_mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y);
- else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
- mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
-
- if ((old_mouse_b & 2) && !(new_mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y);
- else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
-
- if ((old_mouse_b & 4) && !(new_mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y);
- else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, 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 = new_mouse_b;
+ old_mouse_b = mouse_b;
+ }
+ }
+
+ 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 && idle_func)
- idle_func();
+ if (idle && g_idle_func)
+ g_idle_func();
}
}
diff --git a/src/glut/dos/menu.c b/src/glut/dos/menu.c
index eccc51d2ea..9a3841b12b 100644
--- a/src/glut/dos/menu.c
+++ b/src/glut/dos/menu.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -27,60 +27,90 @@
*/
-#include "GL/glut.h"
+#include "glutint.h"
-int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))
+
+GLUTmenuStatusCB g_menu_status_func = NULL;
+
+
+
+void APIENTRY glutMenuStateFunc (GLUTmenuStateCB func)
+{
+ g_menu_status_func = (GLUTmenuStatusCB)func;
+}
+
+
+
+void APIENTRY glutMenuStatusFunc (GLUTmenuStatusCB func)
+{
+ g_menu_status_func = func;
+}
+
+
+
+int APIENTRY glutCreateMenu (GLUTselectCB func)
{
return 0;
}
+
+
void APIENTRY glutDestroyMenu (int menu)
{
}
+
int APIENTRY glutGetMenu (void)
{
return 0;
}
+
void APIENTRY glutSetMenu (int menu)
{
}
+
void APIENTRY glutAddMenuEntry (const char *label, int value)
{
}
+
void APIENTRY glutAddSubMenu (const char *label, int submenu)
{
}
+
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)
{
}
+
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)
{
}
+
void APIENTRY glutRemoveMenuItem (int item)
{
}
+
void APIENTRY glutAttachMenu (int button)
{
}
+
void APIENTRY glutDetachMenu (int button)
{
}
diff --git a/src/glut/dos/mouse.c b/src/glut/dos/mouse.c
new file mode 100644
index 0000000000..c67f8093b1
--- /dev/null
+++ b/src/glut/dos/mouse.c
@@ -0,0 +1,58 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.4
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.3 for Mesa 5.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "glutint.h"
+
+
+
+int g_mouse;
+int g_mouse_x = 0, g_mouse_y = 0;
+
+
+
+void __glutInitMouse (void)
+{
+ if ((g_mouse = pc_install_mouse())) {
+ GLint yorg;
+ GLint rect[4];
+
+ DMesaGetIntegerv(DMESA_Y_ORIGIN, &yorg);
+ if (yorg) {
+ rect[1] = g_screen_h - g_curwin->height;
+ } else {
+ rect[1] = g_curwin->ypos;
+ }
+ rect[0] = g_curwin->xpos;
+ rect[2] = rect[0] + g_curwin->width - 1;
+ rect[3] = rect[1] + g_curwin->height - 1;
+ pc_mouse_area(rect[0], rect[1], rect[2], rect[3]);
+
+ g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive);
+ }
+}
diff --git a/src/glut/dos/overlay.c b/src/glut/dos/overlay.c
index ab4f561849..f1f72cf1f8 100644
--- a/src/glut/dos/overlay.c
+++ b/src/glut/dos/overlay.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -27,7 +27,33 @@
*/
-#include "GL/glut.h"
+#include "glutint.h"
+
+
+
+int APIENTRY glutLayerGet (GLenum info)
+{
+ switch (info) {
+ case GLUT_OVERLAY_POSSIBLE:
+ case GLUT_HAS_OVERLAY:
+ return GL_FALSE;
+ case GLUT_LAYER_IN_USE:
+ return GLUT_NORMAL;
+ case GLUT_NORMAL_DAMAGED:
+ return GL_FALSE;
+ case GLUT_OVERLAY_DAMAGED:
+ case GLUT_TRANSPARENT_INDEX:
+ default:
+ return -1;
+ }
+}
+
+
+
+void APIENTRY glutOverlayDisplayFunc (GLUTdisplayCB func)
+{
+}
+
void APIENTRY glutEstablishOverlay (void)
@@ -35,26 +61,31 @@ void APIENTRY glutEstablishOverlay (void)
}
+
void APIENTRY glutRemoveOverlay (void)
{
}
+
void APIENTRY glutUseLayer (GLenum layer)
{
}
+
void APIENTRY glutPostOverlayRedisplay (void)
{
}
+
void APIENTRY glutShowOverlay (void)
{
}
+
void APIENTRY glutHideOverlay (void)
{
}
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c
index b26307d9cb..e9735a06a2 100644
--- a/src/glut/dos/state.c
+++ b/src/glut/dos/state.c
@@ -27,16 +27,19 @@
*/
-#include "GL/glut.h"
-#include "internal.h"
+#include "glutint.h"
+
#define FREQUENCY 100
+
static int timer_installed;
static volatile int ticks;
+
+
static void ticks_timer (void *p)
{
(void)p;
@@ -48,25 +51,92 @@ static void ticks_timer (void *p)
int APIENTRY glutGet (GLenum type)
{
switch (type) {
- case GLUT_WINDOW_COLORMAP_SIZE:
- return (g_display_mode & GLUT_INDEX) ? 256 : 0;
+ case GLUT_WINDOW_X:
+ return g_curwin->xpos;
+ case GLUT_WINDOW_Y:
+ return g_curwin->ypos;
+ case GLUT_WINDOW_WIDTH:
+ return g_curwin->width;
+ case GLUT_WINDOW_HEIGHT:
+ return g_curwin->height;
+ case GLUT_WINDOW_STENCIL_SIZE:
+ return STENCIL_SIZE;
+ case GLUT_WINDOW_DEPTH_SIZE:
+ return DEPTH_SIZE;
case GLUT_WINDOW_RGBA:
return !(g_display_mode & GLUT_INDEX);
+ case GLUT_WINDOW_COLORMAP_SIZE:
+ return (g_display_mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0;
+ case GLUT_SCREEN_WIDTH:
+ return g_screen_w;
+ case GLUT_SCREEN_HEIGHT:
+ return g_screen_h;
+ case GLUT_INIT_WINDOW_X:
+ return g_init_x;
+ case GLUT_INIT_WINDOW_Y:
+ return g_init_y;
+ case GLUT_INIT_WINDOW_WIDTH:
+ return g_init_w;
+ case GLUT_INIT_WINDOW_HEIGHT:
+ return g_init_h;
+ case GLUT_INIT_DISPLAY_MODE:
+ return g_display_mode;
case GLUT_ELAPSED_TIME:
if (!timer_installed) {
- timer_installed = !timer_installed;
+ timer_installed = GL_TRUE;
LOCKDATA(ticks);
LOCKFUNC(ticks_timer);
pc_install_int(ticks_timer, NULL, FREQUENCY);
}
return ticks*1000/FREQUENCY;
default:
- return 0;
+ return -1;
}
}
+
int APIENTRY glutDeviceGet (GLenum type)
{
- return 0;
+ switch (type) {
+ case GLUT_HAS_KEYBOARD:
+ return GL_TRUE;
+ case GLUT_HAS_MOUSE:
+ return (g_mouse != 0);
+ case GLUT_NUM_MOUSE_BUTTONS:
+ return g_mouse;
+ case GLUT_HAS_SPACEBALL:
+ case GLUT_HAS_DIAL_AND_BUTTON_BOX:
+ case GLUT_HAS_TABLET:
+ return GL_FALSE;
+ case GLUT_NUM_SPACEBALL_BUTTONS:
+ case GLUT_NUM_BUTTON_BOX_BUTTONS:
+ case GLUT_NUM_DIALS:
+ case GLUT_NUM_TABLET_BUTTONS:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+
+
+int APIENTRY glutGetModifiers (void)
+{
+ int mod = 0;
+ int shifts = pc_keyshifts();
+
+ if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {
+ mod |= GLUT_ACTIVE_SHIFT;
+ }
+
+ if (shifts & KB_ALT_FLAG) {
+ mod |= GLUT_ACTIVE_ALT;
+ }
+
+ if (shifts & KB_CTRL_FLAG) {
+ mod |= GLUT_ACTIVE_CTRL;
+ }
+
+ return mod;
}
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index cce1a1f777..a7a7d9ca59 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -27,17 +27,16 @@
*/
-#include "GL/glut.h"
+#include "glutint.h"
#include "GL/dmesa.h"
-#include "internal.h"
-static int window;
+GLUTwindow *g_curwin;
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
-static DMesaBuffer buffer[MAX_WINDOWS];
+static GLUTwindow *windows[MAX_WINDOWS];
@@ -45,8 +44,8 @@ static void clean (void)
{
int i;
- for (i=0; i<MAX_WINDOWS; i++) {
- glutDestroyWindow(i+1);
+ for (i=1; i<=MAX_WINDOWS; i++) {
+ glutDestroyWindow(i);
}
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
@@ -60,9 +59,11 @@ static void clean (void)
int APIENTRY glutCreateWindow (const char *title)
{
int i;
+ GLint screen_size[2];
+ int m8width = (g_init_w + 7) & ~7;
if (!visual) {
- if ((visual=DMesaCreateVisual(g_xpos + g_width, g_ypos + g_height, g_bpp, g_refresh,
+ if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh,
g_display_mode & GLUT_DOUBLE,
!(g_display_mode & GLUT_INDEX),
g_display_mode & GLUT_ALPHA,
@@ -71,34 +72,46 @@ int APIENTRY glutCreateWindow (const char *title)
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
return 0;
}
-
+
if ((context=DMesaCreateContext(visual, NULL))==NULL) {
DMesaDestroyVisual(visual);
return 0;
}
-
+
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
for (i=0; i<MAX_WINDOWS; i++) {
- if (!buffer[i]) {
+ if (windows[i] == NULL) {
DMesaBuffer b;
-
- if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {
+ GLUTwindow *w;
+
+ if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
+ return 0;
+ }
+
+ if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {
+ free(w);
return 0;
}
if (!DMesaMakeCurrent(context, b)) {
DMesaDestroyBuffer(b);
+ free(w);
return 0;
}
- if (g_mouse) {
- pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);
- }
- buffer[window = i] = b;
- return i+1;
+ g_curwin = windows[i] = w;
+
+ w->num = ++i;
+ w->xpos = g_init_x;
+ w->ypos = g_init_y;
+ w->width = m8width;
+ w->height = g_init_h;
+ w->buffer = b;
+
+ return i;
}
}
@@ -106,73 +119,88 @@ int APIENTRY glutCreateWindow (const char *title)
}
+
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
+
void APIENTRY glutDestroyWindow (int win)
{
- if (buffer[win-1]) {
- DMesaDestroyBuffer(buffer[win-1]);
- buffer[win-1] = NULL;
+ if (windows[--win]) {
+ DMesaDestroyBuffer(windows[win]->buffer);
+ free(windows[win]);
+ windows[win] = NULL;
}
}
+
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
+
void APIENTRY glutSwapBuffers (void)
{
- if (g_mouse) pc_scare_mouse();
- DMesaSwapBuffers(buffer[window]);
- if (g_mouse) pc_unscare_mouse();
+ if (g_curwin->show_mouse) {
+ /* XXX scare mouse */
+ DMesaSwapBuffers(g_curwin->buffer);
+ /* XXX unscare mouse */
+ } else {
+ DMesaSwapBuffers(g_curwin->buffer);
+ }
}
+
int APIENTRY glutGetWindow (void)
{
- return window + 1;
+ return g_curwin->num;
}
+
void APIENTRY glutSetWindow (int win)
{
- window = win - 1;
+ g_curwin = windows[win - 1];
}
+
void APIENTRY glutSetWindowTitle (const char *title)
{
}
+
void APIENTRY glutSetIconTitle (const char *title)
{
}
+
void APIENTRY glutPositionWindow (int x, int y)
{
- if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {
- g_xpos = x;
- g_ypos = y;
+ if (DMesaMoveBuffer(x, y)) {
+ g_curwin->xpos = x;
+ g_curwin->ypos = y;
}
}
+
void APIENTRY glutReshapeWindow (int width, int height)
-{
- if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {
- g_width = width;
- g_height = height;
- if (reshape_func) {
- reshape_func(width, height);
+{
+ if (DMesaResizeBuffer(width, height)) {
+ g_curwin->width = width;
+ g_curwin->height = height;
+ if (g_curwin->reshape) {
+ g_curwin->reshape(width, height);
} else {
glViewport(0, 0, width, height);
}
@@ -180,26 +208,37 @@ void APIENTRY glutReshapeWindow (int width, int height)
}
+
+void APIENTRY glutFullScreen (void)
+{
+}
+
+
+
void APIENTRY glutPopWindow (void)
{
}
+
void APIENTRY glutPushWindow (void)
{
}
+
void APIENTRY glutIconifyWindow (void)
{
}
+
void APIENTRY glutShowWindow (void)
{
}
+
void APIENTRY glutHideWindow (void)
{
}