summaryrefslogtreecommitdiff
path: root/src/glut
diff options
context:
space:
mode:
Diffstat (limited to 'src/glut')
-rw-r--r--src/glut/dos/Makefile.DJ81
-rw-r--r--src/glut/dos/PC_HW/pc_hw.c141
-rw-r--r--src/glut/dos/PC_HW/pc_hw.h227
-rw-r--r--src/glut/dos/PC_HW/pc_irq.S180
-rw-r--r--src/glut/dos/PC_HW/pc_keyb.c532
-rw-r--r--src/glut/dos/PC_HW/pc_mouse.c243
-rw-r--r--src/glut/dos/PC_HW/pc_timer.c158
-rw-r--r--src/glut/dos/callback.c152
-rw-r--r--src/glut/dos/color.c46
-rw-r--r--src/glut/dos/depend18
-rw-r--r--src/glut/dos/font.c52
-rw-r--r--src/glut/dos/globals.c61
-rw-r--r--src/glut/dos/init.c168
-rw-r--r--src/glut/dos/internal.h76
-rw-r--r--src/glut/dos/menu.c86
-rw-r--r--src/glut/dos/models.c598
-rw-r--r--src/glut/dos/overlay.c60
-rw-r--r--src/glut/dos/state.c47
-rw-r--r--src/glut/dos/teapot.c212
-rw-r--r--src/glut/dos/window.c160
20 files changed, 3298 insertions, 0 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ
new file mode 100644
index 0000000000..a8d176cbf4
--- /dev/null
+++ b/src/glut/dos/Makefile.DJ
@@ -0,0 +1,81 @@
+# 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 glut makefile v0.1 for Mesa 4.0
+#
+# Copyright (C) 2002 - Borca Daniel
+# Email : dborca@yahoo.com
+# Web : http://www.geocities.com/dborca
+
+
+.PHONY: all clean
+
+TOP = ..
+CC = gcc
+CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=pentium -ffast-math -O2
+AR = ar
+ARFLAGS = ruv
+LIBDIR = $(TOP)/lib
+
+GLUT_LIB = libglut.a
+
+CORE_SOURCES = \
+ callback.c \
+ color.c \
+ font.c \
+ globals.c \
+ init.c \
+ menu.c \
+ models.c \
+ overlay.c \
+ state.c \
+ teapot.c \
+ window.c
+
+PC_HW_OBJECTS = \
+ PC_HW/pc_hw.o \
+ PC_HW/pc_keyb.o \
+ PC_HW/pc_mouse.o \
+ PC_HW/pc_timer.o \
+ PC_HW/pc_irq.o
+
+SOURCES = $(CORE_SOURCES)
+
+OBJECTS = $(SOURCES:.c=.o) $(PC_HW_OBJECTS)
+
+.S.o:
+ gcc -o $@ -c $(CFLAGS) $<
+.s.o:
+ gcc -o $@ -c $(CFLAGS) $(<:.s=.S)
+.c.o:
+ gcc -o $@ -c $(CFLAGS) $<
+
+all: $(LIBDIR)/$(GLUT_LIB)
+
+$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)
+ $(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)
+
+clean:
+ -$(RM) *.o
+ -$(RM) PC_HW\*.o
+
+include depend
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c
new file mode 100644
index 0000000000..d6ffd5650f
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_hw.c
@@ -0,0 +1,141 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <dpmi.h>
+#include <fcntl.h>
+#include <sys/stat.h> /* for mode definitions */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "pc_hw.h"
+
+/*
+ * atexit
+ */
+#define MAX_ATEXIT 32
+
+static volatile int atexitcnt;
+static VFUNC atexittbl[MAX_ATEXIT];
+
+static void __attribute__((destructor)) doexit (void)
+{
+ while (atexitcnt) atexittbl[--atexitcnt]();
+}
+
+int pc_clexit (VFUNC f)
+{
+ int i;
+
+ for (i=0;i<atexitcnt;i++) {
+ if (atexittbl[i]==f) {
+ for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1];
+ atexittbl[i] = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int pc_atexit (VFUNC f)
+{
+ pc_clexit(f);
+ if (atexitcnt<MAX_ATEXIT) {
+ atexittbl[atexitcnt++] = f;
+ return 0;
+ }
+ return -1;
+}
+
+/*
+ * locked memory allocation
+ */
+void *pc_malloc (size_t size)
+{
+ void *p = malloc(size);
+
+ if (p) {
+ if (_go32_dpmi_lock_data(p, size)) {
+ free(p);
+ return NULL;
+ }
+ }
+
+ return p;
+}
+
+/*
+ * standard redirection
+ */
+static char errname[L_tmpnam];
+static char outname[L_tmpnam];
+
+static int h_out, h_outbak;
+static int h_err, h_errbak;
+
+void pc_open_stderr (void)
+{
+ if (tmpnam(errname)) {
+ h_err = open(errname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
+ S_IREAD | S_IWRITE);
+ h_errbak = dup(2);
+ fflush(stderr);
+ dup2(h_err, 2);
+ }
+}
+
+void pc_close_stderr (void)
+{
+ FILE *f;
+ char *line = alloca(512);
+
+ dup2(h_errbak, 2);
+ close(h_err);
+ close(h_errbak);
+
+ if ((f=fopen(errname, "r"))!=NULL) {
+ while (fgets(line, 512, f)) {
+ fputs(line, stderr);
+ }
+ fclose(f);
+ }
+
+ remove(errname);
+}
+
+void pc_open_stdout (void)
+{
+ if (tmpnam(outname)) {
+ h_out = open(outname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,
+ S_IREAD | S_IWRITE);
+ h_outbak = dup(1);
+ fflush(stdout);
+ dup2(h_out, 1);
+ }
+}
+
+void pc_close_stdout (void)
+{
+ FILE *f;
+ char *line = alloca(512);
+
+ dup2(h_outbak, 1);
+ close(h_out);
+ close(h_outbak);
+
+ if ((f=fopen(outname, "r"))!=NULL) {
+ while (fgets(line, 512, f)) {
+ fputs(line, stdout);
+ }
+ fclose(f);
+ }
+
+ remove(outname);
+}
diff --git a/src/glut/dos/PC_HW/pc_hw.h b/src/glut/dos/PC_HW/pc_hw.h
new file mode 100644
index 0000000000..09fe8051bb
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_hw.h
@@ -0,0 +1,227 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef PC_HW_H_included
+#define PC_HW_H_included
+
+#include <dpmi.h>
+#include <stdlib.h>
+
+/*
+ * misc C definitions
+ */
+#define FALSE 0
+#define TRUE !FALSE
+
+#define MIN(x,y) (((x) < (y)) ? (x) : (y))
+#define MAX(x,y) (((x) > (y)) ? (x) : (y))
+#define MID(x,y,z) MAX((x), MIN((y), (z)))
+
+typedef void (*VFUNC) (void);
+typedef void (*PFUNC) (void *);
+typedef void (*MFUNC) (int x, int y, int b);
+
+/*
+ * atexit
+ */
+int pc_atexit (VFUNC f);
+int pc_clexit (VFUNC f);
+
+/*
+ * locked memory
+ */
+#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))
+
+void *pc_malloc (size_t size);
+
+/*
+ * IRQ
+ */
+#define ENABLE() __asm__ __volatile__ ("sti")
+#define DISABLE() __asm__ __volatile__ ("cli")
+
+extern int pc_install_irq (int i, int (*handler) ());
+extern int pc_remove_irq (int i);
+
+/*
+ * keyboard
+ */
+#define KB_SHIFT_FLAG 0x0001
+#define KB_CTRL_FLAG 0x0002
+#define KB_ALT_FLAG 0x0004
+#define KB_LWIN_FLAG 0x0008
+#define KB_RWIN_FLAG 0x0010
+#define KB_MENU_FLAG 0x0020
+#define KB_SCROLOCK_FLAG 0x0100
+#define KB_NUMLOCK_FLAG 0x0200
+#define KB_CAPSLOCK_FLAG 0x0400
+#define KB_INALTSEQ_FLAG 0x0800
+#define KB_ACCENT1_FLAG 0x1000
+#define KB_ACCENT2_FLAG 0x2000
+#define KB_ACCENT3_FLAG 0x4000
+#define KB_ACCENT4_FLAG 0x8000
+
+#define KEY_A 1
+#define KEY_B 2
+#define KEY_C 3
+#define KEY_D 4
+#define KEY_E 5
+#define KEY_F 6
+#define KEY_G 7
+#define KEY_H 8
+#define KEY_I 9
+#define KEY_J 10
+#define KEY_K 11
+#define KEY_L 12
+#define KEY_M 13
+#define KEY_N 14
+#define KEY_O 15
+#define KEY_P 16
+#define KEY_Q 17
+#define KEY_R 18
+#define KEY_S 19
+#define KEY_T 20
+#define KEY_U 21
+#define KEY_V 22
+#define KEY_W 23
+#define KEY_X 24
+#define KEY_Y 25
+#define KEY_Z 26
+#define KEY_0 27
+#define KEY_1 28
+#define KEY_2 29
+#define KEY_3 30
+#define KEY_4 31
+#define KEY_5 32
+#define KEY_6 33
+#define KEY_7 34
+#define KEY_8 35
+#define KEY_9 36
+#define KEY_0_PAD 37
+#define KEY_1_PAD 38
+#define KEY_2_PAD 39
+#define KEY_3_PAD 40
+#define KEY_4_PAD 41
+#define KEY_5_PAD 42
+#define KEY_6_PAD 43
+#define KEY_7_PAD 44
+#define KEY_8_PAD 45
+#define KEY_9_PAD 46
+#define KEY_F1 47
+#define KEY_F2 48
+#define KEY_F3 49
+#define KEY_F4 50
+#define KEY_F5 51
+#define KEY_F6 52
+#define KEY_F7 53
+#define KEY_F8 54
+#define KEY_F9 55
+#define KEY_F10 56
+#define KEY_F11 57
+#define KEY_F12 58
+#define KEY_ESC 59
+#define KEY_TILDE 60
+#define KEY_MINUS 61
+#define KEY_EQUALS 62
+#define KEY_BACKSPACE 63
+#define KEY_TAB 64
+#define KEY_OPENBRACE 65
+#define KEY_CLOSEBRACE 66
+#define KEY_ENTER 67
+#define KEY_COLON 68
+#define KEY_QUOTE 69
+#define KEY_BACKSLASH 70
+#define KEY_BACKSLASH2 71
+#define KEY_COMMA 72
+#define KEY_STOP 73
+#define KEY_SLASH 74
+#define KEY_SPACE 75
+#define KEY_INSERT 76
+#define KEY_DEL 77
+#define KEY_HOME 78
+#define KEY_END 79
+#define KEY_PGUP 80
+#define KEY_PGDN 81
+#define KEY_LEFT 82
+#define KEY_RIGHT 83
+#define KEY_UP 84
+#define KEY_DOWN 85
+#define KEY_SLASH_PAD 86
+#define KEY_ASTERISK 87
+#define KEY_MINUS_PAD 88
+#define KEY_PLUS_PAD 89
+#define KEY_DEL_PAD 90
+#define KEY_ENTER_PAD 91
+#define KEY_PRTSCR 92
+#define KEY_PAUSE 93
+#define KEY_ABNT_C1 94
+#define KEY_YEN 95
+#define KEY_KANA 96
+#define KEY_CONVERT 97
+#define KEY_NOCONVERT 98
+#define KEY_AT 99
+#define KEY_CIRCUMFLEX 100
+#define KEY_COLON2 101
+#define KEY_KANJI 102
+
+#define KEY_MODIFIERS 103
+
+#define KEY_LSHIFT 103
+#define KEY_RSHIFT 104
+#define KEY_LCONTROL 105
+#define KEY_RCONTROL 106
+#define KEY_ALT 107
+#define KEY_ALTGR 108
+#define KEY_LWIN 109
+#define KEY_RWIN 110
+#define KEY_MENU 111
+#define KEY_SCRLOCK 112
+#define KEY_NUMLOCK 113
+#define KEY_CAPSLOCK 114
+
+#define KEY_MAX 115
+
+extern volatile char pc_key[KEY_MAX];
+
+int pc_install_keyb (void);
+void pc_remove_keyb (void);
+int pc_keypressed (void);
+int pc_readkey (void);
+
+/*
+ * timer
+ */
+int pc_install_int (PFUNC func, void *parm, unsigned int freq);
+void pc_remove_timer (void);
+
+/*
+ * mouse
+ */
+extern volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;
+
+int pc_install_mouse (void);
+void pc_remove_mouse (void);
+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);
+void pc_show_mouse (void);
+void pc_scare_mouse (void);
+void pc_unscare_mouse (void);
+
+/*
+ * standard redirection
+ */
+void pc_open_stdout (void);
+void pc_open_stderr (void);
+void pc_close_stdout (void);
+void pc_close_stderr (void);
+
+#endif
diff --git a/src/glut/dos/PC_HW/pc_irq.S b/src/glut/dos/PC_HW/pc_irq.S
new file mode 100644
index 0000000000..2a6302f71a
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_irq.S
@@ -0,0 +1,180 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+ .file "pc_irq.S"
+
+ .text
+
+#define IRQ_STACK_SIZE 16384
+
+#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)
+#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)
+#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)
+#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)
+
+ .balign 4
+common:
+ movw $0x0400, %ax
+ int $0x31
+
+ movl %ss:8(%ebp), %ebx
+ cmpl $15, %ebx
+ jbe 0f
+ fail:
+ orl $-1, %eax
+ popl %edi
+ popl %ebx
+ leave
+ ret
+
+ 0:
+ movl %ebx, %edi
+ imull $IRQ_WRAPPER_LEN, %edi
+ addl $__irq_wrapper_0, %edi
+
+ cmpb $7, %bl
+ jbe 1f
+ movb %dl, %dh
+ subb $8, %dh
+ 1:
+ addb %dh, %bl
+ ret
+
+ .balign 4
+ .global _pc_install_irq
+_pc_install_irq:
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ebx
+ pushl %edi
+
+ call common
+
+ cmpl $0, IRQ_HOOK(%edi)
+ jne fail
+
+ pushl $IRQ_WRAPPER_LEN
+ pushl %edi
+ call __go32_dpmi_lock_code
+ addl $8, %esp
+ testl %eax, %eax
+ jnz fail
+
+ pushl $IRQ_STACK_SIZE
+ call _pc_malloc
+ popl %edx
+ testl %eax, %eax
+ jz fail
+ addl %edx, %eax
+ movl %eax, IRQ_STACK(%edi)
+
+ movl %ss:12(%ebp), %eax
+ movl %eax, IRQ_HOOK(%edi)
+
+ movw $0x0204, %ax
+ int $0x31
+ movl %edx, IRQ_OLD(%edi)
+ movw %cx, IRQ_OLD+4(%edi)
+ movw $0x0205, %ax
+ movl %edi, %edx
+ movl %cs, %ecx
+ int $0x31
+
+ done:
+ xorl %eax, %eax
+ popl %edi
+ popl %ebx
+ leave
+ ret
+
+ .balign 4
+ .global _pc_remove_irq
+_pc_remove_irq:
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %ebx
+ pushl %edi
+
+ call common
+
+ cmpl $0, IRQ_HOOK(%edi)
+ je fail
+
+ movl $0, IRQ_HOOK(%edi)
+
+ movw $0x0205, %ax
+ movl IRQ_OLD(%edi), %edx
+ movl IRQ_OLD+4(%edi), %ecx
+ int $0x31
+
+ movl IRQ_STACK(%edi), %eax
+ subl $IRQ_STACK_SIZE, %eax
+ pushl %eax
+ call _free
+ popl %eax
+
+ jmp done
+
+#define WRAPPER(x) ; \
+ .balign 4 ; \
+__irq_wrapper_##x: ; \
+ pushal ; \
+ pushl %ds ; \
+ pushl %es ; \
+ pushl %fs ; \
+ pushl %gs ; \
+ movw %ss, %bx ; \
+ movl %esp, %esi ; \
+ movl %cs:___djgpp_ds_alias, %ss ; \
+ movl %cs:__irq_stack_##x, %esp ; \
+ pushl %ss ; \
+ pushl %ss ; \
+ popl %es ; \
+ popl %ds ; \
+ movl ___djgpp_dos_sel, %fs ; \
+ pushl %fs ; \
+ popl %gs ; \
+ call *__irq_hook_##x ; \
+ movw %bx, %ss ; \
+ movl %esi, %esp ; \
+ testl %eax, %eax ; \
+ popl %gs ; \
+ popl %fs ; \
+ popl %es ; \
+ popl %ds ; \
+ popal ; \
+ jz __irq_ignore_##x ; \
+__irq_bypass_##x: ; \
+ ljmp *%cs:__irq_old_##x ; \
+__irq_ignore_##x: ; \
+ iret ; \
+ .balign 4 ; \
+__irq_old_##x: ; \
+ .long 0, 0 ; \
+__irq_hook_##x: ; \
+ .long 0 ; \
+__irq_stack_##x: ; \
+ .long 0
+
+ WRAPPER(0);
+ WRAPPER(1);
+ WRAPPER(2);
+ WRAPPER(3);
+ WRAPPER(4);
+ WRAPPER(5);
+ WRAPPER(6);
+ WRAPPER(7);
+ WRAPPER(8);
+ WRAPPER(9);
+ WRAPPER(10);
+ WRAPPER(11);
+ WRAPPER(12);
+ WRAPPER(13);
+ WRAPPER(14);
+ WRAPPER(15);
diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c
new file mode 100644
index 0000000000..f5f4bd8e76
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_keyb.c
@@ -0,0 +1,532 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <pc.h>
+#include <sys/exceptn.h>
+#include <sys/farptr.h>
+
+#include "pc_hw.h"
+
+
+
+#define KEYB_IRQ 1
+
+#define KEY_BUFFER_SIZE 64
+
+#define KB_MODIFIERS (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG | KB_LWIN_FLAG | KB_RWIN_FLAG | KB_MENU_FLAG)
+#define KB_LED_FLAGS (KB_SCROLOCK_FLAG | KB_NUMLOCK_FLAG | KB_CAPSLOCK_FLAG)
+
+static int keyboard_installed;
+
+static volatile struct {
+ volatile int start, end;
+ volatile int key[KEY_BUFFER_SIZE];
+} key_buffer;
+
+static volatile int key_enhanced, key_pause_loop, key_shifts;
+static int leds_ok = TRUE;
+static int in_a_terrupt = FALSE;
+volatile char pc_key[KEY_MAX];
+
+
+
+/* convert Allegro format scancodes into key_shifts flag bits */
+static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] =
+{
+ KB_SHIFT_FLAG, KB_SHIFT_FLAG, KB_CTRL_FLAG,
+ KB_CTRL_FLAG, KB_ALT_FLAG, KB_ALT_FLAG,
+ KB_LWIN_FLAG, KB_RWIN_FLAG, KB_MENU_FLAG,
+ KB_SCROLOCK_FLAG, KB_NUMLOCK_FLAG, KB_CAPSLOCK_FLAG
+};
+
+
+
+/* lookup table for converting hardware scancodes into Allegro format */
+static unsigned char hw_to_mycode[128] =
+{
+ /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
+ /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
+ /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
+ /* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
+ /* 0x10 */ KEY_Q, KEY_W, KEY_E, KEY_R,
+ /* 0x14 */ KEY_T, KEY_Y, KEY_U, KEY_I,
+ /* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
+ /* 0x1C */ KEY_ENTER, KEY_LCONTROL, KEY_A, KEY_S,
+ /* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
+ /* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
+ /* 0x28 */ KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH,
+ /* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
+ /* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
+ /* 0x34 */ KEY_STOP, KEY_SLASH, KEY_RSHIFT, KEY_ASTERISK,
+ /* 0x38 */ KEY_ALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
+ /* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
+ /* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
+ /* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_SCRLOCK, KEY_7_PAD,
+ /* 0x48 */ KEY_8_PAD, KEY_9_PAD, KEY_MINUS_PAD, KEY_4_PAD,
+ /* 0x4C */ KEY_5_PAD, KEY_6_PAD, KEY_PLUS_PAD, KEY_1_PAD,
+ /* 0x50 */ KEY_2_PAD, KEY_3_PAD, KEY_0_PAD, KEY_DEL_PAD,
+ /* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
+ /* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
+ /* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
+ /* 0x60 */ 0, 0, 0, 0,
+ /* 0x64 */ 0, 0, 0, 0,
+ /* 0x68 */ 0, 0, 0, 0,
+ /* 0x6C */ 0, 0, 0, 0,
+ /* 0x70 */ KEY_KANA, 0, 0, KEY_ABNT_C1,
+ /* 0x74 */ 0, 0, 0, 0,
+ /* 0x78 */ 0, KEY_CONVERT, 0, KEY_NOCONVERT,
+ /* 0x7C */ 0, KEY_YEN, 0, 0
+};
+
+
+
+/* lookup table for converting extended hardware codes into Allegro format */
+static unsigned char hw_to_mycode_ex[128] =
+{
+ /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,
+ /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,
+ /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,
+ /* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,
+ /* 0x10 */ KEY_CIRCUMFLEX, KEY_AT, KEY_COLON2, KEY_R,
+ /* 0x14 */ KEY_KANJI, KEY_Y, KEY_U, KEY_I,
+ /* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,
+ /* 0x1C */ KEY_ENTER_PAD, KEY_RCONTROL, KEY_A, KEY_S,
+ /* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,
+ /* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,
+ /* 0x28 */ KEY_QUOTE, KEY_TILDE, 0, KEY_BACKSLASH,
+ /* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,
+ /* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,
+ /* 0x34 */ KEY_STOP, KEY_SLASH_PAD, 0, KEY_PRTSCR,
+ /* 0x38 */ KEY_ALTGR, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,
+ /* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,
+ /* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,
+ /* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_PAUSE, KEY_HOME,
+ /* 0x48 */ KEY_UP, KEY_PGUP, KEY_MINUS_PAD, KEY_LEFT,
+ /* 0x4C */ KEY_5_PAD, KEY_RIGHT, KEY_PLUS_PAD, KEY_END,
+ /* 0x50 */ KEY_DOWN, KEY_PGDN, KEY_INSERT, KEY_DEL,
+ /* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,
+ /* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,
+ /* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,
+ /* 0x60 */ 0, 0, 0, 0,
+ /* 0x64 */ 0, 0, 0, 0,
+ /* 0x68 */ 0, 0, 0, 0,
+ /* 0x6C */ 0, 0, 0, 0,
+ /* 0x70 */ 0, 0, 0, 0,
+ /* 0x74 */ 0, 0, 0, 0,
+ /* 0x78 */ 0, 0, 0, 0,
+ /* 0x7C */ 0, 0, 0, 0
+};
+
+
+
+/* default mapping table for the US keyboard layout */
+static unsigned short standard_key_ascii_table[KEY_MAX] =
+{
+ /* start */ 0,
+ /* alphabet */ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* numpad */ '/', '*', '-', '+', '.', 13,
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+
+/* capslock mapping table for the US keyboard layout */
+static unsigned short standard_key_capslock_table[KEY_MAX] =
+{
+ /* start */ 0,
+ /* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* numpad */ '/', '*', '-', '+', '.', 13,
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+
+/* shifted mapping table for the US keyboard layout */
+static unsigned short standard_key_shift_table[KEY_MAX] =
+{
+ /* start */ 0,
+ /* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ /* numbers */ ')', '!', '@', '#', '$', '%', '^', '&', '*', '(',
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* misc chars */ 27, '~', '_', '+', 8, 9, '{', '}', 13, ':', '"', '|', '|', '<', '>', '?', ' ',
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* numpad */ '/', '*', '-', '+', '.', 13,
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+
+/* ctrl+key mapping table for the US keyboard layout */
+static unsigned short standard_key_control_table[KEY_MAX] =
+{
+ /* start */ 0,
+ /* alphabet */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ /* numbers */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* misc chars */ 27, 2, 2, 2, 127, 127, 2, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2,
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
+ /* numpad */ 2, 2, 2, 2, 2, 10,
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+
+
+/* convert numeric pad scancodes into arrow codes */
+static unsigned char numlock_table[10] =
+{
+ KEY_INSERT, KEY_END, KEY_DOWN, KEY_PGDN, KEY_LEFT,
+ KEY_5_PAD, KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PGUP
+};
+
+
+
+/* kb_wait_for_write_ready:
+ * Wait for the keyboard controller to set the ready-for-write bit.
+ */
+static __inline__ int kb_wait_for_write_ready (void)
+{
+ int timeout = 4096;
+
+ while ((timeout>0) && (inportb(0x64)&2)) timeout--;
+
+ return (timeout>0);
+}
+
+
+
+/* kb_wait_for_read_ready:
+ * Wait for the keyboard controller to set the ready-for-read bit.
+ */
+static __inline__ int kb_wait_for_read_ready (void)
+{
+ int timeout = 16384;
+
+ while ((timeout>0) && (!(inportb(0x64)&1))) timeout--;
+
+ return (timeout>0);
+}
+
+
+
+/* kb_send_data:
+ * Sends a byte to the keyboard controller. Returns 1 if all OK.
+ */
+static __inline__ int kb_send_data (unsigned char data)
+{
+ int resends = 4;
+ int timeout, temp;
+
+ do {
+ if (!kb_wait_for_write_ready())
+ return 0;
+
+ outportb(0x60, data);
+ timeout = 4096;
+
+ while (--timeout>0) {
+ if (!kb_wait_for_read_ready())
+ return 0;
+
+ temp = inportb(0x60);
+
+ if (temp == 0xFA)
+ return 1;
+
+ if (temp == 0xFE)
+ break;
+ }
+ } while ((resends-- > 0) && (timeout > 0));
+
+ return 0;
+}
+
+
+
+static void update_leds (int leds)
+{
+ if (leds_ok) {
+ if (!in_a_terrupt)
+ DISABLE();
+
+ if (!kb_send_data(0xED)) {
+ kb_send_data(0xF4);
+ leds_ok = FALSE;
+ } else if (!kb_send_data((leds>>8)&7)) {
+ kb_send_data(0xF4);
+ leds_ok = FALSE;
+ }
+
+ if (!in_a_terrupt)
+ ENABLE();
+ }
+} ENDOFUNC(update_leds)
+
+
+
+static void inject_key (int scancode)
+{
+ unsigned short *table;
+
+ if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) {
+ if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) {
+ scancode = numlock_table[scancode - KEY_0_PAD];
+ }
+ table = standard_key_ascii_table;
+ } else if (key_shifts & KB_CTRL_FLAG) {
+ table = standard_key_control_table;
+ } else if (key_shifts & KB_SHIFT_FLAG) {
+ if (key_shifts & KB_CAPSLOCK_FLAG) {
+ if (standard_key_ascii_table[scancode]==standard_key_capslock_table[scancode]) {
+ table = standard_key_shift_table;
+ } else {
+ table = standard_key_ascii_table;
+ }
+ } else {
+ table = standard_key_shift_table;
+ }
+ } else if (key_shifts & KB_CAPSLOCK_FLAG) {
+ table = standard_key_capslock_table;
+ } else {
+ table = standard_key_ascii_table;
+ }
+
+ key_buffer.key[key_buffer.end++] = (scancode<<16)|table[scancode];
+
+ if (key_buffer.end>=KEY_BUFFER_SIZE)
+ key_buffer.end = 0;
+ if (key_buffer.end==key_buffer.start) {
+ key_buffer.start++;
+ if (key_buffer.start>=KEY_BUFFER_SIZE)
+ key_buffer.start = 0;
+ }
+} ENDOFUNC(inject_key)
+
+static void handle_code (int scancode, int keycode)
+{
+ in_a_terrupt++;
+
+ if (keycode==0) { /* pause */
+ inject_key(scancode);
+ pc_key[KEY_PAUSE] ^= TRUE;
+ } else if (scancode) {
+ int flag;
+
+ if (scancode>=KEY_MODIFIERS) {
+ flag = modifier_table[scancode - KEY_MODIFIERS];
+ } else {
+ flag = 0;
+ }
+ if ((char)keycode<0) { /* release */
+ pc_key[scancode] = FALSE;
+ if (flag&KB_MODIFIERS) {
+ key_shifts &= ~flag;
+ }
+ } else { /* keypress */
+ pc_key[scancode] = TRUE;
+ if (flag&KB_MODIFIERS) {
+ key_shifts |= flag;
+ }
+ if (flag&KB_LED_FLAGS) {
+ key_shifts ^= flag;
+ update_leds(key_shifts);
+ }
+ if (scancode<KEY_MODIFIERS) {
+ inject_key(scancode);
+ }
+ }
+ }
+
+ in_a_terrupt--;
+} ENDOFUNC(handle_code)
+
+static __inline__ void satisfy (void)
+{
+ __asm__("\n\
+ inb $0x61, %%al \n\
+ movb %%al, %%ah \n\
+ orb $0x80, %%al \n\
+ outb %%al, $0x61 \n\
+ xchgb %%al, %%ah \n\
+ outb %%al, $0x61 \n\
+ movb $0x20, %%al \n\
+ outb %%al, $0x20 \n\
+ ":::"%eax");
+}
+
+static int keyboard ()
+{
+ unsigned char temp, scancode;
+
+ temp = inportb(0x60);
+
+ if (temp<=0xe1) {
+ if (key_pause_loop) {
+ if (!--key_pause_loop) handle_code(KEY_PAUSE, 0);
+ } else
+ switch (temp) {
+ case 0xe0:
+ key_enhanced = TRUE;
+ break;
+ case 0xe1:
+ key_pause_loop = 5;
+ break;
+ default:
+ if (key_enhanced) {
+ key_enhanced = FALSE;
+ scancode = hw_to_mycode_ex[temp&0x7f];
+ } else {
+ scancode = hw_to_mycode[temp&0x7f];
+ }
+ handle_code(scancode, temp);
+ }
+ }
+
+ if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) {
+ __asm__("\n\
+ movb $0x79, %%al \n\
+ call ___djgpp_hw_exception \n\
+ ":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
+ }
+
+ satisfy();
+ return 0;
+} ENDOFUNC(keyboard)
+
+
+int pc_keypressed (void)
+{
+ return (key_buffer.start!=key_buffer.end);
+}
+
+int pc_readkey (void)
+{
+ if (keyboard_installed) {
+ int key;
+
+ do {
+ } while (key_buffer.start==key_buffer.end);
+
+ DISABLE();
+ key = key_buffer.key[key_buffer.start++];
+ if (key_buffer.start>=KEY_BUFFER_SIZE)
+ key_buffer.start = 0;
+ ENABLE();
+
+ return key;
+ } else {
+ return 0;
+ }
+}
+
+void pc_remove_keyb (void)
+{
+ if (keyboard_installed) {
+ int s1, s2, s3;
+
+ keyboard_installed = FALSE;
+ pc_clexit(pc_remove_keyb);
+
+ DISABLE();
+ _farsetsel(__djgpp_dos_sel);
+ _farnspokew(0x41c, _farnspeekw(0x41a));
+
+ s1 = _farnspeekb(0x417) & 0x80;
+ s2 = _farnspeekb(0x418) & 0xFC;
+ s3 = _farnspeekb(0x496) & 0xF3;
+
+ if (pc_key[KEY_RSHIFT]) { s1 |= 1; }
+ if (pc_key[KEY_LSHIFT]) { s1 |= 2; }
+ if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; }
+ if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; }
+ if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; }
+ if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; }
+
+ if (key_shifts&KB_SCROLOCK_FLAG) s1 |= 16;
+ if (key_shifts&KB_NUMLOCK_FLAG) s1 |= 32;
+ if (key_shifts&KB_CAPSLOCK_FLAG) s1 |= 64;
+
+ _farnspokeb(0x417, s1);
+ _farnspokeb(0x418, s2);
+ _farnspokeb(0x496, s3);
+ update_leds(key_shifts);
+
+ ENABLE();
+ pc_remove_irq(KEYB_IRQ);
+ }
+}
+
+int pc_install_keyb (void)
+{
+ if (keyboard_installed||pc_install_irq(KEYB_IRQ, keyboard)) {
+ return -1;
+ } else {
+ int s1, s2, s3;
+
+ LOCKDATA(key_buffer);
+ LOCKDATA(key_enhanced);
+ LOCKDATA(key_pause_loop);
+ LOCKDATA(key_shifts);
+ LOCKDATA(leds_ok);
+ LOCKDATA(in_a_terrupt);
+ LOCKDATA(pc_key);
+ LOCKDATA(modifier_table);
+ LOCKDATA(hw_to_mycode);
+ LOCKDATA(hw_to_mycode_ex);
+ LOCKDATA(standard_key_ascii_table);
+ LOCKDATA(standard_key_capslock_table);
+ LOCKDATA(standard_key_shift_table);
+ LOCKDATA(standard_key_control_table);
+ LOCKDATA(numlock_table);
+ LOCKFUNC(update_leds);
+ LOCKFUNC(inject_key);
+ LOCKFUNC(handle_code);
+ LOCKFUNC(keyboard);
+
+ DISABLE();
+ _farsetsel(__djgpp_dos_sel);
+ _farnspokew(0x41c, _farnspeekw(0x41a));
+
+ key_shifts = 0;
+ s1 = _farnspeekb(0x417);
+ s2 = _farnspeekb(0x418);
+ s3 = _farnspeekb(0x496);
+
+ if (s1&1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; }
+ if (s1&2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; }
+ if (s2&1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; }
+ if (s2&2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; }
+ if (s3&4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; }
+ if (s3&8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; }
+
+ if (s1&16) key_shifts |= KB_SCROLOCK_FLAG;
+ if (s1&32) key_shifts |= KB_NUMLOCK_FLAG;
+ if (s1&64) key_shifts |= KB_CAPSLOCK_FLAG;
+ update_leds(key_shifts);
+
+ key_enhanced = key_pause_loop = 0;
+ key_buffer.start = key_buffer.end = 0;
+ ENABLE();
+
+ pc_atexit(pc_remove_keyb);
+ keyboard_installed = TRUE;
+ return 0;
+ }
+}
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c
new file mode 100644
index 0000000000..cc3396cb21
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_mouse.c
@@ -0,0 +1,243 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <dpmi.h>
+
+#include "pc_hw.h"
+
+
+
+#define MOUSE_STACK_SIZE 16384
+
+extern void mouse_wrapper (void);
+extern void mouse_wrapper_end (void);
+
+static MFUNC mouse_func;
+static void *mouse_stack;
+static long mouse_callback;
+static __dpmi_regs mouse_regs;
+
+volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;
+
+static int minx = 0;
+static int maxx = 319;
+static int miny = 0;
+static int maxy = 199;
+
+static int sx = 2;
+static int sy = 2;
+
+static int emulat3 = FALSE;
+
+static int ox, oy;
+
+static void mouse (__dpmi_regs *r)
+{
+ int nx = (signed short)r->x.si / sx;
+ int ny = (signed short)r->x.di / sy;
+ int dx = nx - ox;
+ int dy = ny - oy;
+ ox = nx;
+ oy = ny;
+
+ pc_mouse_b = r->x.bx;
+ pc_mouse_x = MID(minx, pc_mouse_x + dx, maxx);
+ pc_mouse_y = MID(miny, pc_mouse_y + dy, maxy);
+
+ if (emulat3) {
+ if ((pc_mouse_b&3)==3) {
+ pc_mouse_b = 4;
+ }
+ }
+
+ if (mouse_func) {
+ mouse_func(pc_mouse_x, pc_mouse_y, pc_mouse_b);
+ }
+} ENDOFUNC(mouse)
+
+void pc_remove_mouse (void)
+{
+ if (mouse_callback) {
+ pc_clexit(pc_remove_mouse);
+ __asm__("\n\
+ movl %%edx, %%ecx \n\
+ shrl $16, %%ecx \n\
+ movw $0x0304, %%ax \n\
+ int $0x31 \n\
+ movw $0x000c, %%ax \n\
+ xorl %%ecx, %%ecx \n\
+ int $0x33 \n\
+ "::"d"(mouse_callback):"%eax", "%ecx");
+
+ mouse_callback = 0;
+
+ free((void *)((unsigned long)mouse_stack-MOUSE_STACK_SIZE));
+ }
+}
+
+int pc_install_mouse (void)
+{
+ int buttons;
+
+ /* fail if already call-backed */
+ if (mouse_callback) {
+ return 0;
+ }
+
+ /* reset mouse and get status */
+ __asm__("\n\
+ xorl %%eax, %%eax \n\
+ int $0x33 \n\
+ andl %%ebx, %%eax \n\
+ movl %%eax, %0 \n\
+ ":"=g" (buttons)::"%eax", "%ebx");
+ if (!buttons) {
+ return 0;
+ }
+
+ /* lock wrapper */
+ LOCKDATA(mouse_func);
+ LOCKDATA(mouse_stack);
+ LOCKDATA(mouse_callback);
+ LOCKDATA(mouse_regs);
+ LOCKDATA(pc_mouse_x);
+ LOCKDATA(pc_mouse_y);
+ LOCKDATA(pc_mouse_b);
+ LOCKDATA(minx);
+ LOCKDATA(maxx);
+ LOCKDATA(miny);
+ LOCKDATA(maxy);
+ LOCKDATA(sx);
+ LOCKDATA(sy);
+ LOCKDATA(emulat3);
+ LOCKDATA(ox);
+ LOCKDATA(oy);
+ LOCKFUNC(mouse);
+ LOCKFUNC(mouse_wrapper);
+
+ /* grab a locked stack */
+ if ((mouse_stack=pc_malloc(MOUSE_STACK_SIZE))==NULL) {
+ return 0;
+ }
+
+ /* try to hook a call-back */
+ __asm__("\n\
+ pushl %%ds \n\
+ pushl %%es \n\
+ movw $0x0303, %%ax \n\
+ pushl %%ds \n\
+ pushl %%cs \n\
+ popl %%ds \n\
+ popl %%es \n\
+ int $0x31 \n\
+ popl %%es \n\
+ popl %%ds \n\
+ jc 0f \n\
+ shll $16, %%ecx \n\
+ movw %%dx, %%cx \n\
+ movl %%ecx, %0 \n\
+ 0: \n\
+ ":"=g"(mouse_callback)
+ :"S" (mouse_wrapper), "D"(&mouse_regs)
+ :"%eax", "%ecx", "%edx");
+ if (!mouse_callback) {
+ free(mouse_stack);
+ return 0;
+ }
+
+ /* adjust stack */
+ mouse_stack = (void *)((unsigned long)mouse_stack + MOUSE_STACK_SIZE);
+
+ /* install the handler */
+ mouse_regs.x.ax = 0x000c;
+ mouse_regs.x.cx = 0x007f;
+ mouse_regs.x.dx = mouse_callback&0xffff;
+ mouse_regs.x.es = mouse_callback>>16;
+ __dpmi_int(0x33, &mouse_regs);
+
+ emulat3 = buttons<3;
+ pc_atexit(pc_remove_mouse);
+ return buttons;
+}
+
+MFUNC pc_install_mouse_handler (MFUNC handler)
+{
+ MFUNC old;
+
+ if (!mouse_callback && !pc_install_mouse()) {
+ return NULL;
+ }
+
+ old = mouse_func;
+ mouse_func = handler;
+ return old;
+}
+
+void pc_mouse_area (int x1, int y1, int x2, int y2)
+{
+ minx = x1;
+ maxx = x2;
+ miny = y1;
+ maxy = y2;
+}
+
+void pc_mouse_speed (int xspeed, int yspeed)
+{
+ DISABLE();
+
+ sx = MAX(1, xspeed);
+ sy = MAX(1, yspeed);
+
+ ENABLE();
+}
+
+void pc_show_mouse (void)
+{
+ /* not implemented */
+}
+void pc_scare_mouse (void)
+{
+ /* not implemented */
+}
+void pc_unscare_mouse (void)
+{
+ /* not implemented */
+}
+
+__asm__("\n\
+ .balign 4 \n\
+ .global _mouse_wrapper \n\
+_mouse_wrapper: \n\
+ cld \n\
+ lodsl \n\
+ movl %eax, %es:42(%edi) \n\
+ addw $4, %es:46(%edi) \n\
+ pushl %es \n\
+ movl %ss, %ebx \n\
+ movl %esp, %esi \n\
+ movl %cs:___djgpp_ds_alias, %ss \n\
+ movl %cs:_mouse_stack, %esp \n\
+ pushl %ss \n\
+ pushl %ss \n\
+ popl %es \n\
+ popl %ds \n\
+ movl ___djgpp_dos_sel, %fs \n\
+ pushl %fs \n\
+ popl %gs \n\
+ pushl %edi \n\
+ call _mouse \n\
+ popl %edi \n\
+ movl %ebx, %ss \n\
+ movl %esi, %esp \n\
+ popl %es \n\
+ iret \n\
+ \n\
+ .balign 4 \n\
+ .global _mouse_wrapper_end \n\
+_mouse_wrapper_end:");
diff --git a/src/glut/dos/PC_HW/pc_timer.c b/src/glut/dos/PC_HW/pc_timer.c
new file mode 100644
index 0000000000..a8c58f6741
--- /dev/null
+++ b/src/glut/dos/PC_HW/pc_timer.c
@@ -0,0 +1,158 @@
+/*
+ * PC/HW routine collection v0.1 for DOS/DJGPP
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <pc.h>
+
+#include "pc_hw.h"
+
+#define TIMER_IRQ 0
+
+#define MAX_TIMERS 8
+
+#define PIT_FREQ 0x1234DD
+
+#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})
+
+static int timer_installed;
+
+typedef struct {
+ volatile unsigned int counter, clock_ticks, freq;
+ volatile PFUNC func;
+ volatile void *parm;
+} TIMER;
+
+TIMER timer_main, timer_func[MAX_TIMERS];
+
+static int timer ()
+{
+ int i;
+
+ for (i=0;i<MAX_TIMERS;i++) {
+ TIMER *t = &timer_func[i];
+ if (t->func) {
+ t->clock_ticks += t->counter;
+ if (t->clock_ticks>=timer_main.counter) {
+ t->clock_ticks -= timer_main.counter;
+ t->func(unvolatile(t->parm, void *));
+ }
+ }
+ }
+
+ timer_main.clock_ticks += timer_main.counter;
+ if (timer_main.clock_ticks>=0x10000) {
+ timer_main.clock_ticks -= 0x10000;
+ return 1;
+ } else {
+ outportb(0x20, 0x20);
+ return 0;
+ }
+} ENDOFUNC(timer)
+
+void pc_remove_timer (void)
+{
+ if (timer_installed) {
+ timer_installed = FALSE;
+ pc_clexit(pc_remove_timer);
+
+ DISABLE();
+ outportb(0x43, 0x34);
+ outportb(0x40, 0);
+ outportb(0x40, 0);
+ ENABLE();
+
+ pc_remove_irq(TIMER_IRQ);
+ }
+}
+
+static int install_timer (void)
+{
+ if (timer_installed||pc_install_irq(TIMER_IRQ, timer)) {
+ return -1;
+ } else {
+ LOCKDATA(timer_func);
+ LOCKDATA(timer_main);
+ LOCKFUNC(timer);
+
+ timer_main.counter = 0x10000;
+
+ DISABLE();
+ outportb(0x43, 0x34);
+ outportb(0x40, 0);
+ outportb(0x40, 0);
+ timer_main.clock_ticks = 0;
+ ENABLE();
+
+ pc_atexit(pc_remove_timer);
+ timer_installed = TRUE;
+ return 0;
+ }
+}
+
+static TIMER *find_slot (PFUNC func)
+{
+ int i;
+
+ for (i=0;i<MAX_TIMERS;i++) {
+ if (timer_func[i].func==func) {
+ return &timer_func[i];
+ }
+ }
+ for (i=0;i<MAX_TIMERS;i++) {
+ if (!timer_func[i].func) {
+ return &timer_func[i];
+ }
+ }
+
+ return NULL;
+}
+
+int pc_install_int (PFUNC func, void *parm, unsigned int freq)
+{
+ int i;
+ TIMER *t;
+
+ if (!timer_installed) {
+ if (install_timer()) {
+ return -1;
+ }
+ }
+
+ if ((t=find_slot(func))!=NULL) {
+ unsigned int new_counter = PIT_FREQ / freq;
+
+ DISABLE();
+
+ t->func = func;
+ t->parm = parm;
+ t->freq = freq;
+ t->clock_ticks = 0;
+
+ if (new_counter < timer_main.counter) {
+ for (i=0;i<MAX_TIMERS;i++) {
+ if (timer_func[i].func) {
+ timer_func[i].counter = new_counter * timer_func[i].freq / freq;
+ }
+ }
+ outportb(0x43, 0x34);
+ outportb(0x40, (unsigned char)new_counter);
+ outportb(0x40, (unsigned char)(new_counter>>8));
+ timer_main.clock_ticks = 0;
+ timer_main.counter = new_counter;
+ timer_main.freq = freq;
+ } else {
+ t->counter = PIT_FREQ * freq / (timer_main.freq * timer_main.freq);
+ }
+
+ ENABLE();
+
+ return 0;
+ }
+
+ return -1;
+}
diff --git a/src/glut/dos/callback.c b/src/glut/dos/callback.c
new file mode 100644
index 0000000000..0e49c3adfe
--- /dev/null
+++ b/src/glut/dos/callback.c
@@ -0,0 +1,152 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+#include "internal.h"
+
+
+void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))
+{
+ display_func = func;
+}
+
+
+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))
+{
+ keyboard_func = func;
+}
+
+
+void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
+{
+ mouse_func = func;
+}
+
+
+void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+{
+ motion_func = func;
+}
+
+
+void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+{
+ passive_motion_func = func;
+}
+
+
+void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))
+{
+ entry_func = func;
+}
+
+
+void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))
+{
+ visibility_func = func;
+}
+
+
+void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))
+{
+ idle_func = func;
+}
+
+
+void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)
+{
+}
+
+
+void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))
+{
+ menu_state_func = func;
+}
+
+
+void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))
+{
+ special_func = func;
+}
+
+
+void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
+{
+}
+
+
+void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
+{
+}
+
+
+void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))
+{
+}
+
+
+void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))
+{
+}
+
+
+void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))
+{
+}
+
+
+void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
+{
+}
+
+
+void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
+{
+}
+
+
+void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))
+{
+}
+
+
+void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))
+{
+}
+
+
+void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))
+{
+}
diff --git a/src/glut/dos/color.c b/src/glut/dos/color.c
new file mode 100644
index 0000000000..b755459a3b
--- /dev/null
+++ b/src/glut/dos/color.c
@@ -0,0 +1,46 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+
+
+void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
+{
+}
+
+
+GLfloat APIENTRY glutGetColor (int ndx, int component)
+{
+ return 0.0;
+}
+
+
+void APIENTRY glutCopyColormap (int win)
+{
+}
diff --git a/src/glut/dos/depend b/src/glut/dos/depend
new file mode 100644
index 0000000000..b78eaa9e20
--- /dev/null
+++ b/src/glut/dos/depend
@@ -0,0 +1,18 @@
+callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+color.o: color.c ../include/GL/glut.h
+font.o: font.c ../include/GL/glut.h
+globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+menu.o: menu.c ../include/GL/glut.h
+models.o: models.c ../include/GL/glut.h
+overlay.o: overlay.c ../include/GL/glut.h
+state.o: state.c ../include/GL/glut.h
+teapot.o: teapot.c ../include/GL/glut.h
+window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \
+ PC_HW/pc_hw.h
+
+PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h
+PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h
+PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h
+PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h
+PC_HW/pc_irq.o: PC_HW/pc_irq.S
diff --git a/src/glut/dos/font.c b/src/glut/dos/font.c
new file mode 100644
index 0000000000..c1303ff6f4
--- /dev/null
+++ b/src/glut/dos/font.c
@@ -0,0 +1,52 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+
+
+void APIENTRY glutBitmapCharacter (void *font, int character)
+{
+}
+
+
+int APIENTRY glutBitmapWidth (void *font, int character)
+{
+ return 0;
+}
+
+
+void APIENTRY glutStrokeCharacter (void *font, int character)
+{
+}
+
+
+int APIENTRY glutStrokeWidth (void *font, int character)
+{
+ return 0;
+}
diff --git a/src/glut/dos/globals.c b/src/glut/dos/globals.c
new file mode 100644
index 0000000000..9bdfe8e0ce
--- /dev/null
+++ b/src/glut/dos/globals.c
@@ -0,0 +1,61 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+#include "internal.h"
+
+GLenum g_display_mode = 0;
+GLuint g_width = DEFAULT_WIDTH;
+GLuint g_height = DEFAULT_HEIGHT;
+GLint g_mouse = GL_FALSE;
+GLboolean g_redisplay = GL_FALSE;
+GLint g_xpos = 0;
+GLint g_ypos = 0;
+
+void (GLUTCALLBACK *display_func) (void) = NULL;
+void (GLUTCALLBACK *reshape_func) (int width, int height) = NULL;
+void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = NULL;
+void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = NULL;
+void (GLUTCALLBACK *motion_func) (int x, int y) = NULL;
+void (GLUTCALLBACK *passive_motion_func) (int x, int y) = NULL;
+void (GLUTCALLBACK *entry_func) (int state) = NULL;
+void (GLUTCALLBACK *visibility_func) (int state) = NULL;
+void (GLUTCALLBACK *idle_func) (void) = NULL;
+void (GLUTCALLBACK *menu_state_func) (int state) = NULL;
+void (GLUTCALLBACK *special_func) (int key, int x, int y) = NULL;
+void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = NULL;
+void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = NULL;
+void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = NULL;
+void (GLUTCALLBACK *button_box_func) (int button, int state) = NULL;
+void (GLUTCALLBACK *dials_func) (int dial, int value) = NULL;
+void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = NULL;
+void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = NULL;
+void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = NULL;
+void (GLUTCALLBACK *overlay_display_func) (void) = NULL;
+void (GLUTCALLBACK *window_status_func) (int state) = NULL;
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c
new file mode 100644
index 0000000000..d3f4582170
--- /dev/null
+++ b/src/glut/dos/init.c
@@ -0,0 +1,168 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include <signal.h>
+#include "GL/glut.h"
+#include "internal.h"
+
+
+static void *old_sig_int = NULL;
+
+
+static void signal_handler (int num)
+{
+ signal(SIGINT, old_sig_int);
+
+ raise(num);
+}
+
+
+void APIENTRY glutInit (int *argcp, char **argv)
+{
+ /* Hack alert:
+ only SIGINT (but not Ctrl-Break)
+ calls the destructors and will safely clean up
+ */
+ old_sig_int = signal(SIGINT, signal_handler);
+}
+
+
+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;
+}
+
+
+void APIENTRY glutInitWindowSize (int width, int height)
+{
+ g_width = width;
+ g_height = height;
+}
+
+
+void APIENTRY glutMainLoop (void)
+{
+ GLboolean idle;
+ static int old_mouse_x = 0;
+ static int old_mouse_y = 0;
+ static int old_mouse_b = 0;
+
+ glutPostRedisplay();
+ if (reshape_func) reshape_func(g_width, g_height);
+ if (visibility_func) visibility_func(GLUT_VISIBLE);
+ if (g_mouse) pc_show_mouse();
+
+ while (GL_TRUE) {
+ idle = GL_TRUE;
+
+ if (g_redisplay && display_func) {
+ 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_mouse && motion_func && ((pc_mouse_x != old_mouse_x) || (pc_mouse_y != old_mouse_y))) {
+ idle = GL_FALSE;
+ old_mouse_x = pc_mouse_x;
+ old_mouse_y = pc_mouse_y;
+
+ motion_func(old_mouse_x, old_mouse_y);
+ }
+
+ if (g_mouse && mouse_func && (pc_mouse_b != old_mouse_b)) {
+ int new_mouse_b = pc_mouse_b;
+
+ if ((old_mouse_b & 1) && !(new_mouse_b & 1))
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
+ else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
+
+ if ((old_mouse_b & 2) && !(new_mouse_b & 2))
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
+ else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
+
+ if ((old_mouse_b & 4) && !(new_mouse_b & 4))
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);
+ else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);
+
+ idle = GL_FALSE;
+ old_mouse_b = new_mouse_b;
+ }
+
+ if (idle && idle_func)
+ idle_func();
+ }
+}
diff --git a/src/glut/dos/internal.h b/src/glut/dos/internal.h
new file mode 100644
index 0000000000..f6c2c4d00c
--- /dev/null
+++ b/src/glut/dos/internal.h
@@ -0,0 +1,76 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef INTERNAL_H_included
+#define INTERNAL_H_included
+
+
+#include "GL/glut.h"
+#include "pc_hw/pc_hw.h"
+
+
+#define DEFAULT_WIDTH 640
+#define DEFAULT_HEIGHT 480
+#define COLOR_DEPTH 16
+
+#define DEPTH_SIZE 16
+#define STENCIL_SIZE 8
+#define ACCUM_SIZE 16
+
+extern GLenum g_display_mode;
+extern GLuint g_width;
+extern GLuint g_height;
+extern GLint g_mouse;
+extern GLboolean g_redisplay;
+extern GLint g_xpos;
+extern GLint g_ypos;
+
+extern void (GLUTCALLBACK *display_func) (void);
+extern void (GLUTCALLBACK *reshape_func) (int width, int height);
+extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y);
+extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y);
+extern void (GLUTCALLBACK *motion_func) (int x, int y);
+extern void (GLUTCALLBACK *passive_motion_func) (int x, int y);
+extern void (GLUTCALLBACK *entry_func) (int state);
+extern void (GLUTCALLBACK *visibility_func) (int state);
+extern void (GLUTCALLBACK *idle_func) (void);
+extern void (GLUTCALLBACK *menu_state_func) (int state);
+extern void (GLUTCALLBACK *special_func) (int key, int x, int y);
+extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z);
+extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z);
+extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state);
+extern void (GLUTCALLBACK *button_box_func) (int button, int state);
+extern void (GLUTCALLBACK *dials_func) (int dial, int value);
+extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y);
+extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y);
+extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y);
+extern void (GLUTCALLBACK *overlay_display_func) (void);
+extern void (GLUTCALLBACK *window_status_func) (int state);
+
+#endif
diff --git a/src/glut/dos/menu.c b/src/glut/dos/menu.c
new file mode 100644
index 0000000000..48354edfe7
--- /dev/null
+++ b/src/glut/dos/menu.c
@@ -0,0 +1,86 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+
+
+int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))
+{
+ 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/models.c b/src/glut/dos/models.c
new file mode 100644
index 0000000000..83729df7c4
--- /dev/null
+++ b/src/glut/dos/models.c
@@ -0,0 +1,598 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
+
+/**
+(c) Copyright 1993, Silicon Graphics, Inc.
+
+ALL RIGHTS RESERVED
+
+Permission to use, copy, modify, and distribute this software
+for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that
+both the copyright notice and this permission notice appear in
+supporting documentation, and that the name of Silicon
+Graphics, Inc. not be used in advertising or publicity
+pertaining to distribution of the software without specific,
+written prior permission.
+
+THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
+"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
+OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
+EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
+ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
+INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
+SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
+NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
+OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+US Government Users Restricted Rights
+
+Use, duplication, or disclosure by the Government is subject to
+restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+(c)(1)(ii) of the Rights in Technical Data and Computer
+Software clause at DFARS 252.227-7013 and/or in similar or
+successor clauses in the FAR or the DOD or NASA FAR
+Supplement. Unpublished-- rights reserved under the copyright
+laws of the United States. Contractor/manufacturer is Silicon
+Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
+94039-7311.
+
+OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+*/
+
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include "GL/glut.h"
+
+/* Some <math.h> files do not define M_PI... */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+static GLUquadricObj *quadObj;
+
+#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
+
+static void
+initQuadObj(void)
+{
+ quadObj = gluNewQuadric();
+/* if (!quadObj)
+ __glutFatalError("out of memory."); */
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
+{
+ QUAD_OBJ_INIT();
+ gluQuadricDrawStyle(quadObj, GLU_LINE);
+ gluQuadricNormals(quadObj, GLU_SMOOTH);
+ /* If we ever changed/used the texture or orientation state
+ of quadObj, we'd need to change it to the defaults here
+ with gluQuadricTexture and/or gluQuadricOrientation. */
+ gluSphere(quadObj, radius, slices, stacks);
+}
+
+void APIENTRY
+glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
+{
+ QUAD_OBJ_INIT();
+ gluQuadricDrawStyle(quadObj, GLU_FILL);
+ gluQuadricNormals(quadObj, GLU_SMOOTH);
+ /* If we ever changed/used the texture or orientation state
+ of quadObj, we'd need to change it to the defaults here
+ with gluQuadricTexture and/or gluQuadricOrientation. */
+ gluSphere(quadObj, radius, slices, stacks);
+}
+
+void APIENTRY
+glutWireCone(GLdouble base, GLdouble height,
+ GLint slices, GLint stacks)
+{
+ QUAD_OBJ_INIT();
+ gluQuadricDrawStyle(quadObj, GLU_LINE);
+ gluQuadricNormals(quadObj, GLU_SMOOTH);
+ /* If we ever changed/used the texture or orientation state
+ of quadObj, we'd need to change it to the defaults here
+ with gluQuadricTexture and/or gluQuadricOrientation. */
+ gluCylinder(quadObj, base, 0.0, height, slices, stacks);
+}
+
+void APIENTRY
+glutSolidCone(GLdouble base, GLdouble height,
+ GLint slices, GLint stacks)
+{
+ QUAD_OBJ_INIT();
+ gluQuadricDrawStyle(quadObj, GLU_FILL);
+ gluQuadricNormals(quadObj, GLU_SMOOTH);
+ /* If we ever changed/used the texture or orientation state
+ of quadObj, we'd need to change it to the defaults here
+ with gluQuadricTexture and/or gluQuadricOrientation. */
+ gluCylinder(quadObj, base, 0.0, height, slices, stacks);
+}
+
+/* ENDCENTRY */
+
+static void
+drawBox(GLfloat size, GLenum type)
+{
+ static GLfloat n[6][3] =
+ {
+ {-1.0, 0.0, 0.0},
+ {0.0, 1.0, 0.0},
+ {1.0, 0.0, 0.0},
+ {0.0, -1.0, 0.0},
+ {0.0, 0.0, 1.0},
+ {0.0, 0.0, -1.0}
+ };
+ static GLint faces[6][4] =
+ {
+ {0, 1, 2, 3},
+ {3, 2, 6, 7},
+ {7, 6, 5, 4},
+ {4, 5, 1, 0},
+ {5, 6, 2, 1},
+ {7, 4, 0, 3}
+ };
+ GLfloat v[8][3];
+ GLint i;
+
+ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
+ v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
+ v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
+ v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
+
+ for (i = 5; i >= 0; i--) {
+ glBegin(type);
+ glNormal3fv(&n[i][0]);
+ glVertex3fv(&v[faces[i][0]][0]);
+ glVertex3fv(&v[faces[i][1]][0]);
+ glVertex3fv(&v[faces[i][2]][0]);
+ glVertex3fv(&v[faces[i][3]][0]);
+ glEnd();
+ }
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireCube(GLdouble size)
+{
+ drawBox(size, GL_LINE_LOOP);
+}
+
+void APIENTRY
+glutSolidCube(GLdouble size)
+{
+ drawBox(size, GL_QUADS);
+}
+
+/* ENDCENTRY */
+
+static void
+doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
+{
+ int i, j;
+ GLfloat theta, phi, theta1;
+ GLfloat cosTheta, sinTheta;
+ GLfloat cosTheta1, sinTheta1;
+ GLfloat ringDelta, sideDelta;
+
+ ringDelta = 2.0 * M_PI / rings;
+ sideDelta = 2.0 * M_PI / nsides;
+
+ theta = 0.0;
+ cosTheta = 1.0;
+ sinTheta = 0.0;
+ for (i = rings - 1; i >= 0; i--) {
+ theta1 = theta + ringDelta;
+ cosTheta1 = cos(theta1);
+ sinTheta1 = sin(theta1);
+ glBegin(GL_QUAD_STRIP);
+ phi = 0.0;
+ for (j = nsides; j >= 0; j--) {
+ GLfloat cosPhi, sinPhi, dist;
+
+ phi += sideDelta;
+ cosPhi = cos(phi);
+ sinPhi = sin(phi);
+ dist = R + r * cosPhi;
+
+ glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
+ glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
+ glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
+ glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
+ }
+ glEnd();
+ theta = theta1;
+ cosTheta = cosTheta1;
+ sinTheta = sinTheta1;
+ }
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
+ GLint nsides, GLint rings)
+{
+ glPushAttrib(GL_POLYGON_BIT);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ doughnut(innerRadius, outerRadius, nsides, rings);
+ glPopAttrib();
+}
+
+void APIENTRY
+glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
+ GLint nsides, GLint rings)
+{
+ doughnut(innerRadius, outerRadius, nsides, rings);
+}
+
+/* ENDCENTRY */
+
+static GLfloat dodec[20][3];
+
+static void
+initDodecahedron(void)
+{
+ GLfloat alpha, beta;
+
+ alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
+ beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
+ 2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
+ /* *INDENT-OFF* */
+ dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
+ dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
+ dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
+ dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
+ dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
+ dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
+ dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
+ dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
+ dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
+ dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
+ dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
+ dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
+ dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
+ dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
+ dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
+ dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
+ dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
+ dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
+ dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
+ dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
+ /* *INDENT-ON* */
+
+}
+
+#define DIFF3(_a,_b,_c) { \
+ (_c)[0] = (_a)[0] - (_b)[0]; \
+ (_c)[1] = (_a)[1] - (_b)[1]; \
+ (_c)[2] = (_a)[2] - (_b)[2]; \
+}
+
+static void
+crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
+{
+ GLfloat p[3]; /* in case prod == v1 or v2 */
+
+ p[0] = v1[1] * v2[2] - v2[1] * v1[2];
+ p[1] = v1[2] * v2[0] - v2[2] * v1[0];
+ p[2] = v1[0] * v2[1] - v2[0] * v1[1];
+ prod[0] = p[0];
+ prod[1] = p[1];
+ prod[2] = p[2];
+}
+
+static void
+normalize(GLfloat v[3])
+{
+ GLfloat d;
+
+ d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+ if (d == 0.0) {
+// __glutWarning("normalize: zero length vector");
+ v[0] = d = 1.0;
+ }
+ d = 1 / d;
+ v[0] *= d;
+ v[1] *= d;
+ v[2] *= d;
+}
+
+static void
+pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
+{
+ GLfloat n0[3], d1[3], d2[3];
+
+ DIFF3(dodec[a], dodec[b], d1);
+ DIFF3(dodec[b], dodec[c], d2);
+ crossprod(d1, d2, n0);
+ normalize(n0);
+
+ glBegin(shadeType);
+ glNormal3fv(n0);
+ glVertex3fv(&dodec[a][0]);
+ glVertex3fv(&dodec[b][0]);
+ glVertex3fv(&dodec[c][0]);
+ glVertex3fv(&dodec[d][0]);
+ glVertex3fv(&dodec[e][0]);
+ glEnd();
+}
+
+static void
+dodecahedron(GLenum type)
+{
+ static int inited = 0;
+
+ if (inited == 0) {
+ inited = 1;
+ initDodecahedron();
+ }
+ pentagon(0, 1, 9, 16, 5, type);
+ pentagon(1, 0, 3, 18, 7, type);
+ pentagon(1, 7, 11, 10, 9, type);
+ pentagon(11, 7, 18, 19, 6, type);
+ pentagon(8, 17, 16, 9, 10, type);
+ pentagon(2, 14, 15, 6, 19, type);
+ pentagon(2, 13, 12, 4, 14, type);
+ pentagon(2, 19, 18, 3, 13, type);
+ pentagon(3, 0, 5, 12, 13, type);
+ pentagon(6, 15, 8, 10, 11, type);
+ pentagon(4, 17, 8, 15, 14, type);
+ pentagon(4, 12, 5, 16, 17, type);
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireDodecahedron(void)
+{
+ dodecahedron(GL_LINE_LOOP);
+}
+
+void APIENTRY
+glutSolidDodecahedron(void)
+{
+ dodecahedron(GL_TRIANGLE_FAN);
+}
+
+/* ENDCENTRY */
+
+static void
+recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
+ GLenum shadeType)
+{
+ GLfloat q0[3], q1[3];
+
+ DIFF3(n1, n2, q0);
+ DIFF3(n2, n3, q1);
+ crossprod(q0, q1, q1);
+ normalize(q1);
+
+ glBegin(shadeType);
+ glNormal3fv(q1);
+ glVertex3fv(n1);
+ glVertex3fv(n2);
+ glVertex3fv(n3);
+ glEnd();
+}
+
+static void
+subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
+ GLenum shadeType)
+{
+ int depth;
+ GLfloat w0[3], w1[3], w2[3];
+ GLfloat l;
+ int i, j, k, n;
+
+ depth = 1;
+ for (i = 0; i < depth; i++) {
+ for (j = 0; i + j < depth; j++) {
+ k = depth - i - j;
+ for (n = 0; n < 3; n++) {
+ w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
+ w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
+ / depth;
+ w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
+ / depth;
+ }
+ l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
+ w0[0] /= l;
+ w0[1] /= l;
+ w0[2] /= l;
+ l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
+ w1[0] /= l;
+ w1[1] /= l;
+ w1[2] /= l;
+ l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
+ w2[0] /= l;
+ w2[1] /= l;
+ w2[2] /= l;
+ recorditem(w1, w0, w2, shadeType);
+ }
+ }
+}
+
+static void
+drawtriangle(int i, GLfloat data[][3], int ndx[][3],
+ GLenum shadeType)
+{
+ GLfloat *x0, *x1, *x2;
+
+ x0 = data[ndx[i][0]];
+ x1 = data[ndx[i][1]];
+ x2 = data[ndx[i][2]];
+ subdivide(x0, x1, x2, shadeType);
+}
+
+/* octahedron data: The octahedron produced is centered at the
+ origin and has radius 1.0 */
+static GLfloat odata[6][3] =
+{
+ {1.0, 0.0, 0.0},
+ {-1.0, 0.0, 0.0},
+ {0.0, 1.0, 0.0},
+ {0.0, -1.0, 0.0},
+ {0.0, 0.0, 1.0},
+ {0.0, 0.0, -1.0}
+};
+
+static int ondex[8][3] =
+{
+ {0, 4, 2},
+ {1, 2, 4},
+ {0, 3, 4},
+ {1, 4, 3},
+ {0, 2, 5},
+ {1, 5, 2},
+ {0, 5, 3},
+ {1, 3, 5}
+};
+
+static void
+octahedron(GLenum shadeType)
+{
+ int i;
+
+ for (i = 7; i >= 0; i--) {
+ drawtriangle(i, odata, ondex, shadeType);
+ }
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireOctahedron(void)
+{
+ octahedron(GL_LINE_LOOP);
+}
+
+void APIENTRY
+glutSolidOctahedron(void)
+{
+ octahedron(GL_TRIANGLES);
+}
+
+/* ENDCENTRY */
+
+/* icosahedron data: These numbers are rigged to make an
+ icosahedron of radius 1.0 */
+
+#define X .525731112119133606
+#define Z .850650808352039932
+
+static GLfloat idata[12][3] =
+{
+ {-X, 0, Z},
+ {X, 0, Z},
+ {-X, 0, -Z},
+ {X, 0, -Z},
+ {0, Z, X},
+ {0, Z, -X},
+ {0, -Z, X},
+ {0, -Z, -X},
+ {Z, X, 0},
+ {-Z, X, 0},
+ {Z, -X, 0},
+ {-Z, -X, 0}
+};
+
+static int index[20][3] =
+{
+ {0, 4, 1},
+ {0, 9, 4},
+ {9, 5, 4},
+ {4, 5, 8},
+ {4, 8, 1},
+ {8, 10, 1},
+ {8, 3, 10},
+ {5, 3, 8},
+ {5, 2, 3},
+ {2, 7, 3},
+ {7, 10, 3},
+ {7, 6, 10},
+ {7, 11, 6},
+ {11, 0, 6},
+ {0, 1, 6},
+ {6, 1, 10},
+ {9, 0, 11},
+ {9, 11, 2},
+ {9, 2, 5},
+ {7, 2, 11},
+};
+
+static void
+icosahedron(GLenum shadeType)
+{
+ int i;
+
+ for (i = 19; i >= 0; i--) {
+ drawtriangle(i, idata, index, shadeType);
+ }
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireIcosahedron(void)
+{
+ icosahedron(GL_LINE_LOOP);
+}
+
+void APIENTRY
+glutSolidIcosahedron(void)
+{
+ icosahedron(GL_TRIANGLES);
+}
+
+/* ENDCENTRY */
+
+/* tetrahedron data: */
+
+#define T 1.73205080756887729
+
+static GLfloat tdata[4][3] =
+{
+ {T, T, T},
+ {T, -T, -T},
+ {-T, T, -T},
+ {-T, -T, T}
+};
+
+static int tndex[4][3] =
+{
+ {0, 1, 3},
+ {2, 1, 0},
+ {3, 2, 0},
+ {1, 2, 3}
+};
+
+static void
+tetrahedron(GLenum shadeType)
+{
+ int i;
+
+ for (i = 3; i >= 0; i--)
+ drawtriangle(i, tdata, tndex, shadeType);
+}
+
+/* CENTRY */
+void APIENTRY
+glutWireTetrahedron(void)
+{
+ tetrahedron(GL_LINE_LOOP);
+}
+
+void APIENTRY
+glutSolidTetrahedron(void)
+{
+ tetrahedron(GL_TRIANGLES);
+}
+
+/* ENDCENTRY */
diff --git a/src/glut/dos/overlay.c b/src/glut/dos/overlay.c
new file mode 100644
index 0000000000..b2c392fcd4
--- /dev/null
+++ b/src/glut/dos/overlay.c
@@ -0,0 +1,60 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+
+
+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
new file mode 100644
index 0000000000..9e5624deb4
--- /dev/null
+++ b/src/glut/dos/state.c
@@ -0,0 +1,47 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+
+
+int APIENTRY glutGet (GLenum type)
+{
+ switch (type) {
+ case GLUT_WINDOW_RGBA:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
+int APIENTRY glutDeviceGet (GLenum type)
+{
+ return 0;
+}
diff --git a/src/glut/dos/teapot.c b/src/glut/dos/teapot.c
new file mode 100644
index 0000000000..b75a97dd26
--- /dev/null
+++ b/src/glut/dos/teapot.c
@@ -0,0 +1,212 @@
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/**
+(c) Copyright 1993, Silicon Graphics, Inc.
+
+ALL RIGHTS RESERVED
+
+Permission to use, copy, modify, and distribute this software
+for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that
+both the copyright notice and this permission notice appear in
+supporting documentation, and that the name of Silicon
+Graphics, Inc. not be used in advertising or publicity
+pertaining to distribution of the software without specific,
+written prior permission.
+
+THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
+"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
+OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
+EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
+ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
+INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
+SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
+NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
+OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+US Government Users Restricted Rights
+
+Use, duplication, or disclosure by the Government is subject to
+restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+(c)(1)(ii) of the Rights in Technical Data and Computer
+Software clause at DFARS 252.227-7013 and/or in similar or
+successor clauses in the FAR or the DOD or NASA FAR
+Supplement. Unpublished-- rights reserved under the copyright
+laws of the United States. Contractor/manufacturer is Silicon
+Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
+94039-7311.
+
+OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+*/
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include "GL/glut.h"
+
+/* Rim, body, lid, and bottom data must be reflected in x and
+ y; handle and spout data across the y axis only. */
+
+static int patchdata[][16] =
+{
+ /* rim */
+ {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15},
+ /* body */
+ {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27},
+ {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
+ 37, 38, 39, 40},
+ /* lid */
+ {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
+ 101, 0, 1, 2, 3,},
+ {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117},
+ /* bottom */
+ {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
+ 125, 120, 40, 39, 38, 37},
+ /* handle */
+ {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56},
+ {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 28, 65, 66, 67},
+ /* spout */
+ {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83},
+ {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95}
+};
+/* *INDENT-OFF* */
+
+static float cpdata[][3] =
+{
+ {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
+ -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
+ {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
+ 0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
+ 2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
+ 2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
+ {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
+ 1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
+ {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
+ 0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
+ 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
+ {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
+ {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
+ -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
+ -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
+ 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
+ 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
+ 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
+ {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
+ -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
+ 1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
+ -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
+ 1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
+ 0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
+ 0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
+ {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
+ -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
+ 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
+ {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
+ {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
+ {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
+ 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
+ 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
+ -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
+ 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
+ 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
+ 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
+ {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
+ -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
+ 0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
+ {0.84, -1.5, 0.075}
+};
+
+static float tex[2][2][2] =
+{
+ { {0, 0},
+ {1, 0}},
+ { {0, 1},
+ {1, 1}}
+};
+
+/* *INDENT-ON* */
+
+static void
+teapot(GLint grid, GLdouble scale, GLenum type)
+{
+ float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
+ long i, j, k, l;
+
+ glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
+ glEnable(GL_AUTO_NORMAL);
+ glEnable(GL_NORMALIZE);
+ glEnable(GL_MAP2_VERTEX_3);
+ glEnable(GL_MAP2_TEXTURE_COORD_2);
+ glPushMatrix();
+ glRotatef(270.0, 1.0, 0.0, 0.0);
+ glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
+ glTranslatef(0.0, 0.0, -1.5);
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 4; j++) {
+ for (k = 0; k < 4; k++) {
+ for (l = 0; l < 3; l++) {
+ p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
+ q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 1)
+ q[j][k][l] *= -1.0;
+ if (i < 6) {
+ r[j][k][l] =
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 0)
+ r[j][k][l] *= -1.0;
+ s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
+ if (l == 0)
+ s[j][k][l] *= -1.0;
+ if (l == 1)
+ s[j][k][l] *= -1.0;
+ }
+ }
+ }
+ }
+ glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
+ &tex[0][0][0]);
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
+ &p[0][0][0]);
+ glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
+ &q[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ if (i < 6) {
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
+ &r[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
+ &s[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ }
+ }
+ glPopMatrix();
+ glPopAttrib();
+}
+
+/* CENTRY */
+void APIENTRY
+glutSolidTeapot(GLdouble scale)
+{
+ teapot(7, scale, GL_FILL);
+}
+
+void APIENTRY
+glutWireTeapot(GLdouble scale)
+{
+ teapot(10, scale, GL_LINE);
+}
+
+/* ENDCENTRY */
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c
new file mode 100644
index 0000000000..6d52524dfb
--- /dev/null
+++ b/src/glut/dos/window.c
@@ -0,0 +1,160 @@
+/*
+ * 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 v0.1 for Mesa 4.0
+ *
+ * Copyright (C) 2002 - Borca Daniel
+ * Email : dborca@yahoo.com
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#include "GL/glut.h"
+#include "GL/dmesa.h"
+#include "internal.h"
+
+
+static DMesaVisual visual = NULL;
+static DMesaContext context = NULL;
+static DMesaBuffer buffer = NULL;
+
+
+static void clean (void)
+{
+ __asm__("movw $3, %%ax; int $0x10":::"%eax");
+ pc_close_stdout();
+ pc_close_stderr();
+}
+
+int APIENTRY glutCreateWindow (const char *title)
+{
+ if ((visual=DMesaCreateVisual(COLOR_DEPTH,
+ g_display_mode & GLUT_DOUBLE,
+ g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,
+ g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,
+ g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {
+ return GL_FALSE;
+ }
+
+ if ((context=DMesaCreateContext(visual, NULL))==NULL) {
+ DMesaDestroyVisual(visual);
+ return GL_FALSE;
+ }
+
+ if ((buffer=DMesaCreateBuffer(visual, g_width, g_height, g_xpos, g_ypos))==NULL) {
+ DMesaDestroyContext(context);
+ DMesaDestroyVisual(visual);
+ return GL_FALSE;
+ }
+
+ if (!DMesaMakeCurrent(context, buffer)) {
+ DMesaDestroyContext(context);
+ DMesaDestroyVisual(visual);
+ return GL_FALSE;
+ }
+
+ pc_open_stdout();
+ pc_open_stderr();
+ pc_atexit(clean);
+
+ return GL_TRUE;
+}
+
+
+int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
+{
+ return GL_FALSE;
+}
+
+
+void APIENTRY glutDestroyWindow (int win)
+{
+}
+
+
+void APIENTRY glutPostRedisplay (void)
+{
+ g_redisplay = GL_TRUE;
+}
+
+
+void APIENTRY glutSwapBuffers (void)
+{
+ if (g_mouse) pc_scare_mouse();
+ DMesaSwapBuffers(buffer);
+ if (g_mouse) pc_unscare_mouse();
+}
+
+
+int APIENTRY glutGetWindow (void)
+{
+ return 0;
+}
+
+
+void APIENTRY glutSetWindow (int win)
+{
+}
+
+
+void APIENTRY glutSetWindowTitle (const char *title)
+{
+}
+
+
+void APIENTRY glutSetIconTitle (const char *title)
+{
+}
+
+
+void APIENTRY glutPositionWindow (int x, int y)
+{
+}
+
+
+void APIENTRY glutReshapeWindow (int width, int height)
+{
+}
+
+
+void APIENTRY glutPopWindow (void)
+{
+}
+
+
+void APIENTRY glutPushWindow (void)
+{
+}
+
+
+void APIENTRY glutIconifyWindow (void)
+{
+}
+
+
+void APIENTRY glutShowWindow (void)
+{
+}
+
+
+void APIENTRY glutHideWindow (void)
+{
+}