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.3 for Mesa
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
38 static GLuint swaptime
, swapcount
;
40 static DMesaVisual visual
= NULL
;
41 static DMesaContext context
= NULL
;
42 static GLUTwindow
*windows
[MAX_WINDOWS
];
46 static void clean (void)
50 for (i
=1; i
<=MAX_WINDOWS
; i
++) {
53 if (context
) DMesaDestroyContext(context
);
54 if (visual
) DMesaDestroyVisual(visual
);
62 int APIENTRY
glutCreateWindow (const char *title
)
65 int m8width
= (g_init_w
+ 7) & ~7;
68 if ((visual
=DMesaCreateVisual(g_init_x
+ m8width
, g_init_y
+ g_init_h
, g_bpp
, g_refresh
,
69 g_display_mode
& GLUT_DOUBLE
,
70 !(g_display_mode
& GLUT_INDEX
),
71 g_display_mode
& GLUT_ALPHA
,
72 g_display_mode
& GLUT_DEPTH
?DEPTH_SIZE
:0,
73 g_display_mode
& GLUT_STENCIL
?STENCIL_SIZE
:0,
74 g_display_mode
& GLUT_ACCUM
?ACCUM_SIZE
:0))==NULL
) {
78 if ((context
=DMesaCreateContext(visual
, NULL
))==NULL
) {
79 DMesaDestroyVisual(visual
);
88 for (i
=0; i
<MAX_WINDOWS
; i
++) {
89 if (windows
[i
] == NULL
) {
93 if ((w
=(GLUTwindow
*)calloc(1, sizeof(GLUTwindow
))) == NULL
) {
97 if ((b
=DMesaCreateBuffer(visual
, g_init_x
, g_init_y
, m8width
, g_init_h
))==NULL
) {
101 if (!DMesaMakeCurrent(context
, b
)) {
102 DMesaDestroyBuffer(b
);
107 g_curwin
= windows
[i
] = w
;
113 w
->height
= g_init_h
;
125 int APIENTRY
glutCreateSubWindow (int win
, int x
, int y
, int width
, int height
)
132 void APIENTRY
glutDestroyWindow (int win
)
134 if (windows
[--win
]) {
135 DMesaDestroyBuffer(windows
[win
]->buffer
);
143 void APIENTRY
glutPostRedisplay (void)
145 g_redisplay
= GL_TRUE
;
150 void APIENTRY
glutSwapBuffers (void)
152 if (g_curwin
->show_mouse
) {
153 /* XXX scare mouse */
154 DMesaSwapBuffers(g_curwin
->buffer
);
155 /* XXX unscare mouse */
157 DMesaSwapBuffers(g_curwin
->buffer
);
161 GLint t
= glutGet(GLUT_ELAPSED_TIME
);
165 else if (t
- swaptime
> g_fps
) {
166 double time
= 0.001 * (t
- swaptime
);
167 double fps
= (double)swapcount
/ time
;
168 fprintf(stderr
, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount
, time
, fps
);
177 int APIENTRY
glutGetWindow (void)
179 return g_curwin
->num
;
184 void APIENTRY
glutSetWindow (int win
)
186 g_curwin
= windows
[win
- 1];
191 void APIENTRY
glutSetWindowTitle (const char *title
)
197 void APIENTRY
glutSetIconTitle (const char *title
)
203 void APIENTRY
glutPositionWindow (int x
, int y
)
205 if (DMesaMoveBuffer(x
, y
)) {
213 void APIENTRY
glutReshapeWindow (int width
, int height
)
215 if (DMesaResizeBuffer(width
, height
)) {
216 g_curwin
->width
= width
;
217 g_curwin
->height
= height
;
218 if (g_curwin
->reshape
) {
219 g_curwin
->reshape(width
, height
);
221 glViewport(0, 0, width
, height
);
228 void APIENTRY
glutFullScreen (void)
234 void APIENTRY
glutPopWindow (void)
240 void APIENTRY
glutPushWindow (void)
246 void APIENTRY
glutIconifyWindow (void)
252 void APIENTRY
glutShowWindow (void)
258 void APIENTRY
glutHideWindow (void)