summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/README.DJ65
-rw-r--r--include/GL/dmesa.h17
-rw-r--r--progs/samples/Makefile.DJ125
-rw-r--r--src/glu/mesa/Makefile.DJ2
-rw-r--r--src/glu/sgi/Makefile.DJ4
-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
-rw-r--r--src/mesa/drivers/dos/dmesa.c81
-rw-r--r--src/mesa/drivers/dos/vesa/vesa.c33
-rw-r--r--src/mesa/drivers/dos/vga/vga.c33
-rw-r--r--src/mesa/drivers/dos/video.c109
-rw-r--r--src/mesa/drivers/dos/video.h5
-rw-r--r--src/mesa/drivers/dos/virtual.S29
-rw-r--r--src/mesa/main/Makefile.DJ35
28 files changed, 1073 insertions, 390 deletions
diff --git a/docs/README.DJ b/docs/README.DJ
index 580228234a..6589f52a2e 100644
--- a/docs/README.DJ
+++ b/docs/README.DJ
@@ -32,22 +32,20 @@ Available options:
Environment variables:
CPU optimize for the given processor.
default = k6
- BIG_OPT=1 crazy optimizations; not very useful, though...
- default = no
SGI_GLU=1 build SGI's GLU instead of Mesa's.
default = no
- GLIDE absolute path to Glide library; used with FX.
+ GLIDE path to Glide3 SDK include files; 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!
+ FX=1 build for 3dfx Glide3. Note that this disables
+ compilation of most DMesa code and requires fxMesa.
+ As a consequence, you'll need the DJGPP Glide3
+ library to build any application.
default = no
HAVE_X86=1 optimize for i386.
default = no
- HAVE_MMX=1 MMX instructions; use only if you assembler/compiler
- supports MMX instruction set; backwards compatibility
- with older processors is still preserved.
+ HAVE_MMX=1 allow MMX specializations, provided your assembler
+ supports MMX instruction set. However, the true CPU
+ capabilities are checked at run-time to avoid crashes.
default = no
HAVE_SSE=1 (see HAVE_MMX)
default = no
@@ -68,7 +66,7 @@ Tested on:
CPU: K6-2 (CXT) @500(412.5) MHz
Mainboard: ViA Apollo VP2/97 w/ 128 MB SDRAM
Video card: PowerColor EvilKing3 (Voodoo3 3000 PCI) w/ 16 MB SDRAM
- DJGPP: djdev 2.04 + gcc v3.2 + make v3.79.1
+ DJGPP: djdev 2.04 + gcc v3.2.1 + make v3.79.1
OS: DOS and Win9x
@@ -99,7 +97,7 @@ FAQ:
A) Build your export object file; then link it with your application.
For example:
dxe3res -o dmesadxe.c gl.dxe glu.dxe glut.dxe
- gcc -o dmesadxe.o -c -fno-builtin dmesadxe.c
+ gcc -o dmesadxe.o -c dmesadxe.c
gcc -o OUT.exe dmesadxe.o IN.c -liglut -liglu -ligl -ldl
3. Using Mesa for DJGPP
@@ -109,10 +107,16 @@ FAQ:
Glide port is on my web page. If you haven't, sorry; everything is done
in software. Suggestions?
+ Q) I tried to set refresh rate w/ DMesa, but without success.
+ A) Refresh rate control works only for VESA 3.0. If you were compiling for
+ Glide, see Glide info. If not, sorry!
+
Q) I made a simple application and it does nothing. It exits right away. Not
even a blank screen.
- A) Single-buffered is not allowed at all. Until I can find a way to use
- *REAL* hardware acceleration, it won't get implemented.
+ A) Only DMesa+FX supports single-buffered. The standard VESA/VGA drivers
+ will always work in double-buffered modes. If/When I will find a way to
+ use *REAL* hardware acceleration for a specific card, it might or might
+ not support single-buffered modes.
A) Another weird "feature" is that buffer width must be multiple of 8 (I'm a
lazy programmer and I found that the easiest way to keep buffer handling
at peak performance ;-).
@@ -123,10 +127,6 @@ FAQ:
GLUT took this into account for _WIN32 DLL's only; I don't want to modify
his headers. The only workaround is to link GLUT the old way :-(
- Q) I tried to set refresh rate w/ DMesa, but without success.
- A) Refresh rate control works only for VESA 3.0. If you were compiling for
- Glide, see Glide info. If not, sorry!
-
Q) The GLUT is incomplete.
A) See below.
@@ -135,9 +135,14 @@ FAQ:
libGLUT (the toolkit):
~~~~~~~~~~~~~~~~~~~~~~
-Well, this "skeletal" GLUT implementation is not mine. Thanks should go to
-Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably
-not ;-). GLUT functionality will be extended only on an "as needed" basis.
+Well, this "skeletal" GLUT implementation was taken from AllegGL project and
+heavily changed. Thanks should go to Bernhard Tschirren, Mark Kilgard, Brian
+Paul and probably others (or probably not ;-). GLUT functionality will be
+extended only on an "as needed" basis.
+
+GLUT talks to hardware via PC_HW package which was put together from various
+pieces I wrote long time ago. It consists from the keyboard, mouse and timer
+drivers.
My keyboard driver used only scancodes; as GLUT requires ASCII values for keys,
I borrowed the translation tables (and maybe more) from Allegro -- many thanks
@@ -163,14 +168,15 @@ means that `printf' can be safely called during graphics. A bit of a hack, I
know, because all messages come in bulk, but I think it's better than nothing.
"Borrowed" from LIBRHUTI (Robert Hoehne).
-Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.
-However, the video mode is chosen in such a way that first window will fit. If
-you need high resolution with small windows, try to place them far to the right
-(or way down).
+Window creating defaults: 300x300x16 at (0,0), 16-bit depth, 16-bit accum,
+8-bit stencil. However, the video mode is chosen in such a way that first
+window will fit. If you need high resolution with small windows, set initial
+position far to the right (or way down); then you can move them back to any
+position right before the main loop.
The following environment variables can customize GLUT behaviour:
- DMESA_GLUT_REFRESH - set vertical screen refresh rate
- DMESA_GLUT_BPP - set default bits per pixel
+ DMESA_GLUT_REFRESH - set vertical screen refresh rate (VESA3)
+ DMESA_GLUT_BPP - set default bits per pixel (VGA needs 8)
@@ -190,17 +196,18 @@ v1.2 (nov-2002)
* synced w/ Mesa-4.1
- removed dmesadxe.h
-v1.3 (dec-2002)
+v1.3 (jan-2003)
+ enabled OpenGL 1.4 support
+ added MMX clear/blit routines
+ enabled SGI's GLU compilation
+ + added new GLUT functions
+ added color-index modes
+ added 8bit FakeColor (thanks to Neil Funk)
+ added VGA support (to keep Ben Decker happy)
* fixed GLUT compilation error (reported by Chan Kar Heng)
* overhauled virtual buffer and internal video drivers
* better fxMesa integration
- * extended GLUT functionality
+ * revamped GLUT
* switched to DXE3
diff --git a/include/GL/dmesa.h b/include/GL/dmesa.h
index 7e46ff2e2f..16f6bff88c 100644
--- a/include/GL/dmesa.h
+++ b/include/GL/dmesa.h
@@ -119,17 +119,24 @@ void DMesaSwapBuffers (DMesaBuffer b);
/*
- * Move/Resize Buffer.
+ * Move/Resize current Buffer.
*/
-GLboolean DMesaViewport (DMesaBuffer b,
- GLint xpos, GLint ypos,
- GLint width, GLint height);
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos);
+GLboolean DMesaResizeBuffer (GLint width, GLint height);
/*
- * Set CI color using normalized values.
+ * Set palette index, using normalized values.
*/
void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
+/*
+ * DMesa state retrieval.
+ */
+#define DMESA_Y_ORIGIN 0x0100
+#define DMESA_SCREEN_SIZE 0x0101
+#define DMESA_ARGB_ORDER 0x0200
+void DMesaGetIntegerv (GLenum pname, GLint *params);
+
#ifdef __cplusplus
}
#endif
diff --git a/progs/samples/Makefile.DJ b/progs/samples/Makefile.DJ
index 5c43b7db68..b5724f432a 100644
--- a/progs/samples/Makefile.DJ
+++ b/progs/samples/Makefile.DJ
@@ -1,36 +1,89 @@
-# $Id: Makefile.DJ,v 1.1 1999/08/19 00:55:41 jtg Exp $
-
-# Makefile for sample programs for MS-DOS with DJGPP
-
-##### MACROS #####
-
-INCDIR = ../include
-
-GL_LIBS = ../lib/dosglut.a ../lib/dosglub.a ../lib/dosmesa.a
-
-LIB_DEP = $(GL_LIBS)
-
-PROGS = accum bitmap1 bitmap2 blendeq blendxor copy depth \
- eval fog font line logo nurb olympic \
- point prim quad select shape \
- sphere star stencil stretch texture \
- tri wave
-
-##### RULES #####
-
-.c: $(LIB_DEP)
- gcc -I$(INCDIR) $(CFLAGS) $< $(LIB_DEP) -o $@
-
-
-##### TARGETS #####
-
-default: $(PROGS)
-
-clean:
- del *.
-
-realclean: clean
- del *.exe
-
-
-
+# Mesa 3-D graphics library
+# Version: 4.0
+#
+# Copyright (C) 1999 Brian Paul All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# 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 samples makefile v1.3 for Mesa 5.0
+#
+# Copyright (C) 2002 - Borca Daniel
+# Email : dborca@yahoo.com
+# Web : http://www.geocities.com/dborca
+
+
+#
+# Available options:
+#
+# Environment variables:
+# CPU optimize for the given processor.
+# default = k6
+# GLIDE path to Glide3 SDK library files; used with FX.
+# default = $(TOP)/lib/glide3
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most DMesa code and requires fxMesa.
+# As a consequence, you'll need the DJGPP Glide3
+# library to build any application.
+# default = no
+# DXE=1 use DXE modules. The resolution object file must be
+# present in the `lib' directory in order to use this
+# option (see README.DJ for details).
+# default = no
+#
+# Targets:
+# <file.exe> build a specific file
+#
+
+
+
+.PHONY : all
+.SUFFIXES : .c .o .exe
+
+TOP = ..
+CPU ?= k6
+GLIDE ?= $(TOP)/lib/glide3
+
+CC = gcc
+CFLAGS = -Wall -W -pedantic
+CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
+CFLAGS += -I$(TOP)/include
+
+LDFLAGS = -s -L$(TOP)/lib
+
+ifdef DXE
+DMESADXE = $(TOP)/lib/dmesadxe.o
+LDLIBS += -liglut -liglu -ligl
+ifdef FX
+LDFLAGS += -L$(GLIDE)
+endif
+LDLIBS += -ldl
+else
+LDLIBS = -lglut -lglu -lgl
+ifdef FX
+LDFLAGS += -L$(GLIDE)
+LDLIBS += -lglid3
+endif
+endif
+
+.c.o:
+ $(CC) -o $@ $(CFLAGS) -c $<
+.o.exe:
+ $(CC) -o $@ $(LDFLAGS) $(DMESADXE) $< $(LDLIBS)
+
+all:
+ $(error Must specify <filename.exe> to build)
diff --git a/src/glu/mesa/Makefile.DJ b/src/glu/mesa/Makefile.DJ
index e720beb1b0..6c8ec1bd5d 100644
--- a/src/glu/mesa/Makefile.DJ
+++ b/src/glu/mesa/Makefile.DJ
@@ -90,7 +90,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)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E glu -X -P gl.dxe -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
diff --git a/src/glu/sgi/Makefile.DJ b/src/glu/sgi/Makefile.DJ
index 32f05770c0..6f4bcd81c0 100644
--- a/src/glu/sgi/Makefile.DJ
+++ b/src/glu/sgi/Makefile.DJ
@@ -50,7 +50,7 @@ GLU_IMP = libiglu.a
CC = gcc
CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude
-CXX = gxx
+CXX = gpp
CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
AR = ar
@@ -174,7 +174,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)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E glu -X -P gl.dxe -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)
endif
clean:
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)
{
}
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 4541559e2c..ec9f3b2224 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -356,7 +356,7 @@ static void read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
offset = c->Buffer->width * FLIP(y) + x;
/* read all pixels */
for (i=0; i<n; i++, offset++) {
- index[i] = vl_getCIpixel(offset);
+ index[i] = vl_getpixel(offset);
}
}
@@ -421,13 +421,13 @@ static void read_index_pixels (const GLcontext *ctx,
/* read some pixels */
for (i=0; i<n; i++) {
if (mask[i]) {
- index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);
+ index[i] = vl_getpixel(FLIP2(y[i])*w + x[i]);
}
}
} else {
/* read all pixels */
for (i=0; i<n; i++) {
- index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);
+ index[i] = vl_getpixel(FLIP2(y[i])*w + x[i]);
}
}
}
@@ -1074,19 +1074,37 @@ void DMesaDestroyContext (DMesaContext c)
-GLboolean DMesaViewport (DMesaBuffer b,
- GLint xpos, GLint ypos,
- GLint width, GLint height)
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos)
{
#ifndef FX
- void *new_window;
+ GET_CURRENT_CONTEXT(ctx);
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;
- if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height)) == NULL) {
+ if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) {
return GL_FALSE;
} else {
- b->the_window = new_window;
b->xpos = xpos;
b->ypos = ypos;
+ return GL_TRUE;
+ }
+
+#else
+
+ return GL_FALSE;
+#endif
+}
+
+
+
+GLboolean DMesaResizeBuffer (GLint width, GLint height)
+{
+#ifndef FX
+ GET_CURRENT_CONTEXT(ctx);
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;
+
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) {
+ return GL_FALSE;
+ } else {
b->width = width;
b->height = height;
return GL_TRUE;
@@ -1107,7 +1125,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
{
#ifndef FX
if ((c != NULL) && (b != NULL)) {
- if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) {
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, b->width, b->height) != 0) {
return GL_FALSE;
}
@@ -1153,3 +1171,46 @@ void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue)
vl_setCI(ndx, red, green, blue);
#endif
}
+
+
+
+void DMesaGetIntegerv (GLenum pname, GLint *params)
+{
+#ifndef FX
+ GET_CURRENT_CONTEXT(ctx);
+ const DMesaContext c = (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx;
+#else
+ const fxMesaContext c = fxMesaGetCurrentContext();
+#endif
+
+ if (c == NULL) {
+ return;
+ }
+
+ switch (pname) {
+ case DMESA_Y_ORIGIN:
+ #ifndef FX
+ params[0] = GL_FALSE;
+ #else
+ params[0] = GL_TRUE;
+ #endif
+ break;
+ case DMESA_SCREEN_SIZE:
+ #ifndef FX
+ vl_get_screen_size(&params[0], &params[1]);
+ #else
+ params[0] = c->screen_width;
+ params[1] = c->screen_height;
+ #endif
+ break;
+ case DMESA_ARGB_ORDER:
+ #ifndef FX
+ params[0] = GL_FALSE;
+ #else
+ params[0] = !c->bgrOrder;
+ #endif
+ break;
+ default:
+ break;
+ }
+}
diff --git a/src/mesa/drivers/dos/vesa/vesa.c b/src/mesa/drivers/dos/vesa/vesa.c
index 26c474317f..1f3de844d7 100644
--- a/src/mesa/drivers/dos/vesa/vesa.c
+++ b/src/mesa/drivers/dos/vesa/vesa.c
@@ -32,6 +32,7 @@
#include <dpmi.h>
+#include <pc.h>
#include <stdlib.h>
#include <stubinfo.h>
#include <sys/exceptn.h>
@@ -454,22 +455,23 @@ static void vesa_restore (void)
* In : color index, R, G, B
* Out : -
*
- * Note: uses normalized values
+ * Note: uses integer values
*/
-static void vesa_setCI_f (int index, float red, float green, float blue)
+static void vesa_setCI_i (int index, int red, int green, int blue)
{
- float max = (1 << vesa_color_precision) - 1;
-
- int _red = red * max;
- int _green = green * max;
- int _blue = blue * max;
-
+#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
-"::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+#else
+ outportb(0x03C8, index);
+ outportb(0x03C9, red);
+ outportb(0x03C9, green);
+ outportb(0x03C9, blue);
+#endif
}
@@ -479,16 +481,13 @@ static void vesa_setCI_f (int index, float red, float green, float blue)
* In : color index, R, G, B
* Out : -
*
- * Note: uses integer values
+ * Note: uses normalized values
*/
-static void vesa_setCI_i (int index, int red, int green, int blue)
+static void vesa_setCI_f (int index, float red, float green, float blue)
{
- __asm("\n\
- movw $0x1010, %%ax \n\
- movb %1, %%dh \n\
- movb %2, %%ch \n\
- int $0x10 \n\
-"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+ float max = (1 << vesa_color_precision) - 1;
+
+ vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
diff --git a/src/mesa/drivers/dos/vga/vga.c b/src/mesa/drivers/dos/vga/vga.c
index 1888d98947..d1d2db51b5 100644
--- a/src/mesa/drivers/dos/vga/vga.c
+++ b/src/mesa/drivers/dos/vga/vga.c
@@ -31,6 +31,7 @@
*/
+#include <pc.h>
#include <stdlib.h>
#include "vga.h"
@@ -158,22 +159,23 @@ static void vga_restore (void)
* In : color index, R, G, B
* Out : -
*
- * Note: uses normalized values
+ * Note: uses integer values
*/
-static void vga_setCI_f (int index, float red, float green, float blue)
+static void vga_setCI_i (int index, int red, int green, int blue)
{
- float max = (1 << vga_color_precision) - 1;
-
- int _red = red * max;
- int _green = green * max;
- int _blue = blue * max;
-
+#if 0
__asm("\n\
movw $0x1010, %%ax \n\
movb %1, %%dh \n\
movb %2, %%ch \n\
int $0x10 \n\
- "::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+#else
+ outportb(0x03C8, index);
+ outportb(0x03C9, red);
+ outportb(0x03C9, green);
+ outportb(0x03C9, blue);
+#endif
}
@@ -183,16 +185,13 @@ static void vga_setCI_f (int index, float red, float green, float blue)
* In : color index, R, G, B
* Out : -
*
- * Note: uses integer values
+ * Note: uses normalized values
*/
-static void vga_setCI_i (int index, int red, int green, int blue)
+static void vga_setCI_f (int index, float red, float green, float blue)
{
- __asm("\n\
- movw $0x1010, %%ax \n\
- movb %1, %%dh \n\
- movb %2, %%ch \n\
- int $0x10 \n\
-"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");
+ float max = (1 << vga_color_precision) - 1;
+
+ vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));
}
diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c
index 5f4d9d5bed..aba99ac542 100644
--- a/src/mesa/drivers/dos/video.c
+++ b/src/mesa/drivers/dos/video.c
@@ -45,6 +45,7 @@
static vl_driver *drv;
/* based upon mode specific data: valid entire session */
int vl_video_selector;
+static vl_mode *video_mode;
static int video_scanlen, video_bypp;
/* valid until next buffer */
void *vl_current_draw_buffer, *vl_current_read_buffer;
@@ -93,6 +94,7 @@ int (*vl_mixfix) (fixed r, fixed g, fixed b);
int (*vl_mixrgb) (const unsigned char rgb[]);
int (*vl_mixrgba) (const unsigned char rgba[]);
void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
+int (*vl_getpixel) (unsigned int offset);
void (*vl_clear) (int color);
void (*vl_rect) (int x, int y, int width, int height, int color);
void (*vl_flip) (void);
@@ -243,30 +245,43 @@ static void v_getrgba32 (unsigned int offset, unsigned char rgba[4])
-/* Desc: set one palette entry
+/* Desc: pixel retrieval
*
- * In : index, R, G, B
- * Out : -
+ * In : pixel offset
+ * Out : pixel value
*
- * Note: color components are in range [0.0 .. 1.0]
+ * Note: uses current read buffer
*/
-void vl_setCI (int index, float red, float green, float blue)
+static int v_getpixel8 (unsigned int offset)
{
- drv->setCI_f(index, red, green, blue);
+ return ((word8 *)vl_current_read_buffer)[offset];
+}
+#define v_getpixel15 v_getpixel16
+static int v_getpixel16 (unsigned int offset)
+{
+ return ((word16 *)vl_current_read_buffer)[offset];
+}
+static int v_getpixel24 (unsigned int offset)
+{
+ return *(word32 *)((long)vl_current_read_buffer+offset*3);
+}
+static int v_getpixel32 (unsigned int offset)
+{
+ return ((word32 *)vl_current_read_buffer)[offset];
}
-/* Desc: read pixel from 8bit buffer
+/* Desc: set one palette entry
*
- * In : pixel offset
- * Out : pixel read
+ * In : index, R, G, B
+ * Out : -
*
- * Note: used only for CI modes
+ * Note: color components are in range [0.0 .. 1.0]
*/
-int vl_getCIpixel (unsigned int offset)
+void vl_setCI (int index, float red, float green, float blue)
{
- return ((word8 *)vl_current_read_buffer)[offset];
+ drv->setCI_f(index, red, green, blue);
}
@@ -276,7 +291,7 @@ int vl_getCIpixel (unsigned int offset)
* In : color, R, G, B
* Out : -
*
- * Note: color components are in range [0 .. 63]
+ * Note: -
*/
static void fake_setcolor (int c, int r, int g, int b)
{
@@ -326,33 +341,56 @@ static void fake_buildpalette (int bits)
/* Desc: sync buffer with video hardware
*
- * In : old buffer, position, size
- * Out : new buffer
+ * In : ptr to old buffer, position, size
+ * Out : 0 if success
*
* Note: -
*/
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height)
{
- void *newbuf;
-
- if (width&7) {
- return NULL;
+ if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {
+ return -1;
} else {
- if ((newbuf=realloc(buffer, width * height * video_bypp)) != NULL) {
- vl_current_width = width;
- vl_current_height = height;
- vl_current_stride = vl_current_width * video_bypp;
- vl_current_bytes = vl_current_stride * height;
-
- vl_current_offset = video_scanlen * y + video_bypp * x;
- vl_current_delta = video_scanlen - vl_current_stride;
+ void *newbuf = *buffer;
+
+ if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) {
+ newbuf = realloc(newbuf, width * height * video_bypp);
}
- return vl_current_draw_buffer = vl_current_read_buffer = newbuf;
+
+ if (newbuf == NULL) {
+ return -2;
+ }
+
+ vl_current_width = width;
+ vl_current_height = height;
+ vl_current_stride = vl_current_width * video_bypp;
+ vl_current_bytes = vl_current_stride * height;
+
+ vl_current_offset = video_scanlen * y + video_bypp * x;
+ vl_current_delta = video_scanlen - vl_current_stride;
+
+ vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf;
+ return 0;
}
}
+/* Desc: get screen geometry
+ *
+ * In : ptr to WIDTH, ptr to HEIGHT
+ * Out : -
+ *
+ * Note: -
+ */
+void vl_get_screen_size (int *width, int *height)
+{
+ *width = video_mode->xres;
+ *height = video_mode->yres;
+}
+
+
+
/* Desc: retrieve CPU MMX capability
*
* In : -
@@ -364,8 +402,7 @@ int vl_can_mmx (void)
{
#ifdef USE_MMX_ASM
extern int _mesa_identify_x86_cpu_features (void);
- int _mesa_x86_cpu_features = _mesa_identify_x86_cpu_features();
- return (_mesa_x86_cpu_features & 0x00800000);
+ return (_mesa_identify_x86_cpu_features() & 0x00800000);
#else
return 0;
#endif
@@ -382,9 +419,14 @@ int vl_can_mmx (void)
*/
static int vl_setup_mode (vl_mode *p)
{
+ if (p == NULL) {
+ return -1;
+ }
+
#define INITPTR(bpp) \
vl_putpixel = v_putpixel##bpp; \
vl_getrgba = v_getrgba##bpp; \
+ vl_getpixel = v_getpixel##bpp; \
vl_rect = v_rect##bpp; \
vl_mixfix = vl_mixfix##bpp; \
vl_mixrgb = vl_mixrgb##bpp; \
@@ -413,6 +455,7 @@ static int vl_setup_mode (vl_mode *p)
#undef INITPTR
+ video_mode = p;
video_bypp = (p->bpp+7)/8;
video_scanlen = p->scanlen;
vl_video_selector = p->sel;
@@ -476,8 +519,8 @@ int vl_video_init (int width, int height, int bpp, int rgb, int refresh)
}
}
- /* check, setup and enter mode */
- if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
+ /* setup and enter mode */
+ if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {
vl_flip = drv->blit;
if (fake) {
min = drv->getCIprec();
diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h
index 3197338e63..8dfb9a9176 100644
--- a/src/mesa/drivers/dos/video.h
+++ b/src/mesa/drivers/dos/video.h
@@ -45,11 +45,12 @@ extern void (*vl_clear) (int color);
extern void (*vl_rect) (int x, int y, int width, int height, int color);
extern void (*vl_flip) (void);
extern void (*vl_putpixel) (unsigned int offset, int color);
+extern int (*vl_getpixel) (unsigned int offset);
void vl_setCI (int index, float red, float green, float blue);
-int vl_getCIpixel (unsigned int offset);
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height);
+void vl_get_screen_size (int *width, int *height);
void vl_video_exit (void);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
diff --git a/src/mesa/drivers/dos/virtual.S b/src/mesa/drivers/dos/virtual.S
index 4dbbbb3e3f..c5a72975fe 100644
--- a/src/mesa/drivers/dos/virtual.S
+++ b/src/mesa/drivers/dos/virtual.S
@@ -107,13 +107,12 @@ _v_clear_common:
.p2align 5,,31
.global _v_clear8_mmx
_v_clear8_mmx:
- movl 4(%esp), %eax
- movb %al, %ah
- pushw %ax
- pushw %ax
- pushw %ax
- pushw %ax
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
+ punpcklbw %mm0, %mm0
+ punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
+#endif
/* Desc: void v_clear16_mmx (int color);
*
@@ -125,12 +124,11 @@ _v_clear8_mmx:
.p2align 5,,31
.global _v_clear16_mmx
_v_clear16_mmx:
- movl 4(%esp), %eax
- pushw %ax
- pushw %ax
- pushw %ax
- pushw %ax
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
+ punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
+#endif
/* Desc: void v_clear32_mmx (int color);
*
@@ -142,15 +140,13 @@ _v_clear16_mmx:
.p2align 5,,31
.global _v_clear32_mmx
_v_clear32_mmx:
- movl 4(%esp), %eax
- pushl %eax
- pushl %eax
+#ifdef USE_MMX_ASM
+ movq 4(%esp), %mm0
.balign 4
_v_clear_common_mmx:
-#ifdef USE_MMX_ASM
+ punpckldq %mm0, %mm0
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
- movq (%esp), %mm0
shrl $3, %ecx
.balign 4
0:
@@ -160,7 +156,6 @@ _v_clear_common_mmx:
jnz 0b
emms
#endif
- addl $8, %esp
ret
/* Desc: void v_clear24 (int color);
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
index 9bbbec6bb2..cabeff1036 100644
--- a/src/mesa/main/Makefile.DJ
+++ b/src/mesa/main/Makefile.DJ
@@ -1,7 +1,7 @@
# Mesa 3-D graphics library
-# Version: 5.1
+# Version: 4.1
#
-# Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+# Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -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 core makefile v1.3 for Mesa 5.1
+# DOS/DJGPP core makefile v1.3 for Mesa 5.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -33,18 +33,18 @@
# Environment variables:
# CFLAGS
#
-# GLIDE absolute path to Glide SDK; used with FX.
+# GLIDE path to Glide3 SDK include files; 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!
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most DMesa code and requires fxMesa.
+# As a consequence, you'll need the DJGPP Glide3
+# library to build any application.
# default = no
# HAVE_X86=1 optimize for i386.
# default = no
-# HAVE_MMX=1 MMX instructions; use only if you assembler/compiler
-# supports MMX instruction set; backwards compatibility
-# with older processors is still preserved.
+# HAVE_MMX=1 allow MMX specializations, provided your assembler
+# supports MMX instruction set. However, the true CPU
+# capabilities are checked at run-time to avoid crashes.
# default = no
# HAVE_SSE=1 (see HAVE_MMX)
# default = no
@@ -119,10 +119,6 @@ CORE_SOURCES = \
lines.c \
matrix.c \
mmath.c \
- nvprogram.c \
- nvfragparse.c \
- nvvertexec.c \
- nvvertparse.c \
pixel.c \
points.c \
polygon.c \
@@ -136,6 +132,10 @@ CORE_SOURCES = \
texstate.c \
texstore.c \
texutil.c \
+ varray.c \
+ vpexec.c \
+ vpparse.c \
+ vpstate.c \
vtxfmt.c \
math/m_debug_clip.c \
math/m_debug_norm.c \
@@ -166,7 +166,6 @@ CORE_SOURCES = \
swrast/s_lines.c \
swrast/s_logic.c \
swrast/s_masking.c \
- swrast/s_nvfragprog.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
swrast/s_readpix.c \
@@ -297,9 +296,9 @@ ifeq ($(DXE3GEN),)
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)
else
ifdef FX
- -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E gl -E DMesa -X -P glid3.dxe -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E _gl -E _DMesa -P glid3.dxe -U $(OBJECTS)
else
- -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E gl -E DMesa -X -U $(OBJECTS)
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E _gl -E _DMesa -U $(OBJECTS)
endif
endif