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 5.0
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
34 void APIENTRY
glutInit (int *argcp
, char **argv
)
38 if ((env
= getenv("DMESA_GLUT_BPP")) != NULL
) {
41 if ((env
= getenv("DMESA_GLUT_REFRESH")) != NULL
) {
42 g_refresh
= atoi(env
);
45 glutGet(GLUT_ELAPSED_TIME
);
49 void APIENTRY
glutInitDisplayMode (unsigned int mode
)
51 g_display_mode
= mode
;
54 g_mouse
= pc_install_mouse();
58 void APIENTRY
glutInitWindowPosition (int x
, int y
)
65 void APIENTRY
glutInitWindowSize (int width
, int height
)
72 void APIENTRY
glutMainLoop (void)
75 static int old_mouse_x
= 0;
76 static int old_mouse_y
= 0;
77 static int old_mouse_b
= 0;
80 if (reshape_func
) reshape_func(g_width
, g_height
);
81 if (visibility_func
) visibility_func(GLUT_VISIBLE
);
82 if (g_mouse
) pc_show_mouse();
87 if (g_redisplay
&& display_func
) {
89 g_redisplay
= GL_FALSE
;
91 if (g_mouse
&& !(g_display_mode
& GLUT_DOUBLE
)) pc_scare_mouse();
93 if (g_mouse
&& !(g_display_mode
& GLUT_DOUBLE
)) pc_unscare_mouse();
96 if (pc_keypressed()) {
103 case KEY_F1
: if (special_func
) special_func(GLUT_KEY_F1
, 0, 0); break;
104 case KEY_F2
: if (special_func
) special_func(GLUT_KEY_F2
, 0, 0); break;
105 case KEY_F3
: if (special_func
) special_func(GLUT_KEY_F3
, 0, 0); break;
106 case KEY_F4
: if (special_func
) special_func(GLUT_KEY_F4
, 0, 0); break;
107 case KEY_F5
: if (special_func
) special_func(GLUT_KEY_F5
, 0, 0); break;
108 case KEY_F6
: if (special_func
) special_func(GLUT_KEY_F6
, 0, 0); break;
109 case KEY_F7
: if (special_func
) special_func(GLUT_KEY_F7
, 0, 0); break;
110 case KEY_F8
: if (special_func
) special_func(GLUT_KEY_F8
, 0, 0); break;
111 case KEY_F9
: if (special_func
) special_func(GLUT_KEY_F9
, 0, 0); break;
112 case KEY_F10
: if (special_func
) special_func(GLUT_KEY_F10
, 0, 0); break;
113 case KEY_F11
: if (special_func
) special_func(GLUT_KEY_F11
, 0, 0); break;
114 case KEY_F12
: if (special_func
) special_func(GLUT_KEY_F12
, 0, 0); break;
115 case KEY_LEFT
: if (special_func
) special_func(GLUT_KEY_LEFT
, 0, 0); break;
116 case KEY_UP
: if (special_func
) special_func(GLUT_KEY_UP
, 0, 0); break;
117 case KEY_RIGHT
: if (special_func
) special_func(GLUT_KEY_RIGHT
, 0, 0); break;
118 case KEY_DOWN
: if (special_func
) special_func(GLUT_KEY_DOWN
, 0, 0); break;
119 case KEY_PGUP
: if (special_func
) special_func(GLUT_KEY_PAGE_UP
, 0, 0); break;
120 case KEY_PGDN
: if (special_func
) special_func(GLUT_KEY_PAGE_DOWN
, 0, 0); break;
121 case KEY_HOME
: if (special_func
) special_func(GLUT_KEY_HOME
, 0, 0); break;
122 case KEY_END
: if (special_func
) special_func(GLUT_KEY_END
, 0, 0); break;
123 case KEY_INSERT
: if (special_func
) special_func(GLUT_KEY_INSERT
, 0, 0); break;
124 default: if (keyboard_func
) keyboard_func(key
& 0xFF, 0, 0);
133 mouse_b
= pc_query_mouse(&mouse_x
, &mouse_y
);
135 if (motion_func
&& ((mouse_x
!= old_mouse_x
) || (mouse_y
!= old_mouse_y
))) {
137 old_mouse_x
= mouse_x
;
138 old_mouse_y
= mouse_y
;
140 motion_func(old_mouse_x
, old_mouse_y
);
143 if (mouse_func
&& (mouse_b
!= old_mouse_b
)) {
144 int new_mouse_b
= mouse_b
;
146 if ((old_mouse_b
& 1) && !(new_mouse_b
& 1))
147 mouse_func(GLUT_LEFT_BUTTON
, GLUT_UP
, mouse_x
, mouse_y
);
148 else if (!(old_mouse_b
& 1) && (new_mouse_b
& 1))
149 mouse_func(GLUT_LEFT_BUTTON
, GLUT_DOWN
, mouse_x
, mouse_y
);
151 if ((old_mouse_b
& 2) && !(new_mouse_b
& 2))
152 mouse_func(GLUT_RIGHT_BUTTON
, GLUT_UP
, mouse_x
, mouse_y
);
153 else if (!(old_mouse_b
& 2) && (new_mouse_b
& 2))
154 mouse_func(GLUT_RIGHT_BUTTON
, GLUT_DOWN
, mouse_x
, mouse_y
);
156 if ((old_mouse_b
& 4) && !(new_mouse_b
& 4))
157 mouse_func(GLUT_MIDDLE_BUTTON
, GLUT_UP
, mouse_x
, mouse_y
);
158 else if (!(old_mouse_b
& 3) && (new_mouse_b
& 4))
159 mouse_func(GLUT_MIDDLE_BUTTON
, GLUT_DOWN
, mouse_x
, mouse_y
);
162 old_mouse_b
= new_mouse_b
;
166 if (idle
&& idle_func
)