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