updates from Daniel Borca
[mesa.git] / src / glut / dos / window.c
index f43533ce5f87d04851b128f584473cc17f891eb2..384e10a03b813dc556cbb88aae80473b2e0f1109 100644 (file)
@@ -19,7 +19,7 @@
  */\r
 \r
 /*\r
- * DOS/DJGPP glut driver v1.0 for Mesa 4.0\r
+ * DOS/DJGPP glut driver v1.1 for Mesa 4.0\r
  *\r
  *  Copyright (C) 2002 - Borca Daniel\r
  *  Email : dborca@yahoo.com\r
 \r
 \r
 #include "GL/glut.h"\r
+#ifndef FX\r
 #include "GL/dmesa.h"\r
+#else\r
+#include "GL/fxmesa.h"\r
+#endif\r
 #include "internal.h"\r
 \r
 \r
 \r
 static int window;\r
 \r
+#ifndef FX\r
 static DMesaVisual  visual  = NULL;\r
 static DMesaContext context = NULL;\r
 static DMesaBuffer  buffer[MAX_WINDOWS];\r
+#else\r
+static void *visual = NULL;\r
+static fxMesaContext context = NULL;\r
+static int fx_attrib[32];\r
+#endif\r
 \r
 \r
 \r
@@ -48,8 +58,12 @@ static void clean (void)
  for (i=0; i<MAX_WINDOWS; i++) {\r
      glutDestroyWindow(i+1);\r
  }\r
+#ifndef FX\r
  if (context) DMesaDestroyContext(context);\r
  if (visual)  DMesaDestroyVisual(visual);\r
+#else\r
+ if (context) fxMesaDestroyContext(context);\r
+#endif\r
 \r
  pc_close_stdout();\r
  pc_close_stderr();\r
@@ -76,6 +90,7 @@ int APIENTRY glutCreateWindow (const char *title)
        screen_h = 768;\r
     }\r
 \r
+#ifndef FX\r
     if ((visual=DMesaCreateVisual(screen_w, screen_h, DEFAULT_BPP,\r
                                   g_display_mode & GLUT_DOUBLE,\r
                                   g_display_mode & GLUT_DEPTH  ?DEPTH_SIZE  :0,\r
@@ -88,12 +103,24 @@ int APIENTRY glutCreateWindow (const char *title)
        DMesaDestroyVisual(visual);\r
        return 0;\r
     }\r
+#else\r
+    i = 0;\r
+    if (g_display_mode & GLUT_DOUBLE) fx_attrib[i++] = FXMESA_DOUBLEBUFFER;\r
+    if (g_display_mode & GLUT_DEPTH) { fx_attrib[i++] = FXMESA_DEPTH_SIZE; fx_attrib[i++] = DEPTH_SIZE; }\r
+    if (g_display_mode & GLUT_STENCIL) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = STENCIL_SIZE; }\r
+    if (g_display_mode & GLUT_ACCUM) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = ACCUM_SIZE; }\r
+    fx_attrib[i] = FXMESA_NONE;\r
+    if ((context=fxMesaCreateBestContext(-1, screen_w, screen_h, fx_attrib))==NULL) {\r
+       return 0;\r
+    }\r
+#endif\r
     \r
     pc_open_stdout();\r
     pc_open_stderr();\r
     pc_atexit(clean);\r
  }\r
 \r
+#ifndef FX\r
  for (i=0; i<MAX_WINDOWS; i++) {\r
      if (!buffer[i]) {\r
         DMesaBuffer b;\r
@@ -115,6 +142,11 @@ int APIENTRY glutCreateWindow (const char *title)
  }\r
 \r
  return 0;\r
+#else\r
+ fxMesaMakeCurrent(context);\r
+\r
+ return 1;\r
+#endif\r
 }\r
 \r
 \r
@@ -126,10 +158,12 @@ int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
 \r
 void APIENTRY glutDestroyWindow (int win)\r
 {\r
+#ifndef FX\r
  if (buffer[win-1]) {\r
     DMesaDestroyBuffer(buffer[win-1]);\r
     buffer[win-1] = NULL;\r
  }\r
+#endif\r
 }\r
 \r
 \r
@@ -142,7 +176,11 @@ void APIENTRY glutPostRedisplay (void)
 void APIENTRY glutSwapBuffers (void)\r
 {\r
  if (g_mouse) pc_scare_mouse();\r
+#ifndef FX\r
  DMesaSwapBuffers(buffer[window]);\r
+#else\r
+ fxMesaSwapBuffers();\r
+#endif\r
  if (g_mouse) pc_unscare_mouse();\r
 }\r
 \r
@@ -171,15 +209,18 @@ void APIENTRY glutSetIconTitle (const char *title)
 \r
 void APIENTRY glutPositionWindow (int x, int y)\r
 {\r
+#ifndef FX\r
  if (DMesaViewport(buffer[window], x, y, g_width, g_height)) {\r
     g_xpos = x;\r
     g_ypos = y;\r
  }\r
+#endif\r
 }\r
 \r
 \r
 void APIENTRY glutReshapeWindow (int width, int height)\r
 {\r
+#ifndef FX\r
  if (DMesaViewport(buffer[window], g_xpos, g_ypos, width, height)) {\r
     g_width = width;\r
     g_height = height;\r
@@ -189,6 +230,7 @@ void APIENTRY glutReshapeWindow (int width, int height)
        glViewport(0, 0, width, height);\r
     }\r
  }\r
+#endif\r
 }\r
 \r
 \r