Environment variables:\r
CPU optimize for the given processor.\r
default = k6\r
- BIG_OPT=1 crazy optimizations; not very useful, though...\r
- default = no\r
SGI_GLU=1 build SGI's GLU instead of Mesa's.\r
default = no\r
- GLIDE absolute path to Glide library; used with FX.\r
+ GLIDE path to Glide3 SDK include files; used with FX.\r
default = $(TOP)/include/glide3\r
- FX=1 build for 3dfx Glide3; use it if you have the Glide\r
- SDK (designed for your platform), and, of course, a\r
- 3dfx card... Note that this disables compilation of\r
- actual DMesa code, as Glide does all the stuff!\r
+ FX=1 build for 3dfx Glide3. Note that this disables\r
+ compilation of most DMesa code and requires fxMesa.\r
+ As a consequence, you'll need the DJGPP Glide3\r
+ library to build any application.\r
default = no\r
HAVE_X86=1 optimize for i386.\r
default = no\r
- HAVE_MMX=1 MMX instructions; use only if you assembler/compiler\r
- supports MMX instruction set; backwards compatibility\r
- with older processors is still preserved.\r
+ HAVE_MMX=1 allow MMX specializations, provided your assembler\r
+ supports MMX instruction set. However, the true CPU\r
+ capabilities are checked at run-time to avoid crashes.\r
default = no\r
HAVE_SSE=1 (see HAVE_MMX)\r
default = no\r
CPU: K6-2 (CXT) @500(412.5) MHz\r
Mainboard: ViA Apollo VP2/97 w/ 128 MB SDRAM\r
Video card: PowerColor EvilKing3 (Voodoo3 3000 PCI) w/ 16 MB SDRAM\r
- DJGPP: djdev 2.04 + gcc v3.2 + make v3.79.1\r
+ DJGPP: djdev 2.04 + gcc v3.2.1 + make v3.79.1\r
OS: DOS and Win9x\r
\r
\r
A) Build your export object file; then link it with your application.\r
For example:\r
dxe3res -o dmesadxe.c gl.dxe glu.dxe glut.dxe\r
- gcc -o dmesadxe.o -c -fno-builtin dmesadxe.c\r
+ gcc -o dmesadxe.o -c dmesadxe.c\r
gcc -o OUT.exe dmesadxe.o IN.c -liglut -liglu -ligl -ldl\r
\r
3. Using Mesa for DJGPP\r
Glide port is on my web page. If you haven't, sorry; everything is done\r
in software. Suggestions?\r
\r
+ Q) I tried to set refresh rate w/ DMesa, but without success.\r
+ A) Refresh rate control works only for VESA 3.0. If you were compiling for\r
+ Glide, see Glide info. If not, sorry!\r
+\r
Q) I made a simple application and it does nothing. It exits right away. Not\r
even a blank screen.\r
- A) Single-buffered is not allowed at all. Until I can find a way to use\r
- *REAL* hardware acceleration, it won't get implemented.\r
+ A) Only DMesa+FX supports single-buffered. The standard VESA/VGA drivers\r
+ will always work in double-buffered modes. If/When I will find a way to\r
+ use *REAL* hardware acceleration for a specific card, it might or might\r
+ not support single-buffered modes.\r
A) Another weird "feature" is that buffer width must be multiple of 8 (I'm a\r
lazy programmer and I found that the easiest way to keep buffer handling\r
at peak performance ;-).\r
GLUT took this into account for _WIN32 DLL's only; I don't want to modify\r
his headers. The only workaround is to link GLUT the old way :-(\r
\r
- Q) I tried to set refresh rate w/ DMesa, but without success.\r
- A) Refresh rate control works only for VESA 3.0. If you were compiling for\r
- Glide, see Glide info. If not, sorry!\r
-\r
Q) The GLUT is incomplete.\r
A) See below.\r
\r
libGLUT (the toolkit):\r
~~~~~~~~~~~~~~~~~~~~~~\r
\r
-Well, this "skeletal" GLUT implementation is not mine. Thanks should go to\r
-Bernhard Tschirren, Mark Kilgard, Brian Paul and probably others (or probably\r
-not ;-). GLUT functionality will be extended only on an "as needed" basis.\r
+Well, this "skeletal" GLUT implementation was taken from AllegGL project and\r
+heavily changed. Thanks should go to Bernhard Tschirren, Mark Kilgard, Brian\r
+Paul and probably others (or probably not ;-). GLUT functionality will be\r
+extended only on an "as needed" basis.\r
+\r
+GLUT talks to hardware via PC_HW package which was put together from various\r
+pieces I wrote long time ago. It consists from the keyboard, mouse and timer\r
+drivers.\r
\r
My keyboard driver used only scancodes; as GLUT requires ASCII values for keys,\r
I borrowed the translation tables (and maybe more) from Allegro -- many thanks\r
know, because all messages come in bulk, but I think it's better than nothing.\r
"Borrowed" from LIBRHUTI (Robert Hoehne).\r
\r
-Window creating defaults: 640x480x16 at (0,0), 8-bit stencil, 16-bit accum.\r
-However, the video mode is chosen in such a way that first window will fit. If\r
-you need high resolution with small windows, try to place them far to the right\r
-(or way down).\r
+Window creating defaults: 300x300x16 at (0,0), 16-bit depth, 16-bit accum,\r
+8-bit stencil. However, the video mode is chosen in such a way that first\r
+window will fit. If you need high resolution with small windows, set initial\r
+position far to the right (or way down); then you can move them back to any\r
+position right before the main loop.\r
\r
The following environment variables can customize GLUT behaviour:\r
- DMESA_GLUT_REFRESH - set vertical screen refresh rate\r
- DMESA_GLUT_BPP - set default bits per pixel\r
+ DMESA_GLUT_REFRESH - set vertical screen refresh rate (VESA3)\r
+ DMESA_GLUT_BPP - set default bits per pixel (VGA needs 8)\r
\r
\r
\r
* synced w/ Mesa-4.1\r
- removed dmesadxe.h\r
\r
-v1.3 (dec-2002)\r
+v1.3 (jan-2003)\r
+ enabled OpenGL 1.4 support\r
+ added MMX clear/blit routines\r
+ enabled SGI's GLU compilation\r
+ + added new GLUT functions\r
+ added color-index modes\r
+ added 8bit FakeColor (thanks to Neil Funk)\r
+ added VGA support (to keep Ben Decker happy)\r
* fixed GLUT compilation error (reported by Chan Kar Heng)\r
* overhauled virtual buffer and internal video drivers\r
* better fxMesa integration\r
- * extended GLUT functionality\r
+ * revamped GLUT\r
* switched to DXE3\r
\r
\r
\r
\r
/*\r
- * Move/Resize Buffer.\r
+ * Move/Resize current Buffer.\r
*/\r
-GLboolean DMesaViewport (DMesaBuffer b,\r
- GLint xpos, GLint ypos,\r
- GLint width, GLint height);\r
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos);\r
+GLboolean DMesaResizeBuffer (GLint width, GLint height);\r
\r
/*\r
- * Set CI color using normalized values.\r
+ * Set palette index, using normalized values.\r
*/\r
void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);\r
\r
+/*\r
+ * DMesa state retrieval.\r
+ */\r
+#define DMESA_Y_ORIGIN 0x0100\r
+#define DMESA_SCREEN_SIZE 0x0101\r
+#define DMESA_ARGB_ORDER 0x0200\r
+void DMesaGetIntegerv (GLenum pname, GLint *params);\r
+\r
#ifdef __cplusplus\r
}\r
#endif\r
-# $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\r
+# Version: 4.0\r
+# \r
+# Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+# \r
+# Permission is hereby granted, free of charge, to any person obtaining a\r
+# copy of this software and associated documentation files (the "Software"),\r
+# to deal in the Software without restriction, including without limitation\r
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+# and/or sell copies of the Software, and to permit persons to whom the\r
+# Software is furnished to do so, subject to the following conditions:\r
+# \r
+# The above copyright notice and this permission notice shall be included\r
+# in all copies or substantial portions of the Software.\r
+# \r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+# DOS/DJGPP samples makefile v1.3 for Mesa 5.0\r
+#\r
+# Copyright (C) 2002 - Borca Daniel\r
+# Email : dborca@yahoo.com\r
+# Web : http://www.geocities.com/dborca\r
+\r
+\r
+#\r
+# Available options:\r
+#\r
+# Environment variables:\r
+# CPU optimize for the given processor.\r
+# default = k6\r
+# GLIDE path to Glide3 SDK library files; used with FX.\r
+# default = $(TOP)/lib/glide3\r
+# FX=1 build for 3dfx Glide3. Note that this disables\r
+# compilation of most DMesa code and requires fxMesa.\r
+# As a consequence, you'll need the DJGPP Glide3\r
+# library to build any application.\r
+# default = no\r
+# DXE=1 use DXE modules. The resolution object file must be\r
+# present in the `lib' directory in order to use this\r
+# option (see README.DJ for details).\r
+# default = no\r
+#\r
+# Targets:\r
+# <file.exe> build a specific file\r
+#\r
+\r
+\r
+\r
+.PHONY : all\r
+.SUFFIXES : .c .o .exe\r
+\r
+TOP = ..\r
+CPU ?= k6\r
+GLIDE ?= $(TOP)/lib/glide3\r
+\r
+CC = gcc\r
+CFLAGS = -Wall -W -pedantic\r
+CFLAGS += -O2 -ffast-math -mcpu=$(CPU)\r
+CFLAGS += -I$(TOP)/include\r
+\r
+LDFLAGS = -s -L$(TOP)/lib\r
+\r
+ifdef DXE\r
+DMESADXE = $(TOP)/lib/dmesadxe.o\r
+LDLIBS += -liglut -liglu -ligl\r
+ifdef FX\r
+LDFLAGS += -L$(GLIDE)\r
+endif\r
+LDLIBS += -ldl\r
+else\r
+LDLIBS = -lglut -lglu -lgl\r
+ifdef FX\r
+LDFLAGS += -L$(GLIDE)\r
+LDLIBS += -lglid3\r
+endif\r
+endif\r
+\r
+.c.o:\r
+ $(CC) -o $@ $(CFLAGS) -c $<\r
+.o.exe:\r
+ $(CC) -o $@ $(LDFLAGS) $(DMESADXE) $< $(LDLIBS)\r
+\r
+all:\r
+ $(error Must specify <filename.exe> to build)\r
$(warning Missing DXE3GEN and/or DXE3.LD! You must have DXE3GEN)\r
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)\r
else\r
- -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E glu -X -P gl.dxe -U $(OBJECTS)\r
+ -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)\r
endif\r
\r
clean:\r
\r
CC = gcc\r
CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude\r
-CXX = gxx\r
+CXX = gpp\r
CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess\r
\r
AR = ar\r
$(warning Missing DXE3GEN and/or DXE3.LD! You must have DXE3GEN)\r
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)\r
else\r
- -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E glu -X -P gl.dxe -U $(OBJECTS)\r
+ -dxe3gen -o $(LIBDIR)/$(GLU_DXE) -I $(LIBDIR)/$(GLU_IMP) -D "MesaGLU/SGI DJGPP" -E _glu -P gl.dxe -U $(OBJECTS)\r
endif\r
\r
clean:\r
GLUT_IMP = libiglut.a\r
\r
CC = gcc\r
-CFLAGS += -I$(TOP)/include -I$(MKGLUT)\r
+CFLAGS += -I- -I$(TOP)/include -I. -I$(MKGLUT) -IPC_HW\r
\r
AR = ar\r
-ARFLAGS = ru\r
+ARFLAGS = rus\r
\r
ifneq ($(wildcard $(DJDIR)/lib/dxe3.ld),)\r
DXE3GEN = $(wildcard $(addsuffix /dxe3gen.exe,$(subst ;, ,$(PATH))))\r
RM = del\r
\r
CORE_SOURCES = \\r
- bitmap.c \\r
callback.c \\r
color.c \\r
- globals.c \\r
+ extens.c \\r
init.c \\r
menu.c \\r
- models.c \\r
+ mouse.c \\r
overlay.c \\r
state.c \\r
- teapot.c \\r
window.c\r
\r
PC_HW_SOURCES = \\r
PC_HW/pc_irq.S\r
\r
MKGLUT_SOURCES = \\r
+ $(MKGLUT)/glut_bitmap.c \\r
+ $(MKGLUT)/glut_bwidth.c \\r
+ $(MKGLUT)/glut_stroke.c \\r
+ $(MKGLUT)/glut_swidth.c \\r
+ $(MKGLUT)/glut_shapes.c \\r
+ $(MKGLUT)/glut_teapot.c \\r
$(MKGLUT)/glut_8x13.c \\r
$(MKGLUT)/glut_9x15.c \\r
$(MKGLUT)/glut_hel10.c \\r
$(MKGLUT)/glut_hel12.c \\r
$(MKGLUT)/glut_hel18.c \\r
$(MKGLUT)/glut_tr10.c \\r
- $(MKGLUT)/glut_tr24.c\r
+ $(MKGLUT)/glut_tr24.c \\r
+ $(MKGLUT)/glut_roman.c \\r
+ $(MKGLUT)/glut_mroman.c \\r
+ $(MKGLUT)/glut_util.c\r
\r
SOURCES = $(CORE_SOURCES) $(PC_HW_SOURCES) $(MKGLUT_SOURCES)\r
\r
$(warning Missing DXE3GEN and/or DXE3.LD! You must have DXE3GEN)\r
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)\r
else\r
- -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E glut -X -P gl.dxe -P glu.dxe -U $(OBJECTS)\r
+ -dxe3gen -o $(LIBDIR)/$(GLUT_DXE) -I $(LIBDIR)/$(GLUT_IMP) -D "MesaGLUT DJGPP" -E _glut -P gl.dxe -P glu.dxe -U $(OBJECTS)\r
endif\r
\r
clean:\r
/*\r
* standard redirection\r
*/\r
-#define STDOUT 1\r
-#define STDERR 2\r
-\r
static char outname[L_tmpnam];\r
static int h_out, h_outbak;\r
static char errname[L_tmpnam];\r
tmpnam(outname);\r
\r
if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {\r
- h_outbak = dup(STDOUT);\r
+ h_outbak = dup(STDOUT_FILENO);\r
fflush(stdout);\r
- dup2(h_out, STDOUT);\r
+ dup2(h_out, STDOUT_FILENO);\r
}\r
\r
return h_out;\r
char *line = alloca(512);\r
\r
if (h_out > 0) {\r
- dup2(h_outbak, STDOUT);\r
+ dup2(h_outbak, STDOUT_FILENO);\r
close(h_out);\r
close(h_outbak);\r
\r
tmpnam(errname);\r
\r
if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) {\r
- h_errbak = dup(STDERR);\r
+ h_errbak = dup(STDERR_FILENO);\r
fflush(stderr);\r
- dup2(h_err, STDERR);\r
+ dup2(h_err, STDERR_FILENO);\r
}\r
\r
return h_err;\r
char *line = alloca(512);\r
\r
if (h_err > 0) {\r
- dup2(h_errbak, STDERR);\r
+ dup2(h_errbak, STDERR_FILENO);\r
close(h_err);\r
close(h_errbak);\r
\r
/*\r
- * PC/HW routine collection v1.2 for DOS/DJGPP\r
+ * PC/HW routine collection v1.3 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
#define ENDOFUNC(x) static void x##_end() { }\r
#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)\r
#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))\r
+#define LOCKBUFF(x, l) _go32_dpmi_lock_data((void *)x, l)\r
\r
void *pc_malloc (size_t size);\r
\r
int pc_keypressed (void);\r
int pc_readkey (void);\r
int pc_keydown (int code);\r
+int pc_keyshifts (void);\r
\r
/*\r
* timer\r
void pc_mouse_area (int x1, int y1, int x2, int y2);\r
void pc_mouse_speed (int xspeed, int yspeed);\r
int pc_query_mouse (int *x, int *y);\r
-void pc_show_mouse (void);\r
-void pc_scare_mouse (void);\r
-void pc_unscare_mouse (void);\r
\r
/*\r
* standard redirection\r
/*\r
- * PC/HW routine collection v1.1 for DOS/DJGPP\r
+ * PC/HW routine collection v1.3 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
return pc_key[code];\r
}\r
\r
+int pc_keyshifts (void)\r
+{\r
+ return key_shifts;\r
+}\r
+\r
void pc_remove_keyb (void)\r
{\r
if (keyboard_installed) {\r
/*\r
- * PC/HW routine collection v1.2 for DOS/DJGPP\r
+ * PC/HW routine collection v1.3 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
return pc_mouse_b;\r
}\r
\r
-void pc_show_mouse (void)\r
-{\r
- /* not implemented */\r
-}\r
-void pc_scare_mouse (void)\r
-{\r
- /* not implemented */\r
-}\r
-void pc_unscare_mouse (void)\r
-{\r
- /* not implemented */\r
-}\r
-\r
__asm("\n\\r
.text \n\\r
- .balign 4 \n\\r
+ .p2align 5,,31 \n\\r
.global _mouse_wrapper \n\\r
_mouse_wrapper: \n\\r
cld \n\\r
/*\r
- * PC/HW routine collection v1.0 for DOS/DJGPP\r
+ * PC/HW routine collection v1.3 for DOS/DJGPP\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
volatile void *parm;\r
} TIMER;\r
\r
-TIMER timer_main, timer_func[MAX_TIMERS];\r
+static TIMER timer_main, timer_func[MAX_TIMERS];\r
\r
static int timer ()\r
{\r
*/\r
\r
/*\r
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
*/\r
\r
\r
-#include "GL/glut.h"\r
-#include "internal.h"\r
+#include "glutint.h"\r
\r
\r
-void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))\r
-{\r
- display_func = func;\r
-}\r
\r
+GLUTidleCB g_idle_func = NULL;\r
\r
-void APIENTRY glutReshapeFunc (void (GLUTCALLBACK *func) (int width, int height))\r
-{\r
- reshape_func = func;\r
-}\r
\r
\r
-void APIENTRY glutKeyboardFunc (void (GLUTCALLBACK *func) (unsigned char key, int x, int y))\r
+void APIENTRY glutDisplayFunc (GLUTdisplayCB func)\r
{\r
- keyboard_func = func;\r
+ g_curwin->display = func;\r
}\r
\r
\r
-void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))\r
+\r
+void APIENTRY glutReshapeFunc (GLUTreshapeCB func)\r
{\r
- mouse_func = func;\r
+ g_curwin->reshape = func;\r
}\r
\r
\r
-void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+\r
+void APIENTRY glutKeyboardFunc (GLUTkeyboardCB func)\r
{\r
- motion_func = func;\r
+ g_curwin->keyboard = func;\r
}\r
\r
\r
-void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+\r
+void APIENTRY glutMouseFunc (GLUTmouseCB func)\r
{\r
- passive_motion_func = func;\r
+ g_curwin->mouse = func;\r
}\r
\r
\r
-void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))\r
+\r
+void APIENTRY glutMotionFunc (GLUTmotionCB func)\r
{\r
- entry_func = func;\r
+ g_curwin->motion = func;\r
}\r
\r
\r
-void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))\r
+\r
+void APIENTRY glutPassiveMotionFunc (GLUTpassiveCB func)\r
{\r
- visibility_func = func;\r
+ g_curwin->passive = func;\r
}\r
\r
\r
-void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))\r
+\r
+void APIENTRY glutEntryFunc (GLUTentryCB func)\r
{\r
- idle_func = func;\r
+ g_curwin->entry = func;\r
}\r
\r
\r
-void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)\r
+\r
+void APIENTRY glutVisibilityFunc (GLUTvisibilityCB func)\r
{\r
+ g_curwin->visibility = func;\r
}\r
\r
\r
-void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))\r
+\r
+void APIENTRY glutWindowStatusFunc (GLUTwindowStatusCB func)\r
{\r
- menu_state_func = func;\r
}\r
\r
\r
-void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))\r
+\r
+void APIENTRY glutIdleFunc (GLUTidleCB func)\r
{\r
- special_func = func;\r
+ g_idle_func = func;\r
}\r
\r
\r
-void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))\r
+\r
+void APIENTRY glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)\r
{\r
}\r
\r
\r
-void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))\r
+\r
+void APIENTRY glutSpecialFunc (GLUTspecialCB func)\r
{\r
+ g_curwin->special = func;\r
}\r
\r
\r
-void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))\r
+\r
+void APIENTRY glutSpaceballMotionFunc (GLUTspaceMotionCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))\r
+\r
+void APIENTRY glutSpaceballRotateFunc (GLUTspaceRotateCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))\r
+\r
+void APIENTRY glutSpaceballButtonFunc (GLUTspaceButtonCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+\r
+void APIENTRY glutDialsFunc (GLUTdialsCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))\r
+\r
+void APIENTRY glutButtonBoxFunc (GLUTbuttonBoxCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))\r
+\r
+void APIENTRY glutTabletMotionFunc (GLUTtabletMotionCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))\r
+\r
+void APIENTRY glutTabletButtonFunc (GLUTtabletButtonCB func)\r
{\r
}\r
\r
\r
-void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))\r
+\r
+void APIENTRY glutJoystickFunc (GLUTjoystickCB func, int interval)\r
{\r
}\r
*/\r
\r
\r
-#include "GL/glut.h"\r
+#include "glutint.h"\r
#include "GL/dmesa.h"\r
-#include "internal.h"\r
\r
\r
\r
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)\r
{\r
if (g_display_mode & GLUT_INDEX) {\r
- DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));\r
+ if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) {\r
+ DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue));\r
+ }\r
}\r
}\r
\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <string.h>\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+\r
+int APIENTRY glutExtensionSupported (const char *extension)\r
+{\r
+ static const GLubyte *extensions = NULL;\r
+ const GLubyte *last, *where;\r
+\r
+ /* Extension names should not have spaces. */\r
+ if (strchr(extension, ' ') || *extension == '\0') {\r
+ return GL_FALSE;\r
+ }\r
+\r
+ /* Not my problem if you don't have a valid OpenGL context */\r
+ if (!extensions) {\r
+ extensions = glGetString(GL_EXTENSIONS);\r
+ }\r
+\r
+ /* Take care of sub-strings etc. */\r
+ for (last = extensions;;) {\r
+ if ((where = (GLubyte *)strstr((const char *)last, extension)) == NULL) {\r
+ return GL_FALSE;\r
+ }\r
+ last = where + strlen(extension);\r
+ if (where == extensions || *(where - 1) == ' ') {\r
+ if (*last == ' ' || *last == '\0') {\r
+ return GL_TRUE;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+ \r
+#ifndef __glutint_h__\r
+#define __glutint_h__\r
+\r
+#include <GL/glut.h>\r
+\r
+#include "GL/dmesa.h"\r
+\r
+\r
+\r
+/* GLUT function types */\r
+typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);\r
+typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);\r
+typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTentryCB) (int);\r
+typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);\r
+typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);\r
+typedef void (GLUTCALLBACK *GLUTidleCB) (void);\r
+typedef void (GLUTCALLBACK *GLUTtimerCB) (int);\r
+typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int); /* DEPRECATED. */\r
+typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTselectCB) (int);\r
+typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);\r
+typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);\r
+typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int, int, int, int);\r
+\r
+typedef struct GLUTwindow {\r
+ int num; /* window id */\r
+\r
+ DMesaBuffer buffer;\r
+\r
+ int show_mouse;\r
+\r
+ /* GLUT settable or visible window state. */\r
+ int xpos;\r
+ int ypos;\r
+ int width; /* window width in pixels */\r
+ int height; /* window height in pixels */\r
+\r
+ /* Per-window callbacks. */\r
+ GLUTdisplayCB display; /* redraw */\r
+ GLUTreshapeCB reshape; /* resize (width,height) */\r
+ GLUTmouseCB mouse; /* mouse (button,state,x,y) */\r
+ GLUTmotionCB motion; /* motion (x,y) */\r
+ GLUTpassiveCB passive; /* passive motion (x,y) */\r
+ GLUTentryCB entry; /* window entry/exit (state) */\r
+ GLUTkeyboardCB keyboard; /* keyboard (ASCII,x,y) */\r
+ GLUTkeyboardCB keyboardUp; /* keyboard up (ASCII,x,y) */\r
+ GLUTwindowStatusCB windowStatus; /* window status */\r
+ GLUTvisibilityCB visibility; /* visibility */\r
+ GLUTspecialCB special; /* special key */\r
+ GLUTspecialCB specialUp; /* special up key */\r
+ GLUTbuttonBoxCB buttonBox; /* button box */\r
+ GLUTdialsCB dials; /* dials */\r
+ GLUTspaceMotionCB spaceMotion; /* Spaceball motion */\r
+ GLUTspaceRotateCB spaceRotate; /* Spaceball rotate */\r
+ GLUTspaceButtonCB spaceButton; /* Spaceball button */\r
+ GLUTtabletMotionCB tabletMotion; /* tablet motion */\r
+ GLUTtabletButtonCB tabletButton; /* tablet button */\r
+ GLUTjoystickCB joystick; /* joystick */\r
+} GLUTwindow;\r
+\r
+extern GLUTidleCB g_idle_func;\r
+extern GLUTmenuStatusCB g_menu_status_func;\r
+\r
+extern GLboolean g_redisplay;\r
+\r
+extern GLuint g_bpp; /* HW: bits per pixel */\r
+extern GLuint g_refresh; /* HW: vertical refresh rate */\r
+extern GLuint g_screen_w, g_screen_h; /* HW: physical screen size */\r
+\r
+extern GLuint g_display_mode; /* display bits */\r
+extern int g_init_x, g_init_y; /* initial window position */\r
+extern GLuint g_init_w, g_init_h; /* initial window size */\r
+\r
+extern int g_mouse; /* non-zero if mouse installed */\r
+extern int g_mouse_x, g_mouse_y; /* mouse coords, relative to current win */\r
+\r
+extern GLUTwindow *g_curwin; /* current window */\r
+\r
+extern char *__glutProgramName; /* program name */\r
+\r
+extern void __glutInitMouse (void);\r
+\r
+/* private routines from glut_util.c */\r
+extern char * __glutStrdup(const char *string);\r
+extern void __glutWarning(char *format,...);\r
+extern void __glutFatalError(char *format,...);\r
+extern void __glutFatalUsage(char *format,...);\r
+\r
+\r
+\r
+/* hmmm... */\r
+#include "pc_hw/pc_hw.h"\r
+\r
+\r
+\r
+#define MAX_WINDOWS 2\r
+\r
+#define DEFAULT_WIDTH 300\r
+#define DEFAULT_HEIGHT 300\r
+#define DEFAULT_BPP 16\r
+\r
+#define DEPTH_SIZE 16\r
+#define STENCIL_SIZE 8\r
+#define ACCUM_SIZE 16\r
+\r
+#define RESERVED_COLORS 0\r
+\r
+#endif /* __glutint_h__ */\r
*/\r
\r
\r
-#include "GL/glut.h"\r
-#include "internal.h"\r
+#include <string.h>\r
\r
+#include "glutint.h"\r
\r
-void APIENTRY glutInit (int *argcp, char **argv)\r
+\r
+\r
+GLboolean g_redisplay = GL_FALSE;\r
+\r
+GLuint g_bpp = DEFAULT_BPP;\r
+GLuint g_refresh = 0;\r
+GLuint g_screen_w, g_screen_h;\r
+\r
+GLuint g_display_mode = 0;\r
+int g_init_x = 0, g_init_y = 0;\r
+GLuint g_init_w = DEFAULT_WIDTH, g_init_h = DEFAULT_HEIGHT;\r
+\r
+char *__glutProgramName = NULL;\r
+\r
+\r
+\r
+void APIENTRY glutInit (int *argc, char **argv)\r
{\r
+ char *str;\r
const char *env;\r
\r
if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {\r
g_refresh = atoi(env);\r
}\r
\r
+ /* Determine program name. */\r
+ str = strrchr(argv[0], '/');\r
+ if (str == NULL) {\r
+ str = argv[0];\r
+ } else {\r
+ str++;\r
+ }\r
+ __glutProgramName = __glutStrdup(str);\r
+\r
+ /* Initialize timer */\r
glutGet(GLUT_ELAPSED_TIME);\r
}\r
\r
\r
+\r
void APIENTRY glutInitDisplayMode (unsigned int mode)\r
{\r
g_display_mode = mode;\r
-\r
- pc_install_keyb();\r
- g_mouse = pc_install_mouse();\r
}\r
\r
\r
+\r
void APIENTRY glutInitWindowPosition (int x, int y)\r
{\r
- g_xpos = x;\r
- g_ypos = y;\r
+ g_init_x = x;\r
+ g_init_y = y;\r
}\r
\r
\r
+\r
void APIENTRY glutInitWindowSize (int width, int height)\r
{\r
- g_width = width;\r
- g_height = height;\r
+ g_init_w = width;\r
+ g_init_h = height;\r
}\r
\r
\r
+\r
void APIENTRY glutMainLoop (void)\r
{\r
GLboolean idle;\r
static int old_mouse_y = 0;\r
static int old_mouse_b = 0;\r
\r
+ {\r
+ GLint screen_size[2];\r
+ DMesaGetIntegerv(DMESA_SCREEN_SIZE, screen_size);\r
+ g_screen_w = screen_size[0];\r
+ g_screen_h = screen_size[1];\r
+ }\r
+\r
+ pc_install_keyb();\r
+ __glutInitMouse();\r
+\r
glutPostRedisplay();\r
- if (reshape_func) reshape_func(g_width, g_height);\r
- if (visibility_func) visibility_func(GLUT_VISIBLE);\r
- if (g_mouse) pc_show_mouse();\r
+ if (g_curwin->reshape) {\r
+ g_curwin->reshape(g_curwin->width, g_curwin->height);\r
+ }\r
+ if (g_curwin->visibility) {\r
+ g_curwin->visibility(GLUT_VISIBLE);\r
+ }\r
\r
while (GL_TRUE) {\r
idle = GL_TRUE;\r
\r
- if (g_redisplay && display_func) {\r
+ if (g_redisplay && g_curwin->display) {\r
idle = GL_FALSE;\r
g_redisplay = GL_FALSE;\r
\r
- if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse();\r
- display_func();\r
- if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse();\r
- }\r
-\r
- if (pc_keypressed()) {\r
- int key;\r
-\r
- idle = GL_FALSE;\r
- key = pc_readkey();\r
-\r
- switch (key>>16) {\r
- case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break;\r
- case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break;\r
- case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break;\r
- case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break;\r
- case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break;\r
- case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break;\r
- case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break;\r
- case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break;\r
- case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break;\r
- case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break;\r
- case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break;\r
- case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break;\r
- case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break;\r
- case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break;\r
- case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break;\r
- case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break;\r
- case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break;\r
- case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break;\r
- case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break;\r
- case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break;\r
- case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break;\r
- default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0);\r
+ if (g_curwin->show_mouse && !(g_display_mode & GLUT_DOUBLE)) {\r
+ /* XXX scare mouse */\r
+ g_curwin->display();\r
+ /* XXX unscare mouse */\r
+ } else {\r
+ g_curwin->display();\r
}\r
}\r
\r
int mouse_x;\r
int mouse_y;\r
int mouse_b;\r
- \r
+\r
+ /* query mouse */\r
mouse_b = pc_query_mouse(&mouse_x, &mouse_y);\r
- \r
- if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) {\r
+\r
+ /* relative to window coordinates */\r
+ g_mouse_x = mouse_x - g_curwin->xpos;\r
+ g_mouse_y = mouse_y - g_curwin->ypos;\r
+\r
+ /* mouse was moved? */\r
+ if ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y)) {\r
idle = GL_FALSE;\r
old_mouse_x = mouse_x;\r
old_mouse_y = mouse_y;\r
- \r
- motion_func(old_mouse_x, old_mouse_y);\r
+\r
+ if (mouse_b) {\r
+ /* any button pressed */\r
+ if (g_curwin->motion) {\r
+ g_curwin->motion(g_mouse_x, g_mouse_y);\r
+ }\r
+ } else {\r
+ /* no button pressed */\r
+ if (g_curwin->passive) {\r
+ g_curwin->passive(g_mouse_x, g_mouse_y);\r
+ }\r
+ }\r
}\r
- \r
- if (mouse_func && (mouse_b != old_mouse_b)) {\r
- int new_mouse_b = mouse_b;\r
- \r
- if ((old_mouse_b & 1) && !(new_mouse_b & 1))\r
- mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y);\r
- else if (!(old_mouse_b & 1) && (new_mouse_b & 1))\r
- mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);\r
- \r
- if ((old_mouse_b & 2) && !(new_mouse_b & 2))\r
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y);\r
- else if (!(old_mouse_b & 2) && (new_mouse_b & 2))\r
- mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);\r
- \r
- if ((old_mouse_b & 4) && !(new_mouse_b & 4))\r
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y);\r
- else if (!(old_mouse_b & 3) && (new_mouse_b & 4))\r
- mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y);\r
- \r
+\r
+ /* button state changed? */\r
+ if (mouse_b != old_mouse_b) {\r
+ GLUTmouseCB mouse_func;\r
+\r
+ if ((mouse_func = g_curwin->mouse)) {\r
+ if ((old_mouse_b & 1) && !(mouse_b & 1))\r
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);\r
+ else if (!(old_mouse_b & 1) && (mouse_b & 1))\r
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);\r
+\r
+ if ((old_mouse_b & 2) && !(mouse_b & 2))\r
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);\r
+ else if (!(old_mouse_b & 2) && (mouse_b & 2))\r
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);\r
+\r
+ if ((old_mouse_b & 4) && !(mouse_b & 4))\r
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, g_mouse_x, g_mouse_y);\r
+ else if (!(old_mouse_b & 3) && (mouse_b & 4))\r
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, g_mouse_x, g_mouse_y);\r
+ }\r
+\r
idle = GL_FALSE;\r
- old_mouse_b = new_mouse_b;\r
+ old_mouse_b = mouse_b;\r
+ }\r
+ }\r
+\r
+ if (pc_keypressed()) {\r
+ int key;\r
+ int glut_key;\r
+\r
+ idle = GL_FALSE;\r
+ key = pc_readkey();\r
+\r
+ switch (key>>16) {\r
+ case KEY_F1: glut_key = GLUT_KEY_F1; goto special;\r
+ case KEY_F2: glut_key = GLUT_KEY_F2; goto special;\r
+ case KEY_F3: glut_key = GLUT_KEY_F3; goto special;\r
+ case KEY_F4: glut_key = GLUT_KEY_F4; goto special;\r
+ case KEY_F5: glut_key = GLUT_KEY_F5; goto special;\r
+ case KEY_F6: glut_key = GLUT_KEY_F6; goto special;\r
+ case KEY_F7: glut_key = GLUT_KEY_F7; goto special;\r
+ case KEY_F8: glut_key = GLUT_KEY_F8; goto special;\r
+ case KEY_F9: glut_key = GLUT_KEY_F9; goto special;\r
+ case KEY_F10: glut_key = GLUT_KEY_F10; goto special;\r
+ case KEY_F11: glut_key = GLUT_KEY_F11; goto special;\r
+ case KEY_F12: glut_key = GLUT_KEY_F12; goto special;\r
+ case KEY_LEFT: glut_key = GLUT_KEY_LEFT; goto special;\r
+ case KEY_UP: glut_key = GLUT_KEY_UP; goto special;\r
+ case KEY_RIGHT: glut_key = GLUT_KEY_RIGHT; goto special;\r
+ case KEY_DOWN: glut_key = GLUT_KEY_DOWN; goto special;\r
+ case KEY_PGUP: glut_key = GLUT_KEY_PAGE_UP; goto special;\r
+ case KEY_PGDN: glut_key = GLUT_KEY_PAGE_DOWN; goto special;\r
+ case KEY_HOME: glut_key = GLUT_KEY_HOME; goto special;\r
+ case KEY_END: glut_key = GLUT_KEY_END; goto special;\r
+ case KEY_INSERT: glut_key = GLUT_KEY_INSERT; goto special;\r
+ special:\r
+ if (g_curwin->special) {\r
+ g_curwin->special(glut_key, g_mouse_x, g_mouse_y);\r
+ }\r
+ break;\r
+ default:\r
+ if (g_curwin->keyboard) {\r
+ g_curwin->keyboard(key & 0xFF, g_mouse_x, g_mouse_y);\r
+ }\r
}\r
}\r
\r
- if (idle && idle_func)\r
- idle_func();\r
+ if (idle && g_idle_func)\r
+ g_idle_func();\r
}\r
}\r
*/\r
\r
/*\r
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
*/\r
\r
\r
-#include "GL/glut.h"\r
+#include "glutint.h"\r
\r
\r
-int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))\r
+\r
+GLUTmenuStatusCB g_menu_status_func = NULL;\r
+\r
+\r
+\r
+void APIENTRY glutMenuStateFunc (GLUTmenuStateCB func)\r
+{\r
+ g_menu_status_func = (GLUTmenuStatusCB)func;\r
+}\r
+\r
+\r
+\r
+void APIENTRY glutMenuStatusFunc (GLUTmenuStatusCB func)\r
+{\r
+ g_menu_status_func = func;\r
+}\r
+\r
+\r
+\r
+int APIENTRY glutCreateMenu (GLUTselectCB func)\r
{\r
return 0;\r
}\r
\r
+\r
+\r
void APIENTRY glutDestroyMenu (int menu)\r
{\r
}\r
\r
\r
+\r
int APIENTRY glutGetMenu (void)\r
{\r
return 0;\r
}\r
\r
\r
+\r
void APIENTRY glutSetMenu (int menu)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutAddMenuEntry (const char *label, int value)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutAddSubMenu (const char *label, int submenu)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutRemoveMenuItem (int item)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutAttachMenu (int button)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutDetachMenu (int button)\r
{\r
}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "glutint.h"\r
+\r
+\r
+\r
+int g_mouse;\r
+int g_mouse_x = 0, g_mouse_y = 0;\r
+\r
+\r
+\r
+void __glutInitMouse (void)\r
+{\r
+ if ((g_mouse = pc_install_mouse())) {\r
+ GLint yorg;\r
+ GLint rect[4];\r
+\r
+ DMesaGetIntegerv(DMESA_Y_ORIGIN, &yorg);\r
+ if (yorg) {\r
+ rect[1] = g_screen_h - g_curwin->height;\r
+ } else {\r
+ rect[1] = g_curwin->ypos;\r
+ }\r
+ rect[0] = g_curwin->xpos;\r
+ rect[2] = rect[0] + g_curwin->width - 1;\r
+ rect[3] = rect[1] + g_curwin->height - 1;\r
+ pc_mouse_area(rect[0], rect[1], rect[2], rect[3]);\r
+\r
+ g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive);\r
+ }\r
+}\r
*/\r
\r
/*\r
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP glut driver v1.3 for Mesa 5.0\r
*\r
* Copyright (C) 2002 - Borca Daniel\r
* Email : dborca@yahoo.com\r
*/\r
\r
\r
-#include "GL/glut.h"\r
+#include "glutint.h"\r
+\r
+\r
+\r
+int APIENTRY glutLayerGet (GLenum info)\r
+{\r
+ switch (info) {\r
+ case GLUT_OVERLAY_POSSIBLE:\r
+ case GLUT_HAS_OVERLAY:\r
+ return GL_FALSE;\r
+ case GLUT_LAYER_IN_USE:\r
+ return GLUT_NORMAL;\r
+ case GLUT_NORMAL_DAMAGED:\r
+ return GL_FALSE;\r
+ case GLUT_OVERLAY_DAMAGED:\r
+ case GLUT_TRANSPARENT_INDEX:\r
+ default:\r
+ return -1;\r
+ }\r
+}\r
+\r
+\r
+\r
+void APIENTRY glutOverlayDisplayFunc (GLUTdisplayCB func)\r
+{\r
+}\r
+\r
\r
\r
void APIENTRY glutEstablishOverlay (void)\r
}\r
\r
\r
+\r
void APIENTRY glutRemoveOverlay (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutUseLayer (GLenum layer)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutPostOverlayRedisplay (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutShowOverlay (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutHideOverlay (void)\r
{\r
}\r
*/\r
\r
\r
-#include "GL/glut.h"\r
-#include "internal.h"\r
+#include "glutint.h"\r
+\r
\r
\r
#define FREQUENCY 100\r
\r
\r
+\r
static int timer_installed;\r
static volatile int ticks;\r
\r
+\r
+\r
static void ticks_timer (void *p)\r
{\r
(void)p;\r
int APIENTRY glutGet (GLenum type)\r
{\r
switch (type) {\r
- case GLUT_WINDOW_COLORMAP_SIZE:\r
- return (g_display_mode & GLUT_INDEX) ? 256 : 0;\r
+ case GLUT_WINDOW_X:\r
+ return g_curwin->xpos;\r
+ case GLUT_WINDOW_Y:\r
+ return g_curwin->ypos;\r
+ case GLUT_WINDOW_WIDTH:\r
+ return g_curwin->width;\r
+ case GLUT_WINDOW_HEIGHT:\r
+ return g_curwin->height;\r
+ case GLUT_WINDOW_STENCIL_SIZE:\r
+ return STENCIL_SIZE;\r
+ case GLUT_WINDOW_DEPTH_SIZE:\r
+ return DEPTH_SIZE;\r
case GLUT_WINDOW_RGBA:\r
return !(g_display_mode & GLUT_INDEX);\r
+ case GLUT_WINDOW_COLORMAP_SIZE:\r
+ return (g_display_mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0;\r
+ case GLUT_SCREEN_WIDTH:\r
+ return g_screen_w;\r
+ case GLUT_SCREEN_HEIGHT:\r
+ return g_screen_h;\r
+ case GLUT_INIT_WINDOW_X:\r
+ return g_init_x;\r
+ case GLUT_INIT_WINDOW_Y:\r
+ return g_init_y;\r
+ case GLUT_INIT_WINDOW_WIDTH:\r
+ return g_init_w;\r
+ case GLUT_INIT_WINDOW_HEIGHT:\r
+ return g_init_h;\r
+ case GLUT_INIT_DISPLAY_MODE:\r
+ return g_display_mode;\r
case GLUT_ELAPSED_TIME:\r
if (!timer_installed) {\r
- timer_installed = !timer_installed;\r
+ timer_installed = GL_TRUE;\r
LOCKDATA(ticks);\r
LOCKFUNC(ticks_timer);\r
pc_install_int(ticks_timer, NULL, FREQUENCY);\r
}\r
return ticks*1000/FREQUENCY;\r
default:\r
- return 0;\r
+ return -1;\r
}\r
}\r
\r
\r
+\r
int APIENTRY glutDeviceGet (GLenum type)\r
{\r
- return 0;\r
+ switch (type) {\r
+ case GLUT_HAS_KEYBOARD:\r
+ return GL_TRUE;\r
+ case GLUT_HAS_MOUSE:\r
+ return (g_mouse != 0);\r
+ case GLUT_NUM_MOUSE_BUTTONS:\r
+ return g_mouse;\r
+ case GLUT_HAS_SPACEBALL:\r
+ case GLUT_HAS_DIAL_AND_BUTTON_BOX:\r
+ case GLUT_HAS_TABLET:\r
+ return GL_FALSE;\r
+ case GLUT_NUM_SPACEBALL_BUTTONS:\r
+ case GLUT_NUM_BUTTON_BOX_BUTTONS:\r
+ case GLUT_NUM_DIALS:\r
+ case GLUT_NUM_TABLET_BUTTONS:\r
+ return 0;\r
+ default:\r
+ return -1;\r
+ }\r
+}\r
+\r
+\r
+\r
+int APIENTRY glutGetModifiers (void)\r
+{\r
+ int mod = 0;\r
+ int shifts = pc_keyshifts();\r
+\r
+ if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {\r
+ mod |= GLUT_ACTIVE_SHIFT;\r
+ }\r
+\r
+ if (shifts & KB_ALT_FLAG) {\r
+ mod |= GLUT_ACTIVE_ALT;\r
+ }\r
+\r
+ if (shifts & KB_CTRL_FLAG) {\r
+ mod |= GLUT_ACTIVE_CTRL;\r
+ }\r
+\r
+ return mod;\r
}\r
*/\r
\r
\r
-#include "GL/glut.h"\r
+#include "glutint.h"\r
#include "GL/dmesa.h"\r
-#include "internal.h"\r
\r
\r
\r
-static int window;\r
+GLUTwindow *g_curwin;\r
\r
static DMesaVisual visual = NULL;\r
static DMesaContext context = NULL;\r
-static DMesaBuffer buffer[MAX_WINDOWS];\r
+static GLUTwindow *windows[MAX_WINDOWS];\r
\r
\r
\r
{\r
int i;\r
\r
- for (i=0; i<MAX_WINDOWS; i++) {\r
- glutDestroyWindow(i+1);\r
+ for (i=1; i<=MAX_WINDOWS; i++) {\r
+ glutDestroyWindow(i);\r
}\r
if (context) DMesaDestroyContext(context);\r
if (visual) DMesaDestroyVisual(visual);\r
int APIENTRY glutCreateWindow (const char *title)\r
{\r
int i;\r
+ GLint screen_size[2];\r
+ int m8width = (g_init_w + 7) & ~7;\r
\r
if (!visual) {\r
- if ((visual=DMesaCreateVisual(g_xpos + g_width, g_ypos + g_height, g_bpp, g_refresh,\r
+ if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh,\r
g_display_mode & GLUT_DOUBLE,\r
!(g_display_mode & GLUT_INDEX),\r
g_display_mode & GLUT_ALPHA,\r
g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {\r
return 0;\r
}\r
- \r
+\r
if ((context=DMesaCreateContext(visual, NULL))==NULL) {\r
DMesaDestroyVisual(visual);\r
return 0;\r
}\r
- \r
+\r
pc_open_stdout();\r
pc_open_stderr();\r
pc_atexit(clean);\r
}\r
\r
for (i=0; i<MAX_WINDOWS; i++) {\r
- if (!buffer[i]) {\r
+ if (windows[i] == NULL) {\r
DMesaBuffer b;\r
- \r
- if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {\r
+ GLUTwindow *w;\r
+\r
+ if ((w=(GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) {\r
+ return 0;\r
+ }\r
+\r
+ if ((b=DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h))==NULL) {\r
+ free(w);\r
return 0;\r
}\r
if (!DMesaMakeCurrent(context, b)) {\r
DMesaDestroyBuffer(b);\r
+ free(w);\r
return 0;\r
}\r
- if (g_mouse) {\r
- pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);\r
- }\r
\r
- buffer[window = i] = b;\r
- return i+1;\r
+ g_curwin = windows[i] = w;\r
+\r
+ w->num = ++i;\r
+ w->xpos = g_init_x;\r
+ w->ypos = g_init_y;\r
+ w->width = m8width;\r
+ w->height = g_init_h;\r
+ w->buffer = b;\r
+\r
+ return i;\r
}\r
}\r
\r
}\r
\r
\r
+\r
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)\r
{\r
return GL_FALSE;\r
}\r
\r
\r
+\r
void APIENTRY glutDestroyWindow (int win)\r
{\r
- if (buffer[win-1]) {\r
- DMesaDestroyBuffer(buffer[win-1]);\r
- buffer[win-1] = NULL;\r
+ if (windows[--win]) {\r
+ DMesaDestroyBuffer(windows[win]->buffer);\r
+ free(windows[win]);\r
+ windows[win] = NULL;\r
}\r
}\r
\r
\r
+\r
void APIENTRY glutPostRedisplay (void)\r
{\r
g_redisplay = GL_TRUE;\r
}\r
\r
\r
+\r
void APIENTRY glutSwapBuffers (void)\r
{\r
- if (g_mouse) pc_scare_mouse();\r
- DMesaSwapBuffers(buffer[window]);\r
- if (g_mouse) pc_unscare_mouse();\r
+ if (g_curwin->show_mouse) {\r
+ /* XXX scare mouse */\r
+ DMesaSwapBuffers(g_curwin->buffer);\r
+ /* XXX unscare mouse */\r
+ } else {\r
+ DMesaSwapBuffers(g_curwin->buffer);\r
+ }\r
}\r
\r
\r
+\r
int APIENTRY glutGetWindow (void)\r
{\r
- return window + 1;\r
+ return g_curwin->num;\r
}\r
\r
\r
+\r
void APIENTRY glutSetWindow (int win)\r
{\r
- window = win - 1;\r
+ g_curwin = windows[win - 1];\r
}\r
\r
\r
+\r
void APIENTRY glutSetWindowTitle (const char *title)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutSetIconTitle (const char *title)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutPositionWindow (int x, int y)\r
{\r
- if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {\r
- g_xpos = x;\r
- g_ypos = y;\r
+ if (DMesaMoveBuffer(x, y)) {\r
+ g_curwin->xpos = x;\r
+ g_curwin->ypos = y;\r
}\r
}\r
\r
\r
+\r
void APIENTRY glutReshapeWindow (int width, int height)\r
-{\r
- if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {\r
- g_width = width;\r
- g_height = height;\r
- if (reshape_func) {\r
- reshape_func(width, height);\r
+{ \r
+ if (DMesaResizeBuffer(width, height)) {\r
+ g_curwin->width = width;\r
+ g_curwin->height = height;\r
+ if (g_curwin->reshape) {\r
+ g_curwin->reshape(width, height);\r
} else {\r
glViewport(0, 0, width, height);\r
}\r
}\r
\r
\r
+\r
+void APIENTRY glutFullScreen (void)\r
+{\r
+}\r
+\r
+\r
+\r
void APIENTRY glutPopWindow (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutPushWindow (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutIconifyWindow (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutShowWindow (void)\r
{\r
}\r
\r
\r
+\r
void APIENTRY glutHideWindow (void)\r
{\r
}\r
offset = c->Buffer->width * FLIP(y) + x;\r
/* read all pixels */\r
for (i=0; i<n; i++, offset++) {\r
- index[i] = vl_getCIpixel(offset);\r
+ index[i] = vl_getpixel(offset);\r
}\r
}\r
\r
/* read some pixels */\r
for (i=0; i<n; i++) {\r
if (mask[i]) {\r
- index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);\r
+ index[i] = vl_getpixel(FLIP2(y[i])*w + x[i]);\r
}\r
}\r
} else {\r
/* read all pixels */\r
for (i=0; i<n; i++) {\r
- index[i] = vl_getCIpixel(FLIP2(y[i])*w + x[i]);\r
+ index[i] = vl_getpixel(FLIP2(y[i])*w + x[i]);\r
}\r
}\r
}\r
\r
\r
\r
-GLboolean DMesaViewport (DMesaBuffer b,\r
- GLint xpos, GLint ypos,\r
- GLint width, GLint height)\r
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos)\r
{\r
#ifndef FX\r
- void *new_window;\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;\r
\r
- if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height)) == NULL) {\r
+ if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) {\r
return GL_FALSE;\r
} else {\r
- b->the_window = new_window;\r
b->xpos = xpos;\r
b->ypos = ypos;\r
+ return GL_TRUE;\r
+ }\r
+\r
+#else\r
+\r
+ return GL_FALSE;\r
+#endif\r
+}\r
+\r
+\r
+\r
+GLboolean DMesaResizeBuffer (GLint width, GLint height)\r
+{\r
+#ifndef FX\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;\r
+\r
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) {\r
+ return GL_FALSE;\r
+ } else {\r
b->width = width;\r
b->height = height;\r
return GL_TRUE;\r
{\r
#ifndef FX\r
if ((c != NULL) && (b != NULL)) {\r
- if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) {\r
+ if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, b->width, b->height) != 0) {\r
return GL_FALSE;\r
}\r
\r
vl_setCI(ndx, red, green, blue);\r
#endif\r
}\r
+\r
+\r
+\r
+void DMesaGetIntegerv (GLenum pname, GLint *params)\r
+{\r
+#ifndef FX\r
+ GET_CURRENT_CONTEXT(ctx);\r
+ const DMesaContext c = (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx;\r
+#else\r
+ const fxMesaContext c = fxMesaGetCurrentContext();\r
+#endif\r
+\r
+ if (c == NULL) {\r
+ return;\r
+ }\r
+\r
+ switch (pname) {\r
+ case DMESA_Y_ORIGIN:\r
+ #ifndef FX\r
+ params[0] = GL_FALSE;\r
+ #else\r
+ params[0] = GL_TRUE;\r
+ #endif\r
+ break;\r
+ case DMESA_SCREEN_SIZE:\r
+ #ifndef FX\r
+ vl_get_screen_size(¶ms[0], ¶ms[1]);\r
+ #else\r
+ params[0] = c->screen_width;\r
+ params[1] = c->screen_height;\r
+ #endif\r
+ break;\r
+ case DMESA_ARGB_ORDER:\r
+ #ifndef FX\r
+ params[0] = GL_FALSE;\r
+ #else\r
+ params[0] = !c->bgrOrder;\r
+ #endif\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+}\r
\r
\r
#include <dpmi.h>\r
+#include <pc.h>\r
#include <stdlib.h>\r
#include <stubinfo.h>\r
#include <sys/exceptn.h>\r
* In : color index, R, G, B\r
* Out : -\r
*\r
- * Note: uses normalized values\r
+ * Note: uses integer values\r
*/\r
-static void vesa_setCI_f (int index, float red, float green, float blue)\r
+static void vesa_setCI_i (int index, int red, int green, int blue)\r
{\r
- float max = (1 << vesa_color_precision) - 1;\r
-\r
- int _red = red * max;\r
- int _green = green * max;\r
- int _blue = blue * max;\r
-\r
+#if 0\r
__asm("\n\\r
movw $0x1010, %%ax \n\\r
movb %1, %%dh \n\\r
movb %2, %%ch \n\\r
int $0x10 \n\\r
-"::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");\r
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");\r
+#else\r
+ outportb(0x03C8, index);\r
+ outportb(0x03C9, red);\r
+ outportb(0x03C9, green);\r
+ outportb(0x03C9, blue);\r
+#endif\r
}\r
\r
\r
* In : color index, R, G, B\r
* Out : -\r
*\r
- * Note: uses integer values\r
+ * Note: uses normalized values\r
*/\r
-static void vesa_setCI_i (int index, int red, int green, int blue)\r
+static void vesa_setCI_f (int index, float red, float green, float blue)\r
{\r
- __asm("\n\\r
- movw $0x1010, %%ax \n\\r
- movb %1, %%dh \n\\r
- movb %2, %%ch \n\\r
- int $0x10 \n\\r
-"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");\r
+ float max = (1 << vesa_color_precision) - 1;\r
+\r
+ vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));\r
}\r
\r
\r
*/\r
\r
\r
+#include <pc.h>\r
#include <stdlib.h>\r
\r
#include "vga.h"\r
* In : color index, R, G, B\r
* Out : -\r
*\r
- * Note: uses normalized values\r
+ * Note: uses integer values\r
*/\r
-static void vga_setCI_f (int index, float red, float green, float blue)\r
+static void vga_setCI_i (int index, int red, int green, int blue)\r
{\r
- float max = (1 << vga_color_precision) - 1;\r
-\r
- int _red = red * max;\r
- int _green = green * max;\r
- int _blue = blue * max;\r
-\r
+#if 0\r
__asm("\n\\r
movw $0x1010, %%ax \n\\r
movb %1, %%dh \n\\r
movb %2, %%ch \n\\r
int $0x10 \n\\r
- "::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");\r
+ "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");\r
+#else\r
+ outportb(0x03C8, index);\r
+ outportb(0x03C9, red);\r
+ outportb(0x03C9, green);\r
+ outportb(0x03C9, blue);\r
+#endif\r
}\r
\r
\r
* In : color index, R, G, B\r
* Out : -\r
*\r
- * Note: uses integer values\r
+ * Note: uses normalized values\r
*/\r
-static void vga_setCI_i (int index, int red, int green, int blue)\r
+static void vga_setCI_f (int index, float red, float green, float blue)\r
{\r
- __asm("\n\\r
- movw $0x1010, %%ax \n\\r
- movb %1, %%dh \n\\r
- movb %2, %%ch \n\\r
- int $0x10 \n\\r
-"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");\r
+ float max = (1 << vga_color_precision) - 1;\r
+\r
+ vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max));\r
}\r
\r
\r
static vl_driver *drv;\r
/* based upon mode specific data: valid entire session */\r
int vl_video_selector;\r
+static vl_mode *video_mode;\r
static int video_scanlen, video_bypp;\r
/* valid until next buffer */\r
void *vl_current_draw_buffer, *vl_current_read_buffer;\r
int (*vl_mixrgb) (const unsigned char rgb[]);\r
int (*vl_mixrgba) (const unsigned char rgba[]);\r
void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);\r
+int (*vl_getpixel) (unsigned int offset);\r
void (*vl_clear) (int color);\r
void (*vl_rect) (int x, int y, int width, int height, int color);\r
void (*vl_flip) (void);\r
\r
\r
\r
-/* Desc: set one palette entry\r
+/* Desc: pixel retrieval\r
*\r
- * In : index, R, G, B\r
- * Out : -\r
+ * In : pixel offset\r
+ * Out : pixel value\r
*\r
- * Note: color components are in range [0.0 .. 1.0]\r
+ * Note: uses current read buffer\r
*/\r
-void vl_setCI (int index, float red, float green, float blue)\r
+static int v_getpixel8 (unsigned int offset)\r
{\r
- drv->setCI_f(index, red, green, blue);\r
+ return ((word8 *)vl_current_read_buffer)[offset];\r
+}\r
+#define v_getpixel15 v_getpixel16\r
+static int v_getpixel16 (unsigned int offset)\r
+{\r
+ return ((word16 *)vl_current_read_buffer)[offset];\r
+}\r
+static int v_getpixel24 (unsigned int offset)\r
+{\r
+ return *(word32 *)((long)vl_current_read_buffer+offset*3);\r
+}\r
+static int v_getpixel32 (unsigned int offset)\r
+{\r
+ return ((word32 *)vl_current_read_buffer)[offset];\r
}\r
\r
\r
\r
-/* Desc: read pixel from 8bit buffer\r
+/* Desc: set one palette entry\r
*\r
- * In : pixel offset\r
- * Out : pixel read\r
+ * In : index, R, G, B\r
+ * Out : -\r
*\r
- * Note: used only for CI modes\r
+ * Note: color components are in range [0.0 .. 1.0]\r
*/\r
-int vl_getCIpixel (unsigned int offset)\r
+void vl_setCI (int index, float red, float green, float blue)\r
{\r
- return ((word8 *)vl_current_read_buffer)[offset];\r
+ drv->setCI_f(index, red, green, blue);\r
}\r
\r
\r
* In : color, R, G, B\r
* Out : -\r
*\r
- * Note: color components are in range [0 .. 63]\r
+ * Note: -\r
*/\r
static void fake_setcolor (int c, int r, int g, int b)\r
{\r
\r
/* Desc: sync buffer with video hardware\r
*\r
- * In : old buffer, position, size\r
- * Out : new buffer\r
+ * In : ptr to old buffer, position, size\r
+ * Out : 0 if success\r
*\r
* Note: -\r
*/\r
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height)\r
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height)\r
{\r
- void *newbuf;\r
-\r
- if (width&7) {\r
- return NULL;\r
+ if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) {\r
+ return -1;\r
} else {\r
- if ((newbuf=realloc(buffer, width * height * video_bypp)) != NULL) {\r
- vl_current_width = width;\r
- vl_current_height = height;\r
- vl_current_stride = vl_current_width * video_bypp;\r
- vl_current_bytes = vl_current_stride * height;\r
-\r
- vl_current_offset = video_scanlen * y + video_bypp * x;\r
- vl_current_delta = video_scanlen - vl_current_stride;\r
+ void *newbuf = *buffer;\r
+\r
+ if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) {\r
+ newbuf = realloc(newbuf, width * height * video_bypp);\r
}\r
- return vl_current_draw_buffer = vl_current_read_buffer = newbuf;\r
+\r
+ if (newbuf == NULL) {\r
+ return -2;\r
+ }\r
+\r
+ vl_current_width = width;\r
+ vl_current_height = height;\r
+ vl_current_stride = vl_current_width * video_bypp;\r
+ vl_current_bytes = vl_current_stride * height;\r
+\r
+ vl_current_offset = video_scanlen * y + video_bypp * x;\r
+ vl_current_delta = video_scanlen - vl_current_stride;\r
+\r
+ vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf;\r
+ return 0;\r
}\r
}\r
\r
\r
\r
+/* Desc: get screen geometry\r
+ *\r
+ * In : ptr to WIDTH, ptr to HEIGHT\r
+ * Out : -\r
+ *\r
+ * Note: -\r
+ */\r
+void vl_get_screen_size (int *width, int *height)\r
+{\r
+ *width = video_mode->xres;\r
+ *height = video_mode->yres;\r
+}\r
+\r
+\r
+\r
/* Desc: retrieve CPU MMX capability\r
*\r
* In : -\r
{\r
#ifdef USE_MMX_ASM\r
extern int _mesa_identify_x86_cpu_features (void);\r
- int _mesa_x86_cpu_features = _mesa_identify_x86_cpu_features();\r
- return (_mesa_x86_cpu_features & 0x00800000);\r
+ return (_mesa_identify_x86_cpu_features() & 0x00800000);\r
#else\r
return 0;\r
#endif\r
*/\r
static int vl_setup_mode (vl_mode *p)\r
{\r
+ if (p == NULL) {\r
+ return -1;\r
+ }\r
+\r
#define INITPTR(bpp) \\r
vl_putpixel = v_putpixel##bpp; \\r
vl_getrgba = v_getrgba##bpp; \\r
+ vl_getpixel = v_getpixel##bpp; \\r
vl_rect = v_rect##bpp; \\r
vl_mixfix = vl_mixfix##bpp; \\r
vl_mixrgb = vl_mixrgb##bpp; \\r
\r
#undef INITPTR\r
\r
+ video_mode = p;\r
video_bypp = (p->bpp+7)/8;\r
video_scanlen = p->scanlen;\r
vl_video_selector = p->sel;\r
}\r
}\r
\r
- /* check, setup and enter mode */\r
- if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {\r
+ /* setup and enter mode */\r
+ if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) {\r
vl_flip = drv->blit;\r
if (fake) {\r
min = drv->getCIprec();\r
extern void (*vl_rect) (int x, int y, int width, int height, int color);\r
extern void (*vl_flip) (void);\r
extern void (*vl_putpixel) (unsigned int offset, int color);\r
+extern int (*vl_getpixel) (unsigned int offset);\r
\r
void vl_setCI (int index, float red, float green, float blue);\r
-int vl_getCIpixel (unsigned int offset);\r
\r
-void *vl_sync_buffer (void *buffer, int x, int y, int width, int height);\r
+int vl_sync_buffer (void **buffer, int x, int y, int width, int height);\r
+void vl_get_screen_size (int *width, int *height);\r
\r
void vl_video_exit (void);\r
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);\r
.p2align 5,,31\r
.global _v_clear8_mmx\r
_v_clear8_mmx:\r
- movl 4(%esp), %eax\r
- movb %al, %ah\r
- pushw %ax\r
- pushw %ax\r
- pushw %ax\r
- pushw %ax\r
+#ifdef USE_MMX_ASM\r
+ movq 4(%esp), %mm0\r
+ punpcklbw %mm0, %mm0\r
+ punpcklwd %mm0, %mm0\r
jmp _v_clear_common_mmx\r
+#endif\r
\r
/* Desc: void v_clear16_mmx (int color);\r
*\r
.p2align 5,,31\r
.global _v_clear16_mmx\r
_v_clear16_mmx:\r
- movl 4(%esp), %eax\r
- pushw %ax\r
- pushw %ax\r
- pushw %ax\r
- pushw %ax\r
+#ifdef USE_MMX_ASM\r
+ movq 4(%esp), %mm0\r
+ punpcklwd %mm0, %mm0\r
jmp _v_clear_common_mmx\r
+#endif\r
\r
/* Desc: void v_clear32_mmx (int color);\r
*\r
.p2align 5,,31\r
.global _v_clear32_mmx\r
_v_clear32_mmx:\r
- movl 4(%esp), %eax\r
- pushl %eax\r
- pushl %eax\r
+#ifdef USE_MMX_ASM\r
+ movq 4(%esp), %mm0\r
.balign 4\r
_v_clear_common_mmx:\r
-#ifdef USE_MMX_ASM\r
+ punpckldq %mm0, %mm0\r
movl _vl_current_bytes, %ecx\r
movl _vl_current_draw_buffer, %edx\r
- movq (%esp), %mm0\r
shrl $3, %ecx\r
.balign 4\r
0:\r
jnz 0b\r
emms\r
#endif\r
- addl $8, %esp\r
ret\r
\r
/* Desc: void v_clear24 (int color);\r
# Mesa 3-D graphics library\r
-# Version: 5.1\r
+# Version: 4.1\r
# \r
-# Copyright (C) 1999-2003 Brian Paul All Rights Reserved.\r
+# Copyright (C) 1999-2002 Brian Paul All Rights Reserved.\r
# \r
# Permission is hereby granted, free of charge, to any person obtaining a\r
# copy of this software and associated documentation files (the "Software"),\r
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
\r
-# DOS/DJGPP core makefile v1.3 for Mesa 5.1\r
+# DOS/DJGPP core makefile v1.3 for Mesa 5.0\r
#\r
# Copyright (C) 2002 - Borca Daniel\r
# Email : dborca@yahoo.com\r
# Environment variables:\r
# CFLAGS\r
#\r
-# GLIDE absolute path to Glide SDK; used with FX.\r
+# GLIDE path to Glide3 SDK include files; used with FX.\r
# default = $(TOP)/include/glide3\r
-# FX=1 build for 3dfx Glide3; use it if you have the glide\r
-# SDK (designed for your platform), and, of course, a\r
-# 3dfx card... Note that this disables compilation of\r
-# actual DMesa code, as Glide does all the stuff!\r
+# FX=1 build for 3dfx Glide3. Note that this disables\r
+# compilation of most DMesa code and requires fxMesa.\r
+# As a consequence, you'll need the DJGPP Glide3\r
+# library to build any application.\r
# default = no\r
# HAVE_X86=1 optimize for i386.\r
# default = no\r
-# HAVE_MMX=1 MMX instructions; use only if you assembler/compiler\r
-# supports MMX instruction set; backwards compatibility\r
-# with older processors is still preserved.\r
+# HAVE_MMX=1 allow MMX specializations, provided your assembler\r
+# supports MMX instruction set. However, the true CPU\r
+# capabilities are checked at run-time to avoid crashes.\r
# default = no\r
# HAVE_SSE=1 (see HAVE_MMX)\r
# default = no\r
lines.c \\r
matrix.c \\r
mmath.c \\r
- nvprogram.c \\r
- nvfragparse.c \\r
- nvvertexec.c \\r
- nvvertparse.c \\r
pixel.c \\r
points.c \\r
polygon.c \\r
texstate.c \\r
texstore.c \\r
texutil.c \\r
+ varray.c \\r
+ vpexec.c \\r
+ vpparse.c \\r
+ vpstate.c \\r
vtxfmt.c \\r
math/m_debug_clip.c \\r
math/m_debug_norm.c \\r
swrast/s_lines.c \\r
swrast/s_logic.c \\r
swrast/s_masking.c \\r
- swrast/s_nvfragprog.c \\r
swrast/s_pixeltex.c \\r
swrast/s_points.c \\r
swrast/s_readpix.c \\r
$(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.)\r
else\r
ifdef FX\r
- -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E gl -E DMesa -X -P glid3.dxe -U $(OBJECTS)\r
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E _gl -E _DMesa -P glid3.dxe -U $(OBJECTS)\r
else\r
- -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E gl -E DMesa -X -U $(OBJECTS)\r
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E _gl -E _DMesa -U $(OBJECTS)\r
endif\r
endif\r
\r