Only enable verbose NoOp dispatch if DEBUG is defined
[mesa.git] / src / glut / dos / init.c
1 /*
2 * DOS/DJGPP Mesa Utility Toolkit
3 * Version: 1.0
4 *
5 * Copyright (C) 2005 Daniel Borca All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "internal.h"
32
33
34 char *__glutProgramName = NULL;
35
36 GLUTvisual _glut_visual = {
37 16, 8, 16, 8, 16, /* bpp, alpha, depth, stencil, accum */
38
39 { 0, 0 }, 0, /* geometry */
40
41 0 /* flags */
42 };
43
44 GLUTdefault _glut_default = {
45 0, 0, /* glutInitWindowPosition */
46 300, 300, /* glutInitWindowSize */
47 0 /* glutInitDisplayMode */
48 };
49
50 GLuint _glut_fps = 0;
51
52 static char *init_string;
53
54
55 void
56 _glut_fatal (char *format,...)
57 {
58 va_list args;
59
60 va_start(args, format);
61 fprintf(stderr, "GLUT: Fatal Error in %s: ",
62 __glutProgramName ? __glutProgramName : "(unamed)");
63 vfprintf(stderr, format, args);
64 va_end(args);
65 putc('\n', stderr);
66 exit(1);
67 }
68
69
70 /* strdup is actually not a standard ANSI C or POSIX routine
71 * so implement a private one for GLUT.
72 */
73 static char *
74 _glut_strdup (const char *string)
75 {
76 if (string != NULL) {
77 int len = strlen(string) + 1;
78 char *p = malloc(len);
79 if (p != NULL) {
80 return strcpy(p, string);
81 }
82 }
83 return NULL;
84 }
85
86
87 void APIENTRY
88 glutInit (int *argc, char **argv)
89 {
90 char *str;
91 const char *env;
92
93 if ((env = getenv("DMESA_GLUT_BPP")) != NULL) {
94 _glut_visual.bpp = atoi(env);
95 }
96 if ((env = getenv("DMESA_GLUT_ALPHA")) != NULL) {
97 _glut_visual.alpha = atoi(env);
98 }
99 if ((env = getenv("DMESA_GLUT_DEPTH")) != NULL) {
100 _glut_visual.depth = atoi(env);
101 }
102 if ((env = getenv("DMESA_GLUT_STENCIL")) != NULL) {
103 _glut_visual.stencil = atoi(env);
104 }
105 if ((env = getenv("DMESA_GLUT_ACCUM")) != NULL) {
106 _glut_visual.accum = atoi(env);
107 }
108 if ((env = getenv("DMESA_GLUT_REFRESH")) != NULL) {
109 _glut_visual.refresh = atoi(env);
110 }
111
112 /* Determine program name. */
113 str = strrchr(argv[0], '/');
114 if (str == NULL) {
115 str = argv[0];
116 } else {
117 str++;
118 }
119 __glutProgramName = _glut_strdup(str);
120
121 /* check if GLUT_FPS env var is set */
122 if ((env = getenv("GLUT_FPS")) != NULL) {
123 if ((_glut_fps = atoi(env)) <= 0) {
124 _glut_fps = 5000; /* 5000 milliseconds */
125 }
126 }
127
128 /* Initialize timer */
129 glutGet(GLUT_ELAPSED_TIME);
130 }
131
132
133 void APIENTRY
134 glutInitDisplayMode (unsigned int mode)
135 {
136 _glut_default.mode = mode;
137 }
138
139
140 void APIENTRY
141 glutInitWindowPosition (int x, int y)
142 {
143 _glut_default.x = x;
144 _glut_default.y = y;
145 }
146
147
148 void APIENTRY
149 glutInitWindowSize (int width, int height)
150 {
151 _glut_default.width = width;
152 _glut_default.height = height;
153 }
154
155
156 void APIENTRY
157 glutInitDisplayString (const char *string)
158 {
159 init_string = _glut_strdup(string);
160 }
161
162
163 void APIENTRY
164 glutSetOption (GLenum pname, int value)
165 {
166 switch (pname) {
167 case GLUT_INIT_WINDOW_X:
168 _glut_default.x = value;
169 break;
170 case GLUT_INIT_WINDOW_Y:
171 _glut_default.y = value;
172 break;
173 }
174 }
175
176
177 void APIENTRY
178 glutForceJoystickFunc (void)
179 {
180 }
181
182
183 void APIENTRY
184 glutIgnoreKeyRepeat (int ignore)
185 {
186 }
187
188
189 void APIENTRY
190 glutSetKeyRepeat (int repeatMode)
191 {
192 }
193
194
195 void APIENTRY
196 glutVideoPan (int x, int y, int w, int h)
197 {
198 }
199
200
201 int APIENTRY
202 glutVideoResizeGet( GLenum eWhat )
203 {
204 return 0;
205 }
206
207
208 void APIENTRY
209 glutSetupVideoResizing (void)
210 {
211 }
212
213
214 void APIENTRY
215 glutStopVideoResizing (void)
216 {
217 }
218
219
220 void APIENTRY
221 glutVideoResize (int x, int y, int w, int h)
222 {
223 }