Rev 55 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
55 | pj | 1 | /* |
2 | * Mesa 3-D graphics library |
||
3 | * Version: 4.0 |
||
4 | * Copyright (C) 1995-1998 Brian Paul |
||
5 | * |
||
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. |
||
10 | * |
||
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. |
||
15 | * |
||
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. |
||
19 | */ |
||
20 | |||
21 | /* |
||
22 | * DOS/DJGPP glut driver v1.0 for Mesa 4.0 |
||
23 | * |
||
24 | * Copyright (C) 2002 - Borca Daniel |
||
25 | * Email : dborca@yahoo.com |
||
26 | * Web : http://www.geocities.com/dborca |
||
27 | */ |
||
28 | |||
29 | |||
30 | #include "GL/glut.h" |
||
31 | #include "internal.h" |
||
32 | |||
33 | |||
34 | void APIENTRY glutInit (int *argcp, char **argv) |
||
35 | { |
||
36 | glutGet(GLUT_ELAPSED_TIME); |
||
37 | } |
||
38 | |||
39 | |||
40 | void APIENTRY glutInitDisplayMode (unsigned int mode) |
||
41 | { |
||
42 | g_display_mode = mode; |
||
43 | |||
44 | pc_install_keyb(); |
||
45 | g_mouse = pc_install_mouse(); |
||
46 | } |
||
47 | |||
48 | |||
49 | void APIENTRY glutInitWindowPosition (int x, int y) |
||
50 | { |
||
51 | g_xpos = x; |
||
52 | g_ypos = y; |
||
53 | } |
||
54 | |||
55 | |||
56 | void APIENTRY glutInitWindowSize (int width, int height) |
||
57 | { |
||
58 | g_width = width; |
||
59 | g_height = height; |
||
60 | } |
||
61 | |||
62 | |||
63 | void APIENTRY glutMainLoop (void) |
||
64 | { |
||
65 | GLboolean idle; |
||
66 | static int old_mouse_x = 0; |
||
67 | static int old_mouse_y = 0; |
||
68 | static int old_mouse_b = 0; |
||
69 | |||
70 | glutPostRedisplay(); |
||
71 | if (reshape_func) reshape_func(g_width, g_height); |
||
72 | if (visibility_func) visibility_func(GLUT_VISIBLE); |
||
73 | if (g_mouse) pc_show_mouse(); |
||
74 | |||
75 | while (GL_TRUE) { |
||
76 | idle = GL_TRUE; |
||
77 | |||
78 | if (g_redisplay && display_func) { |
||
79 | idle = GL_FALSE; |
||
80 | g_redisplay = GL_FALSE; |
||
81 | |||
82 | if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse(); |
||
83 | display_func(); |
||
84 | if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse(); |
||
85 | } |
||
86 | |||
87 | if (pc_keypressed()) { |
||
88 | int key; |
||
89 | |||
90 | idle = GL_FALSE; |
||
91 | key = pc_readkey(); |
||
92 | |||
93 | switch (key>>16) { |
||
94 | case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break; |
||
95 | case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break; |
||
96 | case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break; |
||
97 | case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break; |
||
98 | case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break; |
||
99 | case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break; |
||
100 | case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break; |
||
101 | case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break; |
||
102 | case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break; |
||
103 | case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break; |
||
104 | case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break; |
||
105 | case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break; |
||
106 | case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break; |
||
107 | case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break; |
||
108 | case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break; |
||
109 | case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break; |
||
110 | case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break; |
||
111 | case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break; |
||
112 | case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break; |
||
113 | case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break; |
||
114 | case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break; |
||
115 | default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | if (g_mouse) { |
||
120 | int mouse_x; |
||
121 | int mouse_y; |
||
122 | int mouse_b; |
||
123 | |||
124 | mouse_b = pc_query_mouse(&mouse_x, &mouse_y); |
||
125 | |||
126 | if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) { |
||
127 | idle = GL_FALSE; |
||
128 | old_mouse_x = mouse_x; |
||
129 | old_mouse_y = mouse_y; |
||
130 | |||
131 | motion_func(old_mouse_x, old_mouse_y); |
||
132 | } |
||
133 | |||
134 | if (mouse_func && (mouse_b != old_mouse_b)) { |
||
135 | int new_mouse_b = mouse_b; |
||
136 | |||
137 | if ((old_mouse_b & 1) && !(new_mouse_b & 1)) |
||
138 | mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y); |
||
139 | else if (!(old_mouse_b & 1) && (new_mouse_b & 1)) |
||
140 | mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y); |
||
141 | |||
142 | if ((old_mouse_b & 2) && !(new_mouse_b & 2)) |
||
143 | mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y); |
||
144 | else if (!(old_mouse_b & 2) && (new_mouse_b & 2)) |
||
145 | mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y); |
||
146 | |||
147 | if ((old_mouse_b & 4) && !(new_mouse_b & 4)) |
||
148 | mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y); |
||
149 | else if (!(old_mouse_b & 3) && (new_mouse_b & 4)) |
||
150 | mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y); |
||
151 | |||
152 | idle = GL_FALSE; |
||
153 | old_mouse_b = new_mouse_b; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | if (idle && idle_func) |
||
158 | idle_func(); |
||
159 | } |
||
160 | } |