comparison src/video/dc/SDL_dcvideo.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 11134dc42da8
children e1da92da346c
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
34 #include <dc/video.h> 34 #include <dc/video.h>
35 #include <dc/pvr.h> 35 #include <dc/pvr.h>
36 36
37 37
38 /* Initialization/Query functions */ 38 /* Initialization/Query functions */
39 static int DC_VideoInit(_THIS, SDL_PixelFormat *vformat); 39 static int DC_VideoInit(_THIS, SDL_PixelFormat * vformat);
40 static SDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 40 static SDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
41 static SDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 41 static SDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface * current, int width,
42 static int DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); 42 int height, int bpp, Uint32 flags);
43 static int DC_SetColors(_THIS, int firstcolor, int ncolors,
44 SDL_Color * colors);
43 static void DC_VideoQuit(_THIS); 45 static void DC_VideoQuit(_THIS);
44 46
45 /* Hardware surface functions */ 47 /* Hardware surface functions */
46 static int DC_AllocHWSurface(_THIS, SDL_Surface *surface); 48 static int DC_AllocHWSurface(_THIS, SDL_Surface * surface);
47 static int DC_LockHWSurface(_THIS, SDL_Surface *surface); 49 static int DC_LockHWSurface(_THIS, SDL_Surface * surface);
48 static void DC_UnlockHWSurface(_THIS, SDL_Surface *surface); 50 static void DC_UnlockHWSurface(_THIS, SDL_Surface * surface);
49 static void DC_FreeHWSurface(_THIS, SDL_Surface *surface); 51 static void DC_FreeHWSurface(_THIS, SDL_Surface * surface);
50 static int DC_FlipHWSurface(_THIS, SDL_Surface *surface); 52 static int DC_FlipHWSurface(_THIS, SDL_Surface * surface);
51 53
52 /* etc. */ 54 /* etc. */
53 static void DC_UpdateRects(_THIS, int numrects, SDL_Rect *rects); 55 static void DC_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
54 56
55 /* OpenGL */ 57 /* OpenGL */
56 #if SDL_VIDEO_OPENGL 58 #if SDL_VIDEO_OPENGL
57 static void *DC_GL_GetProcAddress(_THIS, const char *proc); 59 static void *DC_GL_GetProcAddress(_THIS, const char *proc);
58 static int DC_GL_LoadLibrary(_THIS, const char *path); 60 static int DC_GL_LoadLibrary(_THIS, const char *path);
59 static int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); 61 static int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
60 static void DC_GL_SwapBuffers(_THIS); 62 static void DC_GL_SwapBuffers(_THIS);
61 #endif 63 #endif
62 64
63 /* DC driver bootstrap functions */ 65 /* DC driver bootstrap functions */
64 66
65 static int DC_Available(void) 67 static int
66 { 68 DC_Available(void)
67 return 1; 69 {
68 } 70 return 1;
69 71 }
70 static void DC_DeleteDevice(SDL_VideoDevice *device) 72
71 { 73 static void
72 SDL_free(device->hidden); 74 DC_DeleteDevice(SDL_VideoDevice * device)
73 SDL_free(device); 75 {
74 } 76 SDL_free(device->hidden);
75 77 SDL_free(device);
76 static SDL_VideoDevice *DC_CreateDevice(int devindex) 78 }
77 { 79
78 SDL_VideoDevice *device; 80 static SDL_VideoDevice *
79 81 DC_CreateDevice(int devindex)
80 /* Initialize all variables that we clean on shutdown */ 82 {
81 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); 83 SDL_VideoDevice *device;
82 if ( device ) { 84
83 SDL_memset(device, 0, (sizeof *device)); 85 /* Initialize all variables that we clean on shutdown */
84 device->hidden = (struct SDL_PrivateVideoData *) 86 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
85 SDL_malloc((sizeof *device->hidden)); 87 if (device) {
86 } 88 SDL_memset(device, 0, (sizeof *device));
87 if ( (device == NULL) || (device->hidden == NULL) ) { 89 device->hidden = (struct SDL_PrivateVideoData *)
88 SDL_OutOfMemory(); 90 SDL_malloc((sizeof *device->hidden));
89 if ( device ) { 91 }
90 SDL_free(device); 92 if ((device == NULL) || (device->hidden == NULL)) {
91 } 93 SDL_OutOfMemory();
92 return(0); 94 if (device) {
93 } 95 SDL_free(device);
94 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); 96 }
95 97 return (0);
96 /* Set the function pointers */ 98 }
97 device->VideoInit = DC_VideoInit; 99 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
98 device->ListModes = DC_ListModes; 100
99 device->SetVideoMode = DC_SetVideoMode; 101 /* Set the function pointers */
100 device->CreateYUVOverlay = NULL; 102 device->VideoInit = DC_VideoInit;
101 device->SetColors = DC_SetColors; 103 device->ListModes = DC_ListModes;
102 device->UpdateRects = DC_UpdateRects; 104 device->SetVideoMode = DC_SetVideoMode;
103 device->VideoQuit = DC_VideoQuit; 105 device->CreateYUVOverlay = NULL;
104 device->AllocHWSurface = DC_AllocHWSurface; 106 device->SetColors = DC_SetColors;
105 device->CheckHWBlit = NULL; 107 device->UpdateRects = DC_UpdateRects;
106 device->FillHWRect = NULL; 108 device->VideoQuit = DC_VideoQuit;
107 device->SetHWColorKey = NULL; 109 device->AllocHWSurface = DC_AllocHWSurface;
108 device->SetHWAlpha = NULL; 110 device->CheckHWBlit = NULL;
109 device->LockHWSurface = DC_LockHWSurface; 111 device->FillHWRect = NULL;
110 device->UnlockHWSurface = DC_UnlockHWSurface; 112 device->SetHWColorKey = NULL;
111 device->FlipHWSurface = DC_FlipHWSurface; 113 device->SetHWAlpha = NULL;
112 device->FreeHWSurface = DC_FreeHWSurface; 114 device->LockHWSurface = DC_LockHWSurface;
113 #if SDL_VIDEO_OPENGL 115 device->UnlockHWSurface = DC_UnlockHWSurface;
114 device->GL_LoadLibrary = DC_GL_LoadLibrary; 116 device->FlipHWSurface = DC_FlipHWSurface;
115 device->GL_GetProcAddress = DC_GL_GetProcAddress; 117 device->FreeHWSurface = DC_FreeHWSurface;
116 device->GL_GetAttribute = DC_GL_GetAttribute; 118 #if SDL_VIDEO_OPENGL
117 device->GL_MakeCurrent = NULL; 119 device->GL_LoadLibrary = DC_GL_LoadLibrary;
118 device->GL_SwapBuffers = DC_GL_SwapBuffers; 120 device->GL_GetProcAddress = DC_GL_GetProcAddress;
119 #endif 121 device->GL_GetAttribute = DC_GL_GetAttribute;
120 device->SetCaption = NULL; 122 device->GL_MakeCurrent = NULL;
121 device->SetIcon = NULL; 123 device->GL_SwapBuffers = DC_GL_SwapBuffers;
122 device->IconifyWindow = NULL; 124 #endif
123 device->GrabInput = NULL; 125 device->SetCaption = NULL;
124 device->GetWMInfo = NULL; 126 device->SetIcon = NULL;
125 device->InitOSKeymap = DC_InitOSKeymap; 127 device->IconifyWindow = NULL;
126 device->PumpEvents = DC_PumpEvents; 128 device->GrabInput = NULL;
127 129 device->GetWMInfo = NULL;
128 device->free = DC_DeleteDevice; 130 device->InitOSKeymap = DC_InitOSKeymap;
129 131 device->PumpEvents = DC_PumpEvents;
130 return device; 132
133 device->free = DC_DeleteDevice;
134
135 return device;
131 } 136 }
132 137
133 VideoBootStrap DC_bootstrap = { 138 VideoBootStrap DC_bootstrap = {
134 "dcvideo", "Dreamcast Video", 139 "dcvideo", "Dreamcast Video",
135 DC_Available, DC_CreateDevice 140 DC_Available, DC_CreateDevice
136 }; 141 };
137 142
138 143
139 int DC_VideoInit(_THIS, SDL_PixelFormat *vformat) 144 int
140 { 145 DC_VideoInit(_THIS, SDL_PixelFormat * vformat)
141 /* Determine the screen depth (use default 16-bit depth) */ 146 {
142 /* we change this during the SDL_SetVideoMode implementation... */ 147 /* Determine the screen depth (use default 16-bit depth) */
143 vformat->BitsPerPixel = 16; 148 /* we change this during the SDL_SetVideoMode implementation... */
144 vformat->Rmask = 0x0000f800; 149 vformat->BitsPerPixel = 16;
145 vformat->Gmask = 0x000007e0; 150 vformat->Rmask = 0x0000f800;
146 vformat->Bmask = 0x0000001f; 151 vformat->Gmask = 0x000007e0;
147 152 vformat->Bmask = 0x0000001f;
148 /* We're done! */ 153
149 return(0); 154 /* We're done! */
150 } 155 return (0);
151 156 }
152 const static SDL_Rect 157
153 RECT_800x600 = {0,0,800,600}, 158 const static SDL_Rect RECT_800x600 = { 0, 0, 800, 600 }, RECT_640x480 = {
154 RECT_640x480 = {0,0,640,480}, 159 0, 0, 640, 480}, RECT_320x240 = {
155 RECT_320x240 = {0,0,320,240}; 160 0, 0, 320, 240};
156 const static SDL_Rect *vid_modes[] = { 161 const static SDL_Rect *vid_modes[] = {
157 &RECT_800x600, 162 &RECT_800x600,
158 &RECT_640x480, 163 &RECT_640x480,
159 &RECT_320x240, 164 &RECT_320x240,
160 NULL 165 NULL
161 }; 166 };
162 167
163 SDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 168 SDL_Rect **
164 { 169 DC_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
165 switch(format->BitsPerPixel) { 170 {
166 case 15: 171 switch (format->BitsPerPixel) {
167 case 16: 172 case 15:
168 return &vid_modes; 173 case 16:
169 case 32: 174 return &vid_modes;
170 if (!(flags & SDL_OPENGL)) 175 case 32:
171 return &vid_modes; 176 if (!(flags & SDL_INTERNALOPENGL))
172 default: 177 return &vid_modes;
173 return NULL; 178 default:
174 } 179 return NULL;
175 // return (SDL_Rect **) -1; 180 }
181 // return (SDL_Rect **) -1;
176 } 182 }
177 183
178 pvr_init_params_t params = { 184 pvr_init_params_t params = {
179 /* Enable opaque and translucent polygons with size 16 */ 185 /* Enable opaque and translucent polygons with size 16 */
180 { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16 }, 186 {PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0,
181 187 PVR_BINSIZE_16}
182 /* Vertex buffer size */ 188 ,
183 512*1024 189
190 /* Vertex buffer size */
191 512 * 1024
184 }; 192 };
185 193
186 #if SDL_VIDEO_OPENGL 194 #if SDL_VIDEO_OPENGL
187 static int pvr_inited; 195 static int pvr_inited;
188 #endif 196 #endif
189 197
190 SDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface *current, 198 SDL_Surface *
191 int width, int height, int bpp, Uint32 flags) 199 DC_SetVideoMode(_THIS, SDL_Surface * current,
192 { 200 int width, int height, int bpp, Uint32 flags)
193 int disp_mode,pixel_mode,pitch; 201 {
194 Uint32 Rmask, Gmask, Bmask; 202 int disp_mode, pixel_mode, pitch;
195 203 Uint32 Rmask, Gmask, Bmask;
196 if (width==320 && height==240) disp_mode=DM_320x240; 204
197 else if (width==640 && height==480) disp_mode=DM_640x480; 205 if (width == 320 && height == 240)
198 else if (width==800 && height==600) disp_mode=DM_800x608; 206 disp_mode = DM_320x240;
199 else { 207 else if (width == 640 && height == 480)
200 SDL_SetError("Couldn't find requested mode in list"); 208 disp_mode = DM_640x480;
201 return(NULL); 209 else if (width == 800 && height == 600)
202 } 210 disp_mode = DM_800x608;
203 211 else {
204 switch(bpp) { 212 SDL_SetError("Couldn't find requested mode in list");
205 case 15: pixel_mode = PM_RGB555; pitch = width*2; 213 return (NULL);
206 /* 5-5-5 */ 214 }
207 Rmask = 0x00007c00; 215
208 Gmask = 0x000003e0; 216 switch (bpp) {
209 Bmask = 0x0000001f; 217 case 15:
210 break; 218 pixel_mode = PM_RGB555;
211 case 16: pixel_mode = PM_RGB565; pitch = width*2; 219 pitch = width * 2;
212 /* 5-6-5 */ 220 /* 5-5-5 */
213 Rmask = 0x0000f800; 221 Rmask = 0x00007c00;
214 Gmask = 0x000007e0; 222 Gmask = 0x000003e0;
215 Bmask = 0x0000001f; 223 Bmask = 0x0000001f;
216 break; 224 break;
217 case 24: bpp = 32; 225 case 16:
218 case 32: pixel_mode = PM_RGB888; pitch = width*4; 226 pixel_mode = PM_RGB565;
219 Rmask = 0x00ff0000; 227 pitch = width * 2;
220 Gmask = 0x0000ff00; 228 /* 5-6-5 */
221 Bmask = 0x000000ff; 229 Rmask = 0x0000f800;
222 #if SDL_VIDEO_OPENGL 230 Gmask = 0x000007e0;
223 if (!(flags & SDL_OPENGL)) 231 Bmask = 0x0000001f;
224 #endif 232 break;
225 break; 233 case 24:
226 default: 234 bpp = 32;
227 SDL_SetError("Couldn't find requested mode in list"); 235 case 32:
228 return(NULL); 236 pixel_mode = PM_RGB888;
229 } 237 pitch = width * 4;
238 Rmask = 0x00ff0000;
239 Gmask = 0x0000ff00;
240 Bmask = 0x000000ff;
241 #if SDL_VIDEO_OPENGL
242 if (!(flags & SDL_INTERNALOPENGL))
243 #endif
244 break;
245 default:
246 SDL_SetError("Couldn't find requested mode in list");
247 return (NULL);
248 }
230 249
231 // if ( bpp != current->format->BitsPerPixel ) { 250 // if ( bpp != current->format->BitsPerPixel ) {
232 if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0) ) { 251 if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
233 return(NULL); 252 return (NULL);
234 } 253 }
235 // } 254 // }
236 255
237 /* Set up the new mode framebuffer */ 256 /* Set up the new mode framebuffer */
238 current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); 257 current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
239 current->w = width; 258 current->w = width;
240 current->h = height; 259 current->h = height;
241 current->pitch = pitch; 260 current->pitch = pitch;
242 261
243 #if SDL_VIDEO_OPENGL 262 #if SDL_VIDEO_OPENGL
244 if (pvr_inited) { 263 if (pvr_inited) {
245 pvr_inited = 0; 264 pvr_inited = 0;
246 pvr_shutdown(); 265 pvr_shutdown();
247 } 266 }
248 #endif 267 #endif
249 268
250 vid_set_mode(disp_mode,pixel_mode); 269 vid_set_mode(disp_mode, pixel_mode);
251 270
252 current->pixels = vram_s; 271 current->pixels = vram_s;
253 272
254 #if SDL_VIDEO_OPENGL 273 #if SDL_VIDEO_OPENGL
255 if (flags & SDL_OPENGL) { 274 if (flags & SDL_INTERNALOPENGL) {
256 this->gl_config.driver_loaded = 1; 275 this->gl_config.driver_loaded = 1;
257 current->flags = SDL_FULLSCREEN | SDL_OPENGL; 276 current->flags = SDL_FULLSCREEN | SDL_INTERNALOPENGL;
258 current->pixels = NULL; 277 current->pixels = NULL;
259 pvr_inited = 1; 278 pvr_inited = 1;
260 pvr_init(&params); 279 pvr_init(&params);
261 glKosInit(); 280 glKosInit();
262 glKosBeginFrame(); 281 glKosBeginFrame();
263 } else 282 } else
264 #endif 283 #endif
265 if (flags | SDL_DOUBLEBUF) { 284 if (flags | SDL_DOUBLEBUF) {
266 current->flags |= SDL_DOUBLEBUF; 285 current->flags |= SDL_DOUBLEBUF;
267 current->pixels = (void*)((int)current->pixels | 0x400000); 286 current->pixels = (void *) ((int) current->pixels | 0x400000);
268 } 287 }
269 288
270 /* We're done */ 289 /* We're done */
271 return(current); 290 return (current);
272 } 291 }
273 292
274 /* We don't actually allow hardware surfaces other than the main one */ 293 /* We don't actually allow hardware surfaces other than the main one */
275 static int DC_AllocHWSurface(_THIS, SDL_Surface *surface) 294 static int
276 { 295 DC_AllocHWSurface(_THIS, SDL_Surface * surface)
277 return(-1); 296 {
278 } 297 return (-1);
279 static void DC_FreeHWSurface(_THIS, SDL_Surface *surface) 298 }
280 { 299 static void
281 return; 300 DC_FreeHWSurface(_THIS, SDL_Surface * surface)
301 {
302 return;
282 } 303 }
283 304
284 /* We need to wait for vertical retrace on page flipped displays */ 305 /* We need to wait for vertical retrace on page flipped displays */
285 static int DC_LockHWSurface(_THIS, SDL_Surface *surface) 306 static int
286 { 307 DC_LockHWSurface(_THIS, SDL_Surface * surface)
287 return(0); 308 {
288 } 309 return (0);
289 310 }
290 static void DC_UnlockHWSurface(_THIS, SDL_Surface *surface) 311
291 { 312 static void
292 return; 313 DC_UnlockHWSurface(_THIS, SDL_Surface * surface)
293 } 314 {
294 315 return;
295 static int DC_FlipHWSurface(_THIS, SDL_Surface *surface) 316 }
296 { 317
297 if (surface->flags & SDL_DOUBLEBUF) { 318 static int
298 vid_set_start((int)surface->pixels & 0xffffff); 319 DC_FlipHWSurface(_THIS, SDL_Surface * surface)
299 surface->pixels = (void*)((int)surface->pixels ^ 0x400000); 320 {
300 } 321 if (surface->flags & SDL_DOUBLEBUF) {
301 return(0); 322 vid_set_start((int) surface->pixels & 0xffffff);
302 } 323 surface->pixels = (void *) ((int) surface->pixels ^ 0x400000);
303 324 }
304 static void DC_UpdateRects(_THIS, int numrects, SDL_Rect *rects) 325 return (0);
305 { 326 }
306 /* do nothing. */ 327
307 } 328 static void
308 329 DC_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
309 static int DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 330 {
310 { 331 /* do nothing. */
311 /* do nothing of note. */ 332 }
312 return(1); 333
334 static int
335 DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
336 {
337 /* do nothing of note. */
338 return (1);
313 } 339 }
314 340
315 /* Note: If we are terminated, this could be called in the middle of 341 /* Note: If we are terminated, this could be called in the middle of
316 another SDL video routine -- notably UpdateRects. 342 another SDL video routine -- notably UpdateRects.
317 */ 343 */
318 static void DC_VideoQuit(_THIS) 344 static void
319 { 345 DC_VideoQuit(_THIS)
320 #if SDL_VIDEO_OPENGL 346 {
321 if (pvr_inited) { 347 #if SDL_VIDEO_OPENGL
322 pvr_inited = 0; 348 if (pvr_inited) {
323 pvr_shutdown(); 349 pvr_inited = 0;
324 } 350 pvr_shutdown();
325 #endif 351 }
326 } 352 #endif
327 353 }
328 #if SDL_VIDEO_OPENGL 354
329 355 #if SDL_VIDEO_OPENGL
330 void dmyfunc(void) {} 356
331 357 void
332 typedef void (*funcptr)(); 358 dmyfunc(void)
333 const static struct { 359 {
334 char *name; 360 }
335 funcptr addr; 361
362 typedef void (*funcptr) ();
363 const static struct
364 {
365 char *name;
366 funcptr addr;
336 } glfuncs[] = { 367 } glfuncs[] = {
337 #define DEF(func) {#func,&func} 368 #define DEF(func) {#func,&func}
338 DEF(glBegin), 369 DEF(glBegin), DEF(glBindTexture), DEF(glBlendFunc), DEF(glColor4f),
339 DEF(glBindTexture), 370 // DEF(glCopyImageID),
340 DEF(glBlendFunc), 371 DEF(glDisable),
341 DEF(glColor4f), 372 DEF(glEnable),
342 // DEF(glCopyImageID), 373 DEF(glEnd),
343 DEF(glDisable), 374 DEF(glFlush),
344 DEF(glEnable), 375 DEF(glGenTextures),
345 DEF(glEnd), 376 DEF(glGetString),
346 DEF(glFlush), 377 DEF(glLoadIdentity),
347 DEF(glGenTextures), 378 DEF(glMatrixMode), DEF(glOrtho), DEF(glPixelStorei),
348 DEF(glGetString), 379 // DEF(glPopAttrib),
349 DEF(glLoadIdentity), 380 // DEF(glPopClientAttrib),
350 DEF(glMatrixMode), 381 {
351 DEF(glOrtho), 382 "glPopAttrib", &dmyfunc}, {
352 DEF(glPixelStorei), 383 "glPopClientAttrib", &dmyfunc}, DEF(glPopMatrix),
353 // DEF(glPopAttrib), 384 // DEF(glPushAttrib),
354 // DEF(glPopClientAttrib), 385 // DEF(glPushClientAttrib),
355 {"glPopAttrib",&dmyfunc}, 386 {
356 {"glPopClientAttrib",&dmyfunc}, 387 "glPushAttrib", &dmyfunc}, {
357 DEF(glPopMatrix), 388 "glPushClientAttrib", &dmyfunc},
358 // DEF(glPushAttrib), 389 DEF(glPushMatrix),
359 // DEF(glPushClientAttrib), 390 DEF(glTexCoord2f),
360 {"glPushAttrib",&dmyfunc}, 391 DEF(glTexEnvf),
361 {"glPushClientAttrib",&dmyfunc}, 392 DEF(glTexImage2D),
362 DEF(glPushMatrix), 393 DEF(glTexParameteri),
363 DEF(glTexCoord2f), 394 DEF(glTexSubImage2D), DEF(glVertex2i), DEF(glViewport),
364 DEF(glTexEnvf),
365 DEF(glTexImage2D),
366 DEF(glTexParameteri),
367 DEF(glTexSubImage2D),
368 DEF(glVertex2i),
369 DEF(glViewport),
370 #undef DEF 395 #undef DEF
371 }; 396 };
372 397
373 static void *DC_GL_GetProcAddress(_THIS, const char *proc) 398 static void *
374 { 399 DC_GL_GetProcAddress(_THIS, const char *proc)
375 void *ret; 400 {
376 int i; 401 void *ret;
377 402 int i;
378 ret = glKosGetProcAddress(proc); 403
379 if (ret) return ret; 404 ret = glKosGetProcAddress(proc);
380 405 if (ret)
381 for(i=0;i<sizeof(glfuncs)/sizeof(glfuncs[0]);i++) { 406 return ret;
382 if (SDL_strcmp(proc,glfuncs[i].name)==0) return glfuncs[i].addr; 407
383 } 408 for (i = 0; i < sizeof(glfuncs) / sizeof(glfuncs[0]); i++) {
384 409 if (SDL_strcmp(proc, glfuncs[i].name) == 0)
385 return NULL; 410 return glfuncs[i].addr;
386 } 411 }
387 412
388 static int DC_GL_LoadLibrary(_THIS, const char *path) 413 return NULL;
389 { 414 }
390 this->gl_config.driver_loaded = 1; 415
391 416 static int
392 return 0; 417 DC_GL_LoadLibrary(_THIS, const char *path)
393 } 418 {
394 419 this->gl_config.driver_loaded = 1;
395 static int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) 420
396 { 421 return 0;
397 GLenum mesa_attrib; 422 }
398 int val; 423
399 424 static int
400 switch(attrib) { 425 DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
401 case SDL_GL_RED_SIZE: 426 {
402 val = 5; 427 GLenum mesa_attrib;
403 break; 428 int val;
404 case SDL_GL_GREEN_SIZE: 429
405 val = 6; 430 switch (attrib) {
406 break; 431 case SDL_GL_RED_SIZE:
407 case SDL_GL_BLUE_SIZE: 432 val = 5;
408 val = 5; 433 break;
409 break; 434 case SDL_GL_GREEN_SIZE:
410 case SDL_GL_ALPHA_SIZE: 435 val = 6;
411 val = 0; 436 break;
412 break; 437 case SDL_GL_BLUE_SIZE:
413 case SDL_GL_DOUBLEBUFFER: 438 val = 5;
414 val = 1; 439 break;
415 break; 440 case SDL_GL_ALPHA_SIZE:
416 case SDL_GL_DEPTH_SIZE: 441 val = 0;
417 val = 16; /* or 32? */ 442 break;
418 break; 443 case SDL_GL_DOUBLEBUFFER:
419 case SDL_GL_STENCIL_SIZE: 444 val = 1;
420 val = 0; 445 break;
421 break; 446 case SDL_GL_DEPTH_SIZE:
422 case SDL_GL_ACCUM_RED_SIZE: 447 val = 16; /* or 32? */
423 val = 0; 448 break;
424 break; 449 case SDL_GL_STENCIL_SIZE:
425 case SDL_GL_ACCUM_GREEN_SIZE: 450 val = 0;
426 val = 0; 451 break;
427 case SDL_GL_ACCUM_BLUE_SIZE: 452 case SDL_GL_ACCUM_RED_SIZE:
428 val = 0; 453 val = 0;
429 break; 454 break;
430 case SDL_GL_ACCUM_ALPHA_SIZE: 455 case SDL_GL_ACCUM_GREEN_SIZE:
431 val = 0; 456 val = 0;
432 break; 457 case SDL_GL_ACCUM_BLUE_SIZE:
433 default : 458 val = 0;
434 return -1; 459 break;
435 } 460 case SDL_GL_ACCUM_ALPHA_SIZE:
436 *value = val; 461 val = 0;
437 return 0; 462 break;
438 } 463 default:
439 464 return -1;
440 static void DC_GL_SwapBuffers(_THIS) 465 }
441 { 466 *value = val;
442 glKosFinishFrame(); 467 return 0;
443 glKosBeginFrame(); 468 }
444 } 469
445 #endif 470 static void
471 DC_GL_SwapBuffers(_THIS)
472 {
473 glKosFinishFrame();
474 glKosBeginFrame();
475 }
476 #endif
477 /* vi: set ts=4 sw=4 expandtab: */