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 v0.1 for Mesa 4.0
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
35 static void *old_sig_int
= NULL
;
38 static void signal_handler (int num
)
40 signal(SIGINT
, old_sig_int
);
46 void APIENTRY
glutInit (int *argcp
, char **argv
)
49 only SIGINT (but not Ctrl-Break)
50 calls the destructors and will safely clean up
52 old_sig_int
= signal(SIGINT
, signal_handler
);
56 void APIENTRY
glutInitDisplayMode (unsigned int mode
)
58 g_display_mode
= mode
;
61 g_mouse
= pc_install_mouse();
65 void APIENTRY
glutInitWindowPosition (int x
, int y
)
72 void APIENTRY
glutInitWindowSize (int width
, int height
)
79 void APIENTRY
glutMainLoop (void)
82 static int old_mouse_x
= 0;
83 static int old_mouse_y
= 0;
84 static int old_mouse_b
= 0;
87 if (reshape_func
) reshape_func(g_width
, g_height
);
88 if (visibility_func
) visibility_func(GLUT_VISIBLE
);
89 if (g_mouse
) pc_show_mouse();
94 if (g_redisplay
&& display_func
) {
96 g_redisplay
= GL_FALSE
;
98 if (g_mouse
&& !(g_display_mode
& GLUT_DOUBLE
)) pc_scare_mouse();
100 if (g_mouse
&& !(g_display_mode
& GLUT_DOUBLE
)) pc_unscare_mouse();
103 if (pc_keypressed()) {
110 case KEY_F1
: if (special_func
) special_func(GLUT_KEY_F1
, 0, 0); break;
111 case KEY_F2
: if (special_func
) special_func(GLUT_KEY_F2
, 0, 0); break;
112 case KEY_F3
: if (special_func
) special_func(GLUT_KEY_F3
, 0, 0); break;
113 case KEY_F4
: if (special_func
) special_func(GLUT_KEY_F4
, 0, 0); break;
114 case KEY_F5
: if (special_func
) special_func(GLUT_KEY_F5
, 0, 0); break;
115 case KEY_F6
: if (special_func
) special_func(GLUT_KEY_F6
, 0, 0); break;
116 case KEY_F7
: if (special_func
) special_func(GLUT_KEY_F7
, 0, 0); break;
117 case KEY_F8
: if (special_func
) special_func(GLUT_KEY_F8
, 0, 0); break;
118 case KEY_F9
: if (special_func
) special_func(GLUT_KEY_F9
, 0, 0); break;
119 case KEY_F10
: if (special_func
) special_func(GLUT_KEY_F10
, 0, 0); break;
120 case KEY_F11
: if (special_func
) special_func(GLUT_KEY_F11
, 0, 0); break;
121 case KEY_F12
: if (special_func
) special_func(GLUT_KEY_F12
, 0, 0); break;
122 case KEY_LEFT
: if (special_func
) special_func(GLUT_KEY_LEFT
, 0, 0); break;
123 case KEY_UP
: if (special_func
) special_func(GLUT_KEY_UP
, 0, 0); break;
124 case KEY_RIGHT
: if (special_func
) special_func(GLUT_KEY_RIGHT
, 0, 0); break;
125 case KEY_DOWN
: if (special_func
) special_func(GLUT_KEY_DOWN
, 0, 0); break;
126 case KEY_PGUP
: if (special_func
) special_func(GLUT_KEY_PAGE_UP
, 0, 0); break;
127 case KEY_PGDN
: if (special_func
) special_func(GLUT_KEY_PAGE_DOWN
, 0, 0); break;
128 case KEY_HOME
: if (special_func
) special_func(GLUT_KEY_HOME
, 0, 0); break;
129 case KEY_END
: if (special_func
) special_func(GLUT_KEY_END
, 0, 0); break;
130 case KEY_INSERT
: if (special_func
) special_func(GLUT_KEY_INSERT
, 0, 0); break;
131 default: if (keyboard_func
) keyboard_func(key
& 0xFF, 0, 0);
135 if (g_mouse
&& motion_func
&& ((pc_mouse_x
!= old_mouse_x
) || (pc_mouse_y
!= old_mouse_y
))) {
137 old_mouse_x
= pc_mouse_x
;
138 old_mouse_y
= pc_mouse_y
;
140 motion_func(old_mouse_x
, old_mouse_y
);
143 if (g_mouse
&& mouse_func
&& (pc_mouse_b
!= old_mouse_b
)) {
144 int new_mouse_b
= pc_mouse_b
;
146 if ((old_mouse_b
& 1) && !(new_mouse_b
& 1))
147 mouse_func(GLUT_LEFT_BUTTON
, GLUT_UP
, pc_mouse_x
, pc_mouse_y
);
148 else if (!(old_mouse_b
& 1) && (new_mouse_b
& 1))
149 mouse_func(GLUT_LEFT_BUTTON
, GLUT_DOWN
, pc_mouse_x
, pc_mouse_y
);
151 if ((old_mouse_b
& 2) && !(new_mouse_b
& 2))
152 mouse_func(GLUT_RIGHT_BUTTON
, GLUT_UP
, pc_mouse_x
, pc_mouse_y
);
153 else if (!(old_mouse_b
& 2) && (new_mouse_b
& 2))
154 mouse_func(GLUT_RIGHT_BUTTON
, GLUT_DOWN
, pc_mouse_x
, pc_mouse_y
);
156 if ((old_mouse_b
& 4) && !(new_mouse_b
& 4))
157 mouse_func(GLUT_MIDDLE_BUTTON
, GLUT_UP
, pc_mouse_x
, pc_mouse_y
);
158 else if (!(old_mouse_b
& 3) && (new_mouse_b
& 4))
159 mouse_func(GLUT_MIDDLE_BUTTON
, GLUT_DOWN
, pc_mouse_x
, pc_mouse_y
);
162 old_mouse_b
= new_mouse_b
;
165 if (idle
&& idle_func
)