diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2002-02-23 17:11:27 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2002-02-23 17:11:27 +0000 |
commit | e0193a9425807cc61779c3b8680c5b551685ba65 (patch) | |
tree | b3dacd48e37032f60b2b450a68d406d9deee2e1e /src/glut | |
parent | c7a3356746b8751fa0f04c8c0b674e26d73fdb76 (diff) |
DOS updates from Daniel Borca
Diffstat (limited to 'src/glut')
-rw-r--r-- | src/glut/dos/Makefile.DJ | 21 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_irq.S | 6 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_mouse.c | 10 | ||||
-rw-r--r-- | src/glut/dos/init.c | 3 | ||||
-rw-r--r-- | src/glut/dos/internal.h | 6 | ||||
-rw-r--r-- | src/glut/dos/state.c | 25 | ||||
-rw-r--r-- | src/glut/dos/window.c | 106 |
7 files changed, 136 insertions, 41 deletions
diff --git a/src/glut/dos/Makefile.DJ b/src/glut/dos/Makefile.DJ index a8d176cbf4..7cacd8d009 100644 --- a/src/glut/dos/Makefile.DJ +++ b/src/glut/dos/Makefile.DJ @@ -20,7 +20,7 @@ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-# DOS/DJGPP glut makefile v0.1 for Mesa 4.0
+# DOS/DJGPP glut makefile v0.2 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
@@ -78,4 +78,21 @@ clean: -$(RM) *.o
-$(RM) PC_HW\*.o
-include depend
+callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+color.o: color.c ../include/GL/glut.h
+font.o: font.c ../include/GL/glut.h
+globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h
+menu.o: menu.c ../include/GL/glut.h
+models.o: models.c ../include/GL/glut.h
+overlay.o: overlay.c ../include/GL/glut.h
+state.o: state.c ../include/GL/glut.h internal.h pc_hw/pc_hw.h
+teapot.o: teapot.c ../include/GL/glut.h
+window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \
+ PC_HW/pc_hw.h
+
+PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h
+PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h
+PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h
+PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h
+PC_HW/pc_irq.o: PC_HW/pc_irq.S
diff --git a/src/glut/dos/PC_HW/pc_irq.S b/src/glut/dos/PC_HW/pc_irq.S index 2a6302f71a..8f19f8eb9f 100644 --- a/src/glut/dos/PC_HW/pc_irq.S +++ b/src/glut/dos/PC_HW/pc_irq.S @@ -1,5 +1,5 @@ /*
- * PC/HW routine collection v0.1 for DOS/DJGPP
+ * PC/HW routine collection v0.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -129,7 +129,7 @@ __irq_wrapper_##x: ; \ pushl %es ; \
pushl %fs ; \
pushl %gs ; \
- movw %ss, %bx ; \
+ movl %ss, %ebx ; \
movl %esp, %esi ; \
movl %cs:___djgpp_ds_alias, %ss ; \
movl %cs:__irq_stack_##x, %esp ; \
@@ -141,7 +141,7 @@ __irq_wrapper_##x: ; \ pushl %fs ; \
popl %gs ; \
call *__irq_hook_##x ; \
- movw %bx, %ss ; \
+ movl %ebx, %ss ; \
movl %esi, %esp ; \
testl %eax, %eax ; \
popl %gs ; \
diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c index cc3396cb21..2a692eceb6 100644 --- a/src/glut/dos/PC_HW/pc_mouse.c +++ b/src/glut/dos/PC_HW/pc_mouse.c @@ -1,5 +1,5 @@ /*
- * PC/HW routine collection v0.1 for DOS/DJGPP
+ * PC/HW routine collection v0.2 for DOS/DJGPP
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -15,6 +15,12 @@ #define MOUSE_STACK_SIZE 16384
+#define CLEAR_MICKEYS() \
+ do { \
+ __asm__ __volatile__ ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \
+ ox = oy = 0; \
+ } while (0)
+
extern void mouse_wrapper (void);
extern void mouse_wrapper_end (void);
@@ -161,6 +167,8 @@ int pc_install_mouse (void) mouse_regs.x.es = mouse_callback>>16;
__dpmi_int(0x33, &mouse_regs);
+ CLEAR_MICKEYS();
+
emulat3 = buttons<3;
pc_atexit(pc_remove_mouse);
return buttons;
diff --git a/src/glut/dos/init.c b/src/glut/dos/init.c index d3f4582170..41170e37c9 100644 --- a/src/glut/dos/init.c +++ b/src/glut/dos/init.c @@ -19,7 +19,7 @@ */
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -45,6 +45,7 @@ static void signal_handler (int num) void APIENTRY glutInit (int *argcp, char **argv)
{
+ glutGet(GLUT_ELAPSED_TIME);
/* Hack alert:
only SIGINT (but not Ctrl-Break)
calls the destructors and will safely clean up
diff --git a/src/glut/dos/internal.h b/src/glut/dos/internal.h index f6c2c4d00c..2822c2c5ab 100644 --- a/src/glut/dos/internal.h +++ b/src/glut/dos/internal.h @@ -19,7 +19,7 @@ */
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -35,9 +35,11 @@ #include "pc_hw/pc_hw.h"
+#define MAX_WINDOWS 4
+
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
-#define COLOR_DEPTH 16
+#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c index 9e5624deb4..94ef0cac79 100644 --- a/src/glut/dos/state.c +++ b/src/glut/dos/state.c @@ -19,7 +19,7 @@ */
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -28,6 +28,21 @@ #include "GL/glut.h"
+#include "internal.h"
+
+
+#define FREQUENCY 100
+
+
+static int timer_installed;
+static volatile int ticks;
+
+static void ticks_timer (void *p)
+{
+ (void)p;
+ ticks++;
+} ENDOFUNC(ticks_timer)
+
int APIENTRY glutGet (GLenum type)
@@ -35,6 +50,14 @@ int APIENTRY glutGet (GLenum type) switch (type) {
case GLUT_WINDOW_RGBA:
return 1;
+ case GLUT_ELAPSED_TIME:
+ if (!timer_installed) {
+ timer_installed = !timer_installed;
+ LOCKDATA(ticks);
+ LOCKFUNC(ticks_timer);
+ pc_install_int(ticks_timer, NULL, FREQUENCY);
+ }
+ return ticks*1000/FREQUENCY;
default:
return 0;
}
diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c index 6d52524dfb..c110715ebb 100644 --- a/src/glut/dos/window.c +++ b/src/glut/dos/window.c @@ -19,7 +19,7 @@ */
/*
- * DOS/DJGPP glut driver v0.1 for Mesa 4.0
+ * DOS/DJGPP glut driver v0.2 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
@@ -32,50 +32,89 @@ #include "internal.h"
+
+static int window;
+
static DMesaVisual visual = NULL;
static DMesaContext context = NULL;
-static DMesaBuffer buffer = NULL;
+static DMesaBuffer buffer[MAX_WINDOWS];
+
static void clean (void)
{
- __asm__("movw $3, %%ax; int $0x10":::"%eax");
+ int i;
+
+ for (i=0; i<MAX_WINDOWS; i++) {
+ glutDestroyWindow(i+1);
+ }
+ if (context) DMesaDestroyContext(context);
+ if (visual) DMesaDestroyVisual(visual);
+
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;
+int APIENTRY glutCreateWindow (const char *title)
+{
+ int i;
+
+ if (!visual) {
+ int screen_w = DEFAULT_WIDTH;
+ int screen_h = DEFAULT_HEIGHT;
+
+ if ((g_width<=640) && (g_height<=480)) {
+ screen_w = 640;
+ screen_h = 480;
+ } else if ((g_width<=800) && (g_height<=600)) {
+ screen_w = 800;
+ screen_h = 600;
+ } else if ((g_width<=1024) && (g_height<=768)) {
+ screen_w = 1024;
+ screen_h = 768;
+ }
+
+ if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,
+ 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 0;
+ }
+
+ if ((context=DMesaCreateContext(visual, NULL))==NULL) {
+ DMesaDestroyVisual(visual);
+ return 0;
+ }
+
+ pc_open_stdout();
+ pc_open_stderr();
+ pc_atexit(clean);
}
- if (!DMesaMakeCurrent(context, buffer)) {
- DMesaDestroyContext(context);
- DMesaDestroyVisual(visual);
- return GL_FALSE;
+ for (i=0; i<MAX_WINDOWS; i++) {
+ if (!buffer[i]) {
+ DMesaBuffer b;
+
+ if ((b=DMesaCreateBuffer(visual, g_xpos, g_ypos, g_width, g_height))==NULL) {
+ return 0;
+ }
+ if (!DMesaMakeCurrent(context, b)) {
+ DMesaDestroyBuffer(b);
+ return 0;
+ }
+ if (g_mouse) {
+ pc_mouse_area(g_xpos, g_ypos, g_xpos + g_width - 1, g_ypos + g_height - 1);
+ }
+
+ buffer[window = i] = b;
+ return i+1;
+ }
}
- pc_open_stdout();
- pc_open_stderr();
- pc_atexit(clean);
-
- return GL_TRUE;
+ return 0;
}
@@ -87,6 +126,10 @@ int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height) void APIENTRY glutDestroyWindow (int win)
{
+ if (buffer[win-1]) {
+ DMesaDestroyBuffer(buffer[win-1]);
+ buffer[win-1] = NULL;
+ }
}
@@ -99,19 +142,20 @@ void APIENTRY glutPostRedisplay (void) void APIENTRY glutSwapBuffers (void)
{
if (g_mouse) pc_scare_mouse();
- DMesaSwapBuffers(buffer);
+ DMesaSwapBuffers(buffer[window]);
if (g_mouse) pc_unscare_mouse();
}
int APIENTRY glutGetWindow (void)
{
- return 0;
+ return window + 1;
}
void APIENTRY glutSetWindow (int win)
{
+ window = win - 1;
}
|