summaryrefslogtreecommitdiffstats
path: root/src/glut
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-09-03 18:11:32 +0000
committerBrian Paul <[email protected]>2002-09-03 18:11:32 +0000
commit05ed911aca5ad0a6842ea0d6f3ac99b79ec752db (patch)
tree3eab5e0bb8d2d90f3076a0c48679b7f08674ba73 /src/glut
parentb9f75444e60477e7a523e7eec1bb49a8232fd4e7 (diff)
updates from Daniel Borca
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/dos/Makefile.DJ96
-rw-r--r--src/glut/dos/PC_HW/pc_hw.h6
-rw-r--r--src/glut/dos/PC_HW/pc_keyb.c14
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c12
-rw-r--r--src/glut/dos/bitmap.c56
-rw-r--r--src/glut/dos/window.c44
6 files changed, 174 insertions, 54 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
index 02bc31b10ce..698c80ce3c0 100644
--- a/src/glut/dos/Makefile.DJ
+++ b/src/glut/dos/Makefile.DJ
@@ -20,36 +20,65 @@
# 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.0 for Mesa 4.0
+# DOS/DJGPP glut makefile v1.1 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : [email protected]
# Web : http://www.geocities.com/dborca
+#
+# Available options:
+#
+# 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.
+# default = $(TOP)/src-glut
+#
+# Targets:
+# all: build GLUT
+# clean: remove object files
+#
+
+
+
.PHONY: all clean
TOP = ..
+GLIDE ?= $(TOP)/include/glide3
+MARK ?= $(TOP)/src-glut
+LIBDIR = $(TOP)/lib
+GLUT_LIB = libglut.a
+GLUT_DXE = glut.dxe
+GLUT_IMP = libiglut.a
+
CC = gcc
-CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=$(CPU) -ffast-math -O2
+CFLAGS += -I$(TOP)/include -I$(MARK)
+ifdef FX
+CFLAGS += -D__DOS__ -I$(GLIDE) -DFX -DFX_GLIDE3 -DFXMESA_USE_ARGB
+endif
+
AR = ar
-ARFLAGS = ruv
-LIBDIR = $(TOP)/lib
+ARFLAGS = ru
-ifeq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
-DXE2GEN =
-else
+ifneq ($(wildcard $(DJDIR)/lib/dxe2.ld),)
DXE2GEN = $(wildcard $(addsuffix /dxe2gen.exe,$(subst ;, ,$(PATH))))
endif
-GLUT_LIB = libglut.a
-GLUT_DXE = glut.dxe
-GLUT_IMP = libiglut.a
+RM = del
CORE_SOURCES = \
+ bitmap.c \
callback.c \
color.c \
- font.c \
globals.c \
init.c \
menu.c \
@@ -66,16 +95,25 @@ PC_HW_SOURCES = \
PC_HW/pc_timer.c \
PC_HW/pc_irq.S
-SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES)
+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
+
+SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MARK_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
.c.o:
- gcc -o $@ -c $(CFLAGS) $<
+ $(CC) -o $@ -c $(CFLAGS) $<
.S.o:
- gcc -o $@ -c $(CFLAGS) $<
+ $(CC) -o $@ -c $(CFLAGS) $<
.s.o:
- gcc -o $@ -c $(CFLAGS) $(<:.s=.S)
+ $(CC) -o $@ -c $(CFLAGS) -x assembler-with-cpp $<
all: $(LIBDIR)/$(GLUT_LIB) $(LIBDIR)/$(GLUT_DXE) $(LIBDIR)/$(GLUT_IMP)
@@ -87,28 +125,12 @@ ifeq ($(DXE2GEN),)
$(warning Missing DXE2GEN and/or DXE2.LD! You must have DXE2GEN)
$(warning somewhere in PATH, and DXE2.LD in DJGPP/LIB directory.)
else
- dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -D "Mesa DOS GLUT" -U
+ -dxe2gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) $(OBJECTS) -E djgpp_ -E glut -D "Mesa DJGPP GLUT" -U
endif
clean:
- -$(RM) *.o
- -$(RM) PC_HW\*.o
-
-callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
-color.o: color.c ../include/GL/glut.h
-font.o: font.c ../include/GL/glut.h
-globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
-init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
-menu.o: menu.c ../include/GL/glut.h
-models.o: models.c ../include/GL/glut.h
-overlay.o: overlay.c ../include/GL/glut.h
-state.o: state.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
-teapot.o: teapot.c ../include/GL/glut.h
-window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \
- PC_HW/pc_hw.h
-
-PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h
-PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h
-PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h
-PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h
-PC_HW/pc_irq.o: PC_HW/pc_irq.S
+ -$(RM) $(subst /,\,*.o)
+ -$(RM) $(subst /,\,PC_HW/*.o)
+ -$(RM) $(subst /,\,$(MARK)/*.o)
+
+-include depend
diff --git a/src/glut/dos/PC_HW/pc_hw.h b/src/glut/dos/PC_HW/pc_hw.h
index 47fcf78d0c8..fd0e777953d 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.0 for DOS/DJGPP
+ * PC/HW routine collection v1.1 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -45,8 +45,8 @@ void *pc_malloc (size_t size);
/*
* IRQ
*/
-#define ENABLE() __asm__ __volatile__ ("sti")
-#define DISABLE() __asm__ __volatile__ ("cli")
+#define ENABLE() __asm __volatile ("sti")
+#define DISABLE() __asm __volatile ("cli")
extern int pc_install_irq (int i, int (*handler) ());
extern int pc_remove_irq (int i);
diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c
index 50ef94b797b..fb22923d63f 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.0 for DOS/DJGPP
+ * PC/HW routine collection v1.1 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -201,7 +201,7 @@ static unsigned char numlock_table[10] =
/* kb_wait_for_write_ready:
* Wait for the keyboard controller to set the ready-for-write bit.
*/
-static __inline__ int kb_wait_for_write_ready (void)
+static __inline int kb_wait_for_write_ready (void)
{
int timeout = 4096;
@@ -215,7 +215,7 @@ static __inline__ int kb_wait_for_write_ready (void)
/* kb_wait_for_read_ready:
* Wait for the keyboard controller to set the ready-for-read bit.
*/
-static __inline__ int kb_wait_for_read_ready (void)
+static __inline int kb_wait_for_read_ready (void)
{
int timeout = 16384;
@@ -229,7 +229,7 @@ static __inline__ int kb_wait_for_read_ready (void)
/* kb_send_data:
* Sends a byte to the keyboard controller. Returns 1 if all OK.
*/
-static __inline__ int kb_send_data (unsigned char data)
+static __inline int kb_send_data (unsigned char data)
{
int resends = 4;
int timeout, temp;
@@ -357,9 +357,9 @@ static void handle_code (int scancode, int keycode)
in_a_terrupt--;
} ENDOFUNC(handle_code)
-static __inline__ void satisfy (void)
+static __inline void satisfy (void)
{
- __asm__("\n\
+ __asm("\n\
inb $0x61, %%al \n\
movb %%al, %%ah \n\
orb $0x80, %%al \n\
@@ -404,7 +404,7 @@ static int keyboard ()
only SIGINT (but not Ctrl-Break)
calls the destructors and will safely clean up
*/
- __asm__("\n\
+ __asm("\n\
movb $0x79, %%al \n\
call ___djgpp_hw_exception \n\
":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
index 72d3886d5ce..5a04cf21913 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.0 for DOS/DJGPP
+ * PC/HW routine collection v1.1 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -17,7 +17,7 @@
#define CLEAR_MICKEYS() \
do { \
- __asm__ __volatile__ ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
+ __asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
ox = oy = 0; \
} while (0)
@@ -71,7 +71,7 @@ void pc_remove_mouse (void)
{
if (mouse_callback) {
pc_clexit(pc_remove_mouse);
- __asm__("\n\
+ __asm("\n\
movl %%edx, %%ecx \n\
shrl $16, %%ecx \n\
movw $0x0304, %%ax \n\
@@ -97,7 +97,7 @@ int pc_install_mouse (void)
}
/* reset mouse and get status */
- __asm__("\n\
+ __asm("\n\
xorl %%eax, %%eax \n\
int $0x33 \n\
andl %%ebx, %%eax \n\
@@ -133,7 +133,7 @@ int pc_install_mouse (void)
}
/* try to hook a call-back */
- __asm__("\n\
+ __asm("\n\
pushl %%ds \n\
pushl %%es \n\
movw $0x0303, %%ax \n\
@@ -225,7 +225,7 @@ void pc_unscare_mouse (void)
/* not implemented */
}
-__asm__("\n\
+__asm("\n\
.balign 4 \n\
.global _mouse_wrapper \n\
_mouse_wrapper: \n\
diff --git a/src/glut/dos/bitmap.c b/src/glut/dos/bitmap.c
new file mode 100644
index 00000000000..11d539a19a5
--- /dev/null
+++ b/src/glut/dos/bitmap.c
@@ -0,0 +1,56 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/* 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. */
+
+#include "glutbitmap.h"
+
+void APIENTRY
+glutBitmapCharacter(GLUTbitmapFont font, int c)
+{
+ const BitmapCharRec *ch;
+ BitmapFontPtr fontinfo;
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+
+#if defined(_WIN32)
+ fontinfo = (BitmapFontPtr) __glutFont(font);
+#else
+ fontinfo = (BitmapFontPtr) font;
+#endif
+
+ if (c < fontinfo->first ||
+ c >= fontinfo->first + fontinfo->num_chars)
+ return;
+ ch = fontinfo->ch[c - fontinfo->first];
+ if (ch) {
+ /* Save current modes. */
+ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+ /* Little endian machines (DEC Alpha for example) could
+ benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
+ instead of GL_FALSE, but this would require changing the
+ generated bitmaps too. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
+ ch->advance, 0, ch->bitmap);
+ /* Restore saved modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+ }
+}
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
index f43533ce5f8..384e10a03b8 100644
--- a/src/glut/dos/window.c
+++ b/src/glut/dos/window.c
@@ -19,7 +19,7 @@
*/
/*
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0
+ * DOS/DJGPP glut driver v1.1 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : [email protected]
@@ -28,16 +28,26 @@
#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
@@ -48,8 +58,12 @@ 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,6 +90,7 @@ int APIENTRY glutCreateWindow (const char *title)
screen_h = 768;
}
+#ifndef FX
if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,
g_display_mode & GLUT_DOUBLE,
g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
@@ -88,12 +103,24 @@ 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;
+ }
+#endif
pc_open_stdout();
pc_open_stderr();
pc_atexit(clean);
}
+#ifndef FX
for (i=0; i<MAX_WINDOWS; i++) {
if (!buffer[i]) {
DMesaBuffer b;
@@ -115,6 +142,11 @@ int APIENTRY glutCreateWindow (const char *title)
}
return 0;
+#else
+ fxMesaMakeCurrent(context);
+
+ return 1;
+#endif
}
@@ -126,10 +158,12 @@ 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
}
@@ -142,7 +176,11 @@ 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();
}
@@ -171,15 +209,18 @@ 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;
@@ -189,6 +230,7 @@ void APIENTRY glutReshapeWindow (int width, int height)
glViewport(0, 0, width, height);
}
}
+#endif
}