summaryrefslogtreecommitdiff
path: root/src/glut/dos
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-08-19 15:52:51 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-08-19 15:52:51 +0000
commit9ec58c2c5bbf90428a0e8e1c4f4af3805c602cd3 (patch)
tree0519440b1cfa2b839ee1995b3e09d62dc05dd9d1 /src/glut/dos
parent3dc8cc4ebc63624dd521923271e63c2ac5a8aaae (diff)
DOS and glide driver updates from Daniel Borca
Diffstat (limited to 'src/glut/dos')
-rw-r--r--src/glut/dos/Makefile.DJ10
-rw-r--r--src/glut/dos/glutint.h24
-rw-r--r--src/glut/dos/init.c73
-rw-r--r--src/glut/dos/state.c6
-rw-r--r--src/glut/dos/window.c69
5 files changed, 119 insertions, 63 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index c870d23d44..4586a0ba69 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -23,7 +23,7 @@
# DOS/DJGPP glut makefile v1.4 for Mesa
#
# Copyright (C) 2002 - Borca Daniel
-# Email : dborca@yahoo.com
+# Email : dborca@users.sourceforge.net
# Web : http://www.geocities.com/dborca
@@ -53,10 +53,11 @@ GLUT_LIB = libglut.a
GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
-export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR)
+export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR);$(GLIDE)/lib
CC = gcc
CFLAGS += -I- -I$(TOP)/include -I. -I$(MKGLUT) -IPC_HW
+CFLAGS += -DGLUT_IMPORT_LIB
AR = ar
ARFLAGS = rus
@@ -78,6 +79,7 @@ CORE_SOURCES = \
mouse.c \
overlay.c \
state.c \
+ util.c \
window.c
PC_HW_SOURCES = \
@@ -119,13 +121,13 @@ OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
- $(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
+ $(AR) $(ARFLAGS) $@ $^
$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
ifeq ($(HAVEDXE3),)
$(warning Missing DXE3 package... Skipping $(GLUT_DXE))
else
- -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -Y $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -Y $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $^
endif
clean:
diff --git a/src/glut/dos/glutint.h b/src/glut/dos/glutint.h
index e8dffb581b..013b307e94 100644
--- a/src/glut/dos/glutint.h
+++ b/src/glut/dos/glutint.h
@@ -19,10 +19,10 @@
*/
/*
- * DOS/DJGPP glut driver v1.3 for Mesa
+ * DOS/DJGPP glut driver v1.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
- * Email : dborca@yahoo.com
+ * Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@@ -64,9 +64,11 @@ typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);
typedef struct GLUTwindow {
int num; /* window id */
+ DMesaContext context;
DMesaBuffer buffer;
int show_mouse;
+ GLboolean redisplay;
/* GLUT settable or visible window state. */
int xpos;
@@ -100,9 +102,10 @@ typedef struct 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_depth; /* HW: depth bits */
+extern GLuint g_stencil; /* HW: stencil bits */
+extern GLuint g_accum; /* HW: accum bits */
extern GLuint g_refresh; /* HW: vertical refresh rate */
extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */
extern GLint g_driver_caps;
@@ -117,6 +120,7 @@ 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 GLUTwindow *g_windows[];
extern char *__glutProgramName; /* program name */
@@ -127,6 +131,10 @@ extern char * __glutStrdup(const char *string);
extern void __glutWarning(char *format,...);
extern void __glutFatalError(char *format,...);
extern void __glutFatalUsage(char *format,...);
+/* Private routines from util.c */
+#ifdef GLUT_IMPORT_LIB
+extern void *__glutFont(void *font);
+#endif
@@ -137,14 +145,6 @@ extern void __glutFatalUsage(char *format,...);
#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 5d09561dac..22bab9f8af 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.c
@@ -19,10 +19,10 @@
*/
/*
- * DOS/DJGPP glut driver v1.3 for Mesa
+ * DOS/DJGPP glut driver v1.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
- * Email : dborca@yahoo.com
+ * Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@@ -31,11 +31,20 @@
#include "glutint.h"
+#define DEFAULT_WIDTH 300
+#define DEFAULT_HEIGHT 300
+#define DEFAULT_BPP 16
+
+#define DEPTH_SIZE 16
+#define STENCIL_SIZE 8
+#define ACCUM_SIZE 16
-GLboolean g_redisplay = GL_FALSE;
GLuint g_bpp = DEFAULT_BPP;
+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;
@@ -58,6 +67,15 @@ void APIENTRY glutInit (int *argc, char **argv)
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
g_bpp = atoi(env);
}
+ if ((env = getenv("DMESA_GLUT_DEPTH")) != NULL) {
+ g_depth = atoi(env);
+ }
+ if ((env = getenv("DMESA_GLUT_STENCIL")) != NULL) {
+ g_stencil = atoi(env);
+ }
+ if ((env = getenv("DMESA_GLUT_ACCUM")) != NULL) {
+ g_accum = atoi(env);
+ }
if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
g_refresh = atoi(env);
}
@@ -109,6 +127,7 @@ void APIENTRY glutInitWindowSize (int width, int height)
void APIENTRY glutMainLoop (void)
{
+ int i;
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
@@ -125,29 +144,43 @@ void APIENTRY glutMainLoop (void)
pc_install_keyb();
__glutInitMouse();
- glutPostRedisplay();
- if (g_curwin->reshape) {
- g_curwin->reshape(g_curwin->width, g_curwin->height);
- }
- if (g_curwin->visibility) {
- g_curwin->visibility(GLUT_VISIBLE);
+ for (i = 0; i < MAX_WINDOWS; i++) {
+ if (g_windows[i] != NULL) {
+ GLUTwindow *w = g_windows[i];
+ 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;
- if (g_redisplay && g_curwin->display) {
- idle = GL_FALSE;
- g_redisplay = GL_FALSE;
-
- if (g_curwin->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {
- /* XXX scare mouse */
- g_curwin->display();
- /* XXX unscare mouse */
- } else {
- g_curwin->display();
- }
+ for (i = 0; i < MAX_WINDOWS; i++) {
+ if (g_windows[i] != NULL) {
+ GLUTwindow *w = g_windows[i];
+ if (w->redisplay && w->display) {
+ idle = GL_FALSE;
+ w->redisplay = GL_FALSE;
+
+ if (DMesaMakeCurrent(w->context, w->buffer)) {
+ if (w->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {
+ /* XXX scare mouse */
+ w->display();
+ /* XXX unscare mouse */
+ } else {
+ w->display();
+ }
+ }
+ }
+ }
}
+ DMesaMakeCurrent(g_curwin->context, g_curwin->buffer);
if (g_mouse) {
int mouse_x;
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c
index 245d2ef621..e9d854cd4e 100644
--- a/src/glut/dos/state.c
+++ b/src/glut/dos/state.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.3 for Mesa
+ * DOS/DJGPP glut driver v1.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -60,9 +60,9 @@ int APIENTRY glutGet (GLenum type)
case GLUT_WINDOW_HEIGHT:
return g_curwin->height;
case GLUT_WINDOW_STENCIL_SIZE:
- return STENCIL_SIZE;
+ return g_stencil;
case GLUT_WINDOW_DEPTH_SIZE:
- return DEPTH_SIZE;
+ return g_depth;
case GLUT_WINDOW_RGBA:
return !(g_display_mode & GLUT_INDEX);
case GLUT_WINDOW_COLORMAP_SIZE:
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index cfc2f965c0..06e8ea9ead 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -19,10 +19,10 @@
*/
/*
- * DOS/DJGPP glut driver v1.3 for Mesa
+ * DOS/DJGPP glut driver v1.4 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
- * Email : dborca@yahoo.com
+ * Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
@@ -38,8 +38,7 @@ GLUTwindow *g_curwin;
static GLuint swaptime, swapcount;
static DMesaVisual visual = NULL;
-static DMesaContext context = NULL;
-static GLUTwindow *windows[MAX_WINDOWS];
+GLUTwindow *g_windows[MAX_WINDOWS];
@@ -50,7 +49,6 @@ static void clean (void)
for (i=1; i<=MAX_WINDOWS; i++) {
glutDestroyWindow(i);
}
- if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
pc_close_stdout();
@@ -64,53 +62,72 @@ int APIENTRY glutCreateWindow (const char *title)
int i;
int m8width = (g_init_w + 7) & ~7;
+ /* We set the Visual once. This will be our desktop (graphic mode).
+ * We should do this in the `glutInit' code, but we don't have any idea
+ * about its geometry. Supposedly, when we are about to create one
+ * window, we have a slight idea about resolution.
+ */
if (!visual) {
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,
- g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
- g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
- g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
- return 0;
- }
-
- if ((context=DMesaCreateContext(visual, NULL))==NULL) {
- DMesaDestroyVisual(visual);
+ g_display_mode & GLUT_DEPTH ? g_depth :0,
+ g_display_mode & GLUT_STENCIL ? g_stencil:0,
+ g_display_mode & GLUT_ACCUM ? g_accum :0))==NULL) {
return 0;
}
+ /* Also hook stdio/stderr once */
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
+ /* Search for an empty slot.
+ * Each window has its own rendering Context and its own Buffer.
+ */
for (i=0; i<MAX_WINDOWS; i++) {
- if (windows[i] == NULL) {
+ if (g_windows[i] == NULL) {
+ DMesaContext c;
DMesaBuffer b;
GLUTwindow *w;
- if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
+ if ((w = (GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {
+ return 0;
+ }
+
+ /* Allocate the rendering Context. */
+ if ((c = DMesaCreateContext(visual, NULL)) == NULL) {
+ free(w);
return 0;
}
- if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {
+ /* Allocate the Buffer (displayable area).
+ * We have to specify buffer size and position (inside the desktop).
+ */
+ if ((b = DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h)) == NULL) {
+ DMesaDestroyContext(c);
free(w);
return 0;
}
- if (!DMesaMakeCurrent(context, b)) {
+
+ /* Bind Buffer to Context and make the Context the current one. */
+ if (!DMesaMakeCurrent(c, b)) {
DMesaDestroyBuffer(b);
+ DMesaDestroyContext(c);
free(w);
return 0;
}
- g_curwin = windows[i] = w;
+ g_curwin = g_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->context = c;
w->buffer = b;
return i;
@@ -131,10 +148,13 @@ int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
void APIENTRY glutDestroyWindow (int win)
{
- if (windows[--win]) {
- DMesaDestroyBuffer(windows[win]->buffer);
- free(windows[win]);
- windows[win] = NULL;
+ if (g_windows[--win]) {
+ GLUTwindow *w = g_windows[win];
+ DMesaMakeCurrent(NULL, NULL);
+ DMesaDestroyBuffer(w->buffer);
+ DMesaDestroyContext(w->context);
+ free(w);
+ g_windows[win] = NULL;
}
}
@@ -142,7 +162,7 @@ void APIENTRY glutDestroyWindow (int win)
void APIENTRY glutPostRedisplay (void)
{
- g_redisplay = GL_TRUE;
+ g_curwin->redisplay = GL_TRUE;
}
@@ -183,7 +203,8 @@ int APIENTRY glutGetWindow (void)
void APIENTRY glutSetWindow (int win)
{
- g_curwin = windows[win - 1];
+ g_curwin = g_windows[win - 1];
+ DMesaMakeCurrent(g_curwin->context, g_curwin->buffer);
}