summaryrefslogtreecommitdiff
path: root/src/glut
diff options
context:
space:
mode:
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/dos/Makefile.DJ56
-rw-r--r--src/glut/dos/PC_HW/pc_hw.c84
-rw-r--r--src/glut/dos/color.c14
-rw-r--r--src/glut/dos/globals.c8
-rw-r--r--src/glut/dos/init.c11
-rw-r--r--src/glut/dos/internal.h6
-rw-r--r--src/glut/dos/state.c6
-rw-r--r--src/glut/dos/window.c63
8 files changed, 105 insertions, 143 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index 698c80ce3c..fed1f42e8c 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -20,7 +20,7 @@
# 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.
-# DOS/DJGPP glut makefile v1.1 for Mesa 4.0
+# DOS/DJGPP glut makefile v1.3 for Mesa 5.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -33,14 +33,7 @@
# Environment variables:
# CFLAGS
#
-# GLIDE absolute path to Glide SDK; used with FX.
-# default = $(TOP)/include/glide3
-# FX=1 build for 3dfx Glide3; use it if you have the glide
-# SDK (designed for your platform), and, of course, a
-# 3dfx card... Note that this disables compilation of
-# actual DMesa code, as Glide does all the stuff!
-# default = no
-# MARK absolute path to original GLUT.
+# MKGLUT absolute path to original GLUT.
# default = $(TOP)/src-glut
#
# Targets:
@@ -54,23 +47,20 @@
TOP = ..
GLIDE ?= $(TOP)/include/glide3
-MARK ?= $(TOP)/src-glut
+MKGLUT ?= $(TOP)/src-glut
LIBDIR = $(TOP)/lib
GLUT_LIB = libglut.a
GLUT_DXE = glut.dxe
GLUT_IMP = libiglut.a
CC = gcc
-CFLAGS += -I$(TOP)/include -I$(MARK)
-ifdef FX
-CFLAGS += -D__DOS__ -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB
-endif
+CFLAGS += -I$(TOP)/include -I$(MKGLUT)
AR = ar
ARFLAGS = ru
-ifneq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
-DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
+ifneq ($(wildcard $(DJDIR)/lib/dxe3.ld),)
+DXE3GEN = $(wildcard $(addsuffix /dxe3gen.exe,$(subst ;, ,$(PATH))))
endif
RM = del
@@ -95,25 +85,25 @@ PC_HW_SOURCES = \
PC_HW/pc_timer.c \
PC_HW/pc_irq.S
-MARK_SOURCES = \
- $(MARK)/glut_8x13.c \
- $(MARK)/glut_9x15.c \
- $(MARK)/glut_hel10.c \
- $(MARK)/glut_hel12.c \
- $(MARK)/glut_hel18.c \
- $(MARK)/glut_tr10.c \
- $(MARK)/glut_tr24.c
+MKGLUT_SOURCES = \
+ $(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
-SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MARK_SOURCES)
+SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MKGLUT_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
- $(CC) -o $@ -c $(CFLAGS) $<
+ $(CC) -o $@ $(CFLAGS) -c $<
.S.o:
- $(CC) -o $@ -c $(CFLAGS) $<
+ $(CC) -o $@ $(CFLAGS) -c $<
.s.o:
- $(CC) -o $@ -c $(CFLAGS) -x assembler-with-cpp $<
+ $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
@@ -121,16 +111,16 @@ $(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
$(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
-ifeq ($(DXE2GEN),)
- $(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)
- $(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)
+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
- -dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -E djgpp_ -E glut -D "Mesa DJGPP GLUT" -U
+ -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E glut -X -P gl.dxe -P glu.dxe -U $(OBJECTS)
endif
clean:
-$(RM) $(subst /,\,*.o)
-$(RM) $(subst /,\,PC_HW/*.o)
- -$(RM) $(subst /,\,$(MARK)/*.o)
+ -$(RM) $(subst /,\,$(MKGLUT)/*.o)
-include depend
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c
index 9b30c5808c..867daf89b0 100644
--- a/src/glut/dos/PC_HW/pc_hw.c
+++ b/src/glut/dos/PC_HW/pc_hw.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
@@ -73,21 +73,25 @@ void *pc_malloc (size_t size)
/*
* standard redirection
*/
-static int h_out, h_outbak, h_err, h_errbak;
+#define STDOUT 1
+#define STDERR 2
+
+static char outname[L_tmpnam];
+static int h_out, h_outbak;
+static char errname[L_tmpnam];
+static int h_err, h_errbak;
int pc_open_stdout (void)
{
- if ((h_out=open(tmpnam(NULL), O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_TEMPORARY, S_IRUSR | S_IWUSR)) >= 0) {
- if ((h_outbak=dup(1)) != -1) {
- fflush(stdout);
- if (dup2(h_out, 1) != -1) {
- return 0;
- }
- close(h_outbak);
- }
- close(h_out);
+ tmpnam(outname);
+
+ if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
+ h_outbak = dup(STDOUT);
+ fflush(stdout);
+ dup2(h_out, STDOUT);
}
- return (h_out = -1);
+
+ return h_out;
}
void pc_close_stdout (void)
@@ -95,35 +99,32 @@ void pc_close_stdout (void)
FILE *f;
char *line = alloca(512);
- if (h_out >= 0) {
- dup2(h_outbak, 1);
+ if (h_out > 0) {
+ dup2(h_outbak, STDOUT);
+ close(h_out);
close(h_outbak);
- if ((f=fdopen(h_out, "r")) != NULL) {
- fseek(f, 0, SEEK_SET);
- while (fgets(line, 512, f)) {
- fputs(line, stdout);
- }
- fclose(f);
- } else {
- close(h_out);
+ f = fopen(outname, "rt");
+ while (fgets(line, 512, f)) {
+ fputs(line, stdout);
}
+ fclose(f);
+
+ remove(outname);
}
}
int pc_open_stderr (void)
{
- if ((h_err=open(tmpnam(NULL), O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_TEMPORARY, S_IRUSR | S_IWUSR)) >= 0) {
- if ((h_errbak=dup(2)) != -1) {
- fflush(stderr);
- if (dup2(h_err, 2) != -1) {
- return 0;
- }
- close(h_errbak);
- }
- close(h_err);
+ tmpnam(errname);
+
+ if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {
+ h_errbak = dup(STDERR);
+ fflush(stderr);
+ dup2(h_err, STDERR);
}
- return (h_err = -1);
+
+ return h_err;
}
void pc_close_stderr (void)
@@ -131,18 +132,17 @@ void pc_close_stderr (void)
FILE *f;
char *line = alloca(512);
- if (h_err >= 0) {
- dup2(h_errbak, 2);
+ if (h_err > 0) {
+ dup2(h_errbak, STDERR);
+ close(h_err);
close(h_errbak);
- if ((f=fdopen(h_err, "r")) != NULL) {
- fseek(f, 0, SEEK_SET);
- while (fgets(line, 512, f)) {
- fputs(line, stderr);
- }
- fclose(f);
- } else {
- close(h_err);
+ f = fopen(errname, "rt");
+ while (fgets(line, 512, f)) {
+ fputs(line, stderr);
}
+ fclose(f);
+
+ remove(errname);
}
}
diff --git a/src/glut/dos/color.c b/src/glut/dos/color.c
index 9a7754514c..f1f529521d 100644
--- a/src/glut/dos/color.c
+++ b/src/glut/dos/color.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
@@ -28,19 +28,31 @@
#include "GL/glut.h"
+#include "GL/dmesa.h"
+#include "internal.h"
+
+
+
+#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i)))
+
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));
+ }
}
+
GLfloat APIENTRY glutGetColor (int ndx, int component)
{
return 0.0;
}
+
void APIENTRY glutCopyColormap (int win)
{
}
diff --git a/src/glut/dos/globals.c b/src/glut/dos/globals.c
index 342cf3d08f..c264992cc7 100644
--- a/src/glut/dos/globals.c
+++ b/src/glut/dos/globals.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
@@ -30,10 +30,12 @@
#include "GL/glut.h"
#include "internal.h"
-GLenum g_display_mode = 0;
+GLuint g_display_mode = 0;
GLuint g_width = DEFAULT_WIDTH;
GLuint g_height = DEFAULT_HEIGHT;
-GLint g_mouse = GL_FALSE;
+GLuint g_bpp = DEFAULT_BPP;
+GLuint g_refresh = 0;
+GLuint g_mouse = 0;
GLboolean g_redisplay = GL_FALSE;
GLint g_xpos = 0;
GLint g_ypos = 0;
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
index a6d7e830b0..4ee939b487 100644
--- a/src/glut/dos/init.c
+++ b/src/glut/dos/init.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
@@ -33,6 +33,15 @@
void APIENTRY glutInit (int *argcp, char **argv)
{
+ const char *env;
+
+ if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
+ g_bpp = atoi(env);
+ }
+ if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
+ g_refresh = atoi(env);
+ }
+
glutGet(GLUT_ELAPSED_TIME);
}
diff --git a/src/glut/dos/internal.h b/src/glut/dos/internal.h
index e23d485b2e..ac9e58b2df 100644
--- a/src/glut/dos/internal.h
+++ b/src/glut/dos/internal.h
@@ -45,10 +45,12 @@
#define STENCIL_SIZE 8
#define ACCUM_SIZE 16
-extern GLenum g_display_mode;
+extern GLuint g_display_mode;
extern GLuint g_width;
extern GLuint g_height;
-extern GLint g_mouse;
+extern GLuint g_bpp;
+extern GLuint g_refresh;
+extern GLuint g_mouse;
extern GLboolean g_redisplay;
extern GLint g_xpos;
extern GLint g_ypos;
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c
index b463f4a109..b26307d9cb 100644
--- a/src/glut/dos/state.c
+++ b/src/glut/dos/state.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
@@ -48,8 +48,10 @@ 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_RGBA:
- return 1;
+ return !(g_display_mode & GLUT_INDEX);
case GLUT_ELAPSED_TIME:
if (!timer_installed) {
timer_installed = !timer_installed;
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index ba0f5acee5..cce1a1f777 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.2 for Mesa 4.1
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -28,26 +28,16 @@
#include "GL/glut.h"
-#ifndef FX
#include "GL/dmesa.h"
-#else
-#include "GL/fxmesa.h"
-#endif
#include "internal.h"
static int window;
-#ifndef FX
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
static DMesaBuffer buffer[MAX_WINDOWS];
-#else
-static void *visual = NULL;
-static fxMesaContext context = NULL;
-static int fx_attrib[32];
-#endif
@@ -58,12 +48,8 @@ static void clean (void)
for (i=0; i<MAX_WINDOWS; i++) {
glutDestroyWindow(i+1);
}
-#ifndef FX
if (context) DMesaDestroyContext(context);
if (visual) DMesaDestroyVisual(visual);
-#else
- if (context) fxMesaDestroyContext(context);
-#endif
pc_close_stdout();
pc_close_stderr();
@@ -76,23 +62,10 @@ int APIENTRY glutCreateWindow (const char *title)
int i;
if (!visual) {
- int screen_w = DEFAULT_WIDTH;
- int screen_h = DEFAULT_HEIGHT;
-
- if ((g_width<=640) && (g_height<=480)) {
- screen_w = 640;
- screen_h = 480;
- } else if ((g_width<=800) && (g_height<=600)) {
- screen_w = 800;
- screen_h = 600;
- } else if ((g_width<=1024) && (g_height<=768)) {
- screen_w = 1024;
- screen_h = 768;
- }
-
-#ifndef FX
- if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,
+ if ((visual=DMesaCreateVisual(g_xpos + g_width, g_ypos + g_height, 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) {
@@ -103,25 +76,12 @@ int APIENTRY glutCreateWindow (const char *title)
DMesaDestroyVisual(visual);
return 0;
}
-#else
- i = 0;
- if (g_display_mode & GLUT_DOUBLE) fx_attrib[i++] = FXMESA_DOUBLEBUFFER;
- if (g_display_mode & GLUT_DEPTH) { fx_attrib[i++] = FXMESA_DEPTH_SIZE; fx_attrib[i++] = DEPTH_SIZE; }
- if (g_display_mode & GLUT_STENCIL) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = STENCIL_SIZE; }
- if (g_display_mode & GLUT_ACCUM) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = ACCUM_SIZE; }
- fx_attrib[i] = FXMESA_NONE;
- if ((context=fxMesaCreateBestContext(-1, screen_w, screen_h, fx_attrib))==NULL) {
- return 0;
- }
- visual = context;
-#endif
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
-#ifndef FX
for (i=0; i<MAX_WINDOWS; i++) {
if (!buffer[i]) {
DMesaBuffer b;
@@ -143,11 +103,6 @@ int APIENTRY glutCreateWindow (const char *title)
}
return 0;
-#else
- fxMesaMakeCurrent(context);
-
- return 1;
-#endif
}
@@ -159,12 +114,10 @@ int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
void APIENTRY glutDestroyWindow (int win)
{
-#ifndef FX
if (buffer[win-1]) {
DMesaDestroyBuffer(buffer[win-1]);
buffer[win-1] = NULL;
}
-#endif
}
@@ -177,11 +130,7 @@ void APIENTRY glutPostRedisplay (void)
void APIENTRY glutSwapBuffers (void)
{
if (g_mouse) pc_scare_mouse();
-#ifndef FX
DMesaSwapBuffers(buffer[window]);
-#else
- fxMesaSwapBuffers();
-#endif
if (g_mouse) pc_unscare_mouse();
}
@@ -210,18 +159,15 @@ void APIENTRY glutSetIconTitle (const char *title)
void APIENTRY glutPositionWindow (int x, int y)
{
-#ifndef FX
if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {
g_xpos = x;
g_ypos = y;
}
-#endif
}
void APIENTRY glutReshapeWindow (int width, int height)
{
-#ifndef FX
if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {
g_width = width;
g_height = height;
@@ -231,7 +177,6 @@ void APIENTRY glutReshapeWindow (int width, int height)
glViewport(0, 0, width, height);
}
}
-#endif
}