From 05ed911aca5ad0a6842ea0d6f3ac99b79ec752db Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 3 Sep 2002 18:11:32 +0000 Subject: updates from Daniel Borca --- src/glut/dos/Makefile.DJ | 96 ++++++++++++++++++++++++++----------------- src/glut/dos/PC_HW/pc_hw.h | 6 +-- src/glut/dos/PC_HW/pc_keyb.c | 14 +++---- src/glut/dos/PC_HW/pc_mouse.c | 12 +++--- src/glut/dos/bitmap.c | 56 +++++++++++++++++++++++++ src/glut/dos/window.c | 44 +++++++++++++++++++- 6 files changed, 174 insertions(+), 54 deletions(-) create mode 100644 src/glut/dos/bitmap.c (limited to 'src/glut') diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ index 02bc31b10c..698c80ce3c 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 : dborca@yahoo.com # 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 47fcf78d0c..fd0e777953 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 : dborca@yahoo.com @@ -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 50ef94b797..fb22923d63 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 : dborca@yahoo.com @@ -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 72d3886d5c..5a04cf2191 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 : dborca@yahoo.com @@ -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 0000000000..11d539a19a --- /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 f43533ce5f..384e10a03b 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 : dborca@yahoo.com @@ -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