2 * Mesa 3-D graphics library
4 * Copyright (C) 1995-1998 Brian Paul
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * DOS/DJGPP glut driver v1.1 for Mesa 4.0
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
34 #include "GL/fxmesa.h"
43 static DMesaVisual visual
= NULL
;
44 static DMesaContext context
= NULL
;
45 static DMesaBuffer buffer
[MAX_WINDOWS
];
47 static void *visual
= NULL
;
48 static fxMesaContext context
= NULL
;
49 static int fx_attrib
[32];
54 static void clean (void)
58 for (i
=0; i
<MAX_WINDOWS
; i
++) {
59 glutDestroyWindow(i
+1);
62 if (context
) DMesaDestroyContext(context
);
63 if (visual
) DMesaDestroyVisual(visual
);
65 if (context
) fxMesaDestroyContext(context
);
74 int APIENTRY
glutCreateWindow (const char *title
)
79 int screen_w
= DEFAULT_WIDTH
;
80 int screen_h
= DEFAULT_HEIGHT
;
82 if ((g_width
<=640) && (g_height
<=480)) {
85 } else if ((g_width
<=800) && (g_height
<=600)) {
88 } else if ((g_width
<=1024) && (g_height
<=768)) {
94 if ((visual
=DMesaCreateVisual(screen_w
, screen_h
, DEFAULT_BPP
,
95 g_display_mode
& GLUT_DOUBLE
,
96 g_display_mode
& GLUT_DEPTH
?DEPTH_SIZE
:0,
97 g_display_mode
& GLUT_STENCIL
?STENCIL_SIZE
:0,
98 g_display_mode
& GLUT_ACCUM
?ACCUM_SIZE
:0))==NULL
) {
102 if ((context
=DMesaCreateContext(visual
, NULL
))==NULL
) {
103 DMesaDestroyVisual(visual
);
108 if (g_display_mode
& GLUT_DOUBLE
) fx_attrib
[i
++] = FXMESA_DOUBLEBUFFER
;
109 if (g_display_mode
& GLUT_DEPTH
) { fx_attrib
[i
++] = FXMESA_DEPTH_SIZE
; fx_attrib
[i
++] = DEPTH_SIZE
; }
110 if (g_display_mode
& GLUT_STENCIL
) { fx_attrib
[i
++] = FXMESA_STENCIL_SIZE
; fx_attrib
[i
++] = STENCIL_SIZE
; }
111 if (g_display_mode
& GLUT_ACCUM
) { fx_attrib
[i
++] = FXMESA_ACCUM_SIZE
; fx_attrib
[i
++] = ACCUM_SIZE
; }
112 fx_attrib
[i
] = FXMESA_NONE
;
113 if ((context
=fxMesaCreateBestContext(-1, screen_w
, screen_h
, fx_attrib
))==NULL
) {
124 for (i
=0; i
<MAX_WINDOWS
; i
++) {
128 if ((b
=DMesaCreateBuffer(visual
, g_xpos
, g_ypos
, g_width
, g_height
))==NULL
) {
131 if (!DMesaMakeCurrent(context
, b
)) {
132 DMesaDestroyBuffer(b
);
136 pc_mouse_area(g_xpos
, g_ypos
, g_xpos
+ g_width
- 1, g_ypos
+ g_height
- 1);
139 buffer
[window
= i
] = b
;
146 fxMesaMakeCurrent(context
);
153 int APIENTRY
glutCreateSubWindow (int win
, int x
, int y
, int width
, int height
)
159 void APIENTRY
glutDestroyWindow (int win
)
163 DMesaDestroyBuffer(buffer
[win
-1]);
164 buffer
[win
-1] = NULL
;
170 void APIENTRY
glutPostRedisplay (void)
172 g_redisplay
= GL_TRUE
;
176 void APIENTRY
glutSwapBuffers (void)
178 if (g_mouse
) pc_scare_mouse();
180 DMesaSwapBuffers(buffer
[window
]);
184 if (g_mouse
) pc_unscare_mouse();
188 int APIENTRY
glutGetWindow (void)
194 void APIENTRY
glutSetWindow (int win
)
200 void APIENTRY
glutSetWindowTitle (const char *title
)
205 void APIENTRY
glutSetIconTitle (const char *title
)
210 void APIENTRY
glutPositionWindow (int x
, int y
)
213 if (DMesaViewport(buffer
[window
], x
, y
, g_width
, g_height
)) {
221 void APIENTRY
glutReshapeWindow (int width
, int height
)
224 if (DMesaViewport(buffer
[window
], g_xpos
, g_ypos
, width
, height
)) {
228 reshape_func(width
, height
);
230 glViewport(0, 0, width
, height
);
237 void APIENTRY
glutPopWindow (void)
242 void APIENTRY
glutPushWindow (void)
247 void APIENTRY
glutIconifyWindow (void)
252 void APIENTRY
glutShowWindow (void)
257 void APIENTRY
glutHideWindow (void)