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.2 for Mesa 4.1
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
35 #define USE_MINI_GLX 1
37 #include "GL/miniglx.h"
44 static GLXContext context
= 0;
46 static XVisualInfo
*visinfo
= 0;
47 static Display
*dpy
= 0;
50 int APIENTRY
glutCreateWindow (const char *title
)
52 XSetWindowAttributes attr
;
56 Window root
= RootWindow( dpy
, scrnum
);
62 dpy
= XOpenDisplay(NULL
);
64 printf("Error: XOpenDisplay failed\n");
70 int attrib
[] = {GLX_RGBA
,
79 visinfo
= glXChooseVisual( dpy
, scrnum
, attrib
);
81 printf("Error: couldn't get an RGB, Double-buffered visual\n");
86 /* window attributes */
87 attr
.background_pixel
= 0;
88 attr
.border_pixel
= 0;
89 attr
.colormap
= XCreateColormap( dpy
, root
, visinfo
->visual
, AllocNone
);
90 attr
.event_mask
= StructureNotifyMask
| ExposureMask
;
91 mask
= CWBackPixel
| CWBorderPixel
| CWColormap
| CWEventMask
;
93 win
= XCreateWindow( dpy
, root
, 0, 0, g_width
, g_height
,
94 0, visinfo
->depth
, InputOutput
,
95 visinfo
->visual
, mask
, &attr
);
97 printf("Error: XCreateWindow failed\n");
101 ctx
= glXCreateContext( dpy
, visinfo
, NULL
, True
);
103 printf("Error: glXCreateContext failed\n");
107 if (!glXMakeCurrent( dpy
, win
, ctx
)) {
108 printf("Error: glXMakeCurrent failed\n");
112 if (!(g_display_mode
& GLUT_DOUBLE
))
113 glDrawBuffer( GL_FRONT
);
116 XMapWindow( dpy
, win
);
122 XNextEvent( dpy
, &e
);
123 if (e
.type
== MapNotify
&& e
.xmap
.window
== win
) {
134 int APIENTRY
glutCreateSubWindow (int win
, int x
, int y
, int width
, int height
)
140 void APIENTRY
glutDestroyWindow (int idx
)
143 XDestroyWindow( dpy
, win
);
146 XCloseDisplay( dpy
);
153 void APIENTRY
glutPostRedisplay (void)
155 g_redisplay
= GL_TRUE
;
159 void APIENTRY
glutSwapBuffers (void)
161 /* if (g_mouse) pc_scare_mouse(); */
162 if (dpy
&& win
) glXSwapBuffers( dpy
, win
);
163 /* if (g_mouse) pc_unscare_mouse(); */
167 int APIENTRY
glutGetWindow (void)
173 void APIENTRY
glutSetWindow (int win
)
178 void APIENTRY
glutSetWindowTitle (const char *title
)
183 void APIENTRY
glutSetIconTitle (const char *title
)
188 void APIENTRY
glutPositionWindow (int x
, int y
)
193 void APIENTRY
glutReshapeWindow (int width
, int height
)
198 void APIENTRY
glutPopWindow (void)
203 void APIENTRY
glutPushWindow (void)
208 void APIENTRY
glutIconifyWindow (void)
213 void APIENTRY
glutShowWindow (void)
218 void APIENTRY
glutHideWindow (void)
222 void APIENTRY
glutMainLoop (void)
225 GLboolean have_event
;
230 if (reshape_func
) reshape_func(g_width
, g_height
);
236 if (visible
&& idle_func
)
237 have_event
= XCheckMaskEvent( dpy
, ~0, &evt
);
239 have_event
= XNextEvent( dpy
, &evt
);
245 if (visibility_func
) {
246 visibility_func(GLUT_VISIBLE
);
251 if (visibility_func
) {
252 visibility_func(GLUT_NOT_VISIBLE
);
262 if (visible
&& g_redisplay
&& display_func
) {
264 g_redisplay
= GL_FALSE
;
269 if (visible
&& idle
&& idle_func
) {