Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_atarigl.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 | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
46 | 46 |
47 #define VDI_RGB 0xf | 47 #define VDI_RGB 0xf |
48 | 48 |
49 /*--- Functions prototypes ---*/ | 49 /*--- Functions prototypes ---*/ |
50 | 50 |
51 static void SDL_AtariGL_UnloadLibrary(_THIS); | 51 static void SDL_AtariGL_UnloadLibrary (_THIS); |
52 | 52 |
53 #if SDL_VIDEO_OPENGL | 53 #if SDL_VIDEO_OPENGL |
54 static void CopyShadowNull(_THIS, SDL_Surface *surface); | 54 static void CopyShadowNull (_THIS, SDL_Surface * surface); |
55 static void CopyShadowDirect(_THIS, SDL_Surface *surface); | 55 static void CopyShadowDirect (_THIS, SDL_Surface * surface); |
56 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface); | 56 static void CopyShadowRGBTo555 (_THIS, SDL_Surface * surface); |
57 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface); | 57 static void CopyShadowRGBTo565 (_THIS, SDL_Surface * surface); |
58 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface); | 58 static void CopyShadowRGBSwap (_THIS, SDL_Surface * surface); |
59 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface); | 59 static void CopyShadowRGBToARGB (_THIS, SDL_Surface * surface); |
60 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface); | 60 static void CopyShadowRGBToABGR (_THIS, SDL_Surface * surface); |
61 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface); | 61 static void CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface); |
62 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface); | 62 static void CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface); |
63 static void CopyShadow8888To555(_THIS, SDL_Surface *surface); | 63 static void CopyShadow8888To555 (_THIS, SDL_Surface * surface); |
64 static void CopyShadow8888To565(_THIS, SDL_Surface *surface); | 64 static void CopyShadow8888To565 (_THIS, SDL_Surface * surface); |
65 | 65 |
66 static void ConvertNull(_THIS, SDL_Surface *surface); | 66 static void ConvertNull (_THIS, SDL_Surface * surface); |
67 static void Convert565To555be(_THIS, SDL_Surface *surface); | 67 static void Convert565To555be (_THIS, SDL_Surface * surface); |
68 static void Convert565To555le(_THIS, SDL_Surface *surface); | 68 static void Convert565To555le (_THIS, SDL_Surface * surface); |
69 static void Convert565le(_THIS, SDL_Surface *surface); | 69 static void Convert565le (_THIS, SDL_Surface * surface); |
70 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface); | 70 static void ConvertBGRAToABGR (_THIS, SDL_Surface * surface); |
71 | 71 |
72 static int InitNew(_THIS, SDL_Surface *current); | 72 static int InitNew (_THIS, SDL_Surface * current); |
73 static int InitOld(_THIS, SDL_Surface *current); | 73 static int InitOld (_THIS, SDL_Surface * current); |
74 #endif | 74 #endif |
75 | 75 |
76 /*--- Public functions ---*/ | 76 /*--- Public functions ---*/ |
77 | 77 |
78 int SDL_AtariGL_Init(_THIS, SDL_Surface *current) | 78 int |
79 SDL_AtariGL_Init (_THIS, SDL_Surface * current) | |
79 { | 80 { |
80 #if SDL_VIDEO_OPENGL | 81 #if SDL_VIDEO_OPENGL |
81 if (gl_oldmesa) { | 82 if (gl_oldmesa) { |
82 gl_active = InitOld(this, current); | 83 gl_active = InitOld (this, current); |
83 } else { | 84 } else { |
84 gl_active = InitNew(this, current); | 85 gl_active = InitNew (this, current); |
85 } | 86 } |
86 #endif | 87 #endif |
87 | 88 |
88 return (gl_active); | 89 return (gl_active); |
89 } | 90 } |
90 | 91 |
91 void SDL_AtariGL_Quit(_THIS, SDL_bool unload) | 92 void |
93 SDL_AtariGL_Quit (_THIS, SDL_bool unload) | |
92 { | 94 { |
93 #if SDL_VIDEO_OPENGL | 95 #if SDL_VIDEO_OPENGL |
94 if (gl_oldmesa) { | 96 if (gl_oldmesa) { |
95 /* Old mesa implementations */ | 97 /* Old mesa implementations */ |
96 if (this->gl_data->OSMesaDestroyLDG) { | 98 if (this->gl_data->OSMesaDestroyLDG) { |
97 this->gl_data->OSMesaDestroyLDG(); | 99 this->gl_data->OSMesaDestroyLDG (); |
98 } | 100 } |
99 if (gl_shadow) { | 101 if (gl_shadow) { |
100 Mfree(gl_shadow); | 102 Mfree (gl_shadow); |
101 gl_shadow = NULL; | 103 gl_shadow = NULL; |
102 } | 104 } |
103 } else { | 105 } else { |
104 /* New mesa implementation */ | 106 /* New mesa implementation */ |
105 if (gl_ctx) { | 107 if (gl_ctx) { |
106 if (this->gl_data->OSMesaDestroyContext) { | 108 if (this->gl_data->OSMesaDestroyContext) { |
107 this->gl_data->OSMesaDestroyContext(gl_ctx); | 109 this->gl_data->OSMesaDestroyContext (gl_ctx); |
108 } | 110 } |
109 gl_ctx = NULL; | 111 gl_ctx = NULL; |
110 } | 112 } |
111 } | 113 } |
112 | 114 |
113 if (unload) { | 115 if (unload) { |
114 SDL_AtariGL_UnloadLibrary(this); | 116 SDL_AtariGL_UnloadLibrary (this); |
115 } | 117 } |
116 | |
117 #endif /* SDL_VIDEO_OPENGL */ | 118 #endif /* SDL_VIDEO_OPENGL */ |
118 gl_active = 0; | 119 gl_active = 0; |
119 } | 120 } |
120 | 121 |
121 int SDL_AtariGL_LoadLibrary(_THIS, const char *path) | 122 int |
123 SDL_AtariGL_LoadLibrary (_THIS, const char *path) | |
122 { | 124 { |
123 #if SDL_VIDEO_OPENGL | 125 #if SDL_VIDEO_OPENGL |
124 | 126 |
125 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC | 127 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC |
126 void *handle; | 128 void *handle; |
127 SDL_bool cancel_load; | 129 SDL_bool cancel_load; |
128 | 130 |
129 if (gl_active) { | 131 if (gl_active) { |
130 SDL_SetError("OpenGL context already created"); | 132 SDL_SetError ("OpenGL context already created"); |
131 return -1; | 133 return -1; |
132 } | 134 } |
133 | 135 |
134 /* Unload previous driver */ | 136 /* Unload previous driver */ |
135 SDL_AtariGL_UnloadLibrary(this); | 137 SDL_AtariGL_UnloadLibrary (this); |
136 | 138 |
137 /* Load library given by path */ | 139 /* Load library given by path */ |
138 handle = SDL_LoadObject(path); | 140 handle = SDL_LoadObject (path); |
139 if (handle == NULL) { | 141 if (handle == NULL) { |
140 /* Try to load another one */ | 142 /* Try to load another one */ |
141 path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); | 143 path = SDL_getenv ("SDL_VIDEO_GL_DRIVER"); |
142 if ( path != NULL ) { | 144 if (path != NULL) { |
143 handle = SDL_LoadObject(path); | 145 handle = SDL_LoadObject (path); |
144 } | 146 } |
145 | 147 |
146 /* If it does not work, try some other */ | 148 /* If it does not work, try some other */ |
147 if (handle == NULL) { | 149 if (handle == NULL) { |
148 path = PATH_OSMESA_LDG; | 150 path = PATH_OSMESA_LDG; |
149 handle = SDL_LoadObject(path); | 151 handle = SDL_LoadObject (path); |
150 } | 152 } |
151 | 153 |
152 if (handle == NULL) { | 154 if (handle == NULL) { |
153 path = PATH_MESAGL_LDG; | 155 path = PATH_MESAGL_LDG; |
154 handle = SDL_LoadObject(path); | 156 handle = SDL_LoadObject (path); |
155 } | 157 } |
156 | 158 |
157 if (handle == NULL) { | 159 if (handle == NULL) { |
158 path = PATH_TINYGL_LDG; | 160 path = PATH_TINYGL_LDG; |
159 handle = SDL_LoadObject(path); | 161 handle = SDL_LoadObject (path); |
160 } | 162 } |
161 } | 163 } |
162 | 164 |
163 if (handle == NULL) { | 165 if (handle == NULL) { |
164 SDL_SetError("Could not load OpenGL library"); | 166 SDL_SetError ("Could not load OpenGL library"); |
165 return -1; | 167 return -1; |
166 } | 168 } |
167 | 169 |
168 this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); | 170 this->gl_data->glGetIntegerv = SDL_LoadFunction (handle, "glGetIntegerv"); |
169 this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish"); | 171 this->gl_data->glFinish = SDL_LoadFunction (handle, "glFinish"); |
170 this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush"); | 172 this->gl_data->glFlush = SDL_LoadFunction (handle, "glFlush"); |
171 | 173 |
172 cancel_load = SDL_FALSE; | 174 cancel_load = SDL_FALSE; |
173 if (this->gl_data->glGetIntegerv == NULL) { | 175 if (this->gl_data->glGetIntegerv == NULL) { |
174 cancel_load = SDL_TRUE; | 176 cancel_load = SDL_TRUE; |
175 } else { | 177 } else { |
176 /* We need either glFinish (OSMesa) or glFlush (TinyGL) */ | 178 /* We need either glFinish (OSMesa) or glFlush (TinyGL) */ |
177 if ((this->gl_data->glFinish == NULL) && | 179 if ((this->gl_data->glFinish == NULL) && |
178 (this->gl_data->glFlush == NULL)) { | 180 (this->gl_data->glFlush == NULL)) { |
179 cancel_load = SDL_TRUE; | 181 cancel_load = SDL_TRUE; |
180 } | 182 } |
181 } | 183 } |
182 if (cancel_load) { | 184 if (cancel_load) { |
183 SDL_SetError("Could not retrieve OpenGL functions"); | 185 SDL_SetError ("Could not retrieve OpenGL functions"); |
184 SDL_UnloadObject(handle); | 186 SDL_UnloadObject (handle); |
185 /* Restore pointers to static library */ | 187 /* Restore pointers to static library */ |
186 SDL_AtariGL_InitPointers(this); | 188 SDL_AtariGL_InitPointers (this); |
187 return -1; | 189 return -1; |
188 } | 190 } |
189 | 191 |
190 /* Load functions pointers (osmesa.ldg) */ | 192 /* Load functions pointers (osmesa.ldg) */ |
191 this->gl_data->OSMesaCreateContextExt = SDL_LoadFunction(handle, "OSMesaCreateContextExt"); | 193 this->gl_data->OSMesaCreateContextExt = |
192 this->gl_data->OSMesaDestroyContext = SDL_LoadFunction(handle, "OSMesaDestroyContext"); | 194 SDL_LoadFunction (handle, "OSMesaCreateContextExt"); |
193 this->gl_data->OSMesaMakeCurrent = SDL_LoadFunction(handle, "OSMesaMakeCurrent"); | 195 this->gl_data->OSMesaDestroyContext = |
194 this->gl_data->OSMesaPixelStore = SDL_LoadFunction(handle, "OSMesaPixelStore"); | 196 SDL_LoadFunction (handle, "OSMesaDestroyContext"); |
195 this->gl_data->OSMesaGetProcAddress = SDL_LoadFunction(handle, "OSMesaGetProcAddress"); | 197 this->gl_data->OSMesaMakeCurrent = |
196 | 198 SDL_LoadFunction (handle, "OSMesaMakeCurrent"); |
197 /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ | 199 this->gl_data->OSMesaPixelStore = |
198 this->gl_data->OSMesaCreateLDG = SDL_LoadFunction(handle, "OSMesaCreateLDG"); | 200 SDL_LoadFunction (handle, "OSMesaPixelStore"); |
199 this->gl_data->OSMesaDestroyLDG = SDL_LoadFunction(handle, "OSMesaDestroyLDG"); | 201 this->gl_data->OSMesaGetProcAddress = |
200 | 202 SDL_LoadFunction (handle, "OSMesaGetProcAddress"); |
201 gl_oldmesa = 0; | 203 |
202 | 204 /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ |
203 if ( (this->gl_data->OSMesaCreateContextExt == NULL) || | 205 this->gl_data->OSMesaCreateLDG = |
204 (this->gl_data->OSMesaDestroyContext == NULL) || | 206 SDL_LoadFunction (handle, "OSMesaCreateLDG"); |
205 (this->gl_data->OSMesaMakeCurrent == NULL) || | 207 this->gl_data->OSMesaDestroyLDG = |
206 (this->gl_data->OSMesaPixelStore == NULL) || | 208 SDL_LoadFunction (handle, "OSMesaDestroyLDG"); |
207 (this->gl_data->OSMesaGetProcAddress == NULL)) { | 209 |
208 /* Hum, maybe old library ? */ | 210 gl_oldmesa = 0; |
209 if ( (this->gl_data->OSMesaCreateLDG == NULL) || | 211 |
210 (this->gl_data->OSMesaDestroyLDG == NULL)) { | 212 if ((this->gl_data->OSMesaCreateContextExt == NULL) || |
211 SDL_SetError("Could not retrieve OSMesa functions"); | 213 (this->gl_data->OSMesaDestroyContext == NULL) || |
212 SDL_UnloadObject(handle); | 214 (this->gl_data->OSMesaMakeCurrent == NULL) || |
213 /* Restore pointers to static library */ | 215 (this->gl_data->OSMesaPixelStore == NULL) || |
214 SDL_AtariGL_InitPointers(this); | 216 (this->gl_data->OSMesaGetProcAddress == NULL)) { |
215 return -1; | 217 /* Hum, maybe old library ? */ |
216 } else { | 218 if ((this->gl_data->OSMesaCreateLDG == NULL) || |
217 gl_oldmesa = 1; | 219 (this->gl_data->OSMesaDestroyLDG == NULL)) { |
218 } | 220 SDL_SetError ("Could not retrieve OSMesa functions"); |
219 } | 221 SDL_UnloadObject (handle); |
220 | 222 /* Restore pointers to static library */ |
221 this->gl_config.dll_handle = handle; | 223 SDL_AtariGL_InitPointers (this); |
222 if ( path ) { | 224 return -1; |
223 SDL_strlcpy(this->gl_config.driver_path, path, | 225 } else { |
224 SDL_arraysize(this->gl_config.driver_path)); | 226 gl_oldmesa = 1; |
225 } else { | 227 } |
226 *this->gl_config.driver_path = '\0'; | 228 } |
227 } | 229 |
230 this->gl_config.dll_handle = handle; | |
231 if (path) { | |
232 SDL_strlcpy (this->gl_config.driver_path, path, | |
233 SDL_arraysize (this->gl_config.driver_path)); | |
234 } else { | |
235 *this->gl_config.driver_path = '\0'; | |
236 } | |
228 | 237 |
229 #endif | 238 #endif |
230 this->gl_config.driver_loaded = 1; | 239 this->gl_config.driver_loaded = 1; |
231 | 240 |
232 return 0; | 241 return 0; |
233 #else | 242 #else |
234 return -1; | 243 return -1; |
235 #endif | 244 #endif |
236 } | 245 } |
237 | 246 |
238 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc) | 247 void * |
239 { | 248 SDL_AtariGL_GetProcAddress (_THIS, const char *proc) |
240 void *func = NULL; | 249 { |
250 void *func = NULL; | |
241 #if SDL_VIDEO_OPENGL | 251 #if SDL_VIDEO_OPENGL |
242 | 252 |
243 if (this->gl_config.dll_handle) { | 253 if (this->gl_config.dll_handle) { |
244 func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc); | 254 func = SDL_LoadFunction (this->gl_config.dll_handle, (void *) proc); |
245 } else if (this->gl_data->OSMesaGetProcAddress) { | 255 } else if (this->gl_data->OSMesaGetProcAddress) { |
246 func = this->gl_data->OSMesaGetProcAddress(proc); | 256 func = this->gl_data->OSMesaGetProcAddress (proc); |
247 } | 257 } |
248 | |
249 #endif | 258 #endif |
250 return func; | 259 return func; |
251 } | 260 } |
252 | 261 |
253 int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) | 262 int |
263 SDL_AtariGL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) | |
254 { | 264 { |
255 #if SDL_VIDEO_OPENGL | 265 #if SDL_VIDEO_OPENGL |
256 GLenum mesa_attrib; | 266 GLenum mesa_attrib; |
257 SDL_Surface *surface; | 267 SDL_Surface *surface; |
258 | 268 |
259 if (!gl_active) { | 269 if (!gl_active) { |
260 return -1; | 270 return -1; |
261 } | 271 } |
262 | 272 |
263 switch(attrib) { | 273 switch (attrib) { |
264 case SDL_GL_RED_SIZE: | 274 case SDL_GL_RED_SIZE: |
265 mesa_attrib = GL_RED_BITS; | 275 mesa_attrib = GL_RED_BITS; |
266 break; | 276 break; |
267 case SDL_GL_GREEN_SIZE: | 277 case SDL_GL_GREEN_SIZE: |
268 mesa_attrib = GL_GREEN_BITS; | 278 mesa_attrib = GL_GREEN_BITS; |
269 break; | 279 break; |
270 case SDL_GL_BLUE_SIZE: | 280 case SDL_GL_BLUE_SIZE: |
271 mesa_attrib = GL_BLUE_BITS; | 281 mesa_attrib = GL_BLUE_BITS; |
272 break; | 282 break; |
273 case SDL_GL_ALPHA_SIZE: | 283 case SDL_GL_ALPHA_SIZE: |
274 mesa_attrib = GL_ALPHA_BITS; | 284 mesa_attrib = GL_ALPHA_BITS; |
275 break; | 285 break; |
276 case SDL_GL_DOUBLEBUFFER: | 286 case SDL_GL_DOUBLEBUFFER: |
277 surface = this->screen; | 287 surface = this->screen; |
278 *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF); | 288 *value = ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF); |
279 return 0; | 289 return 0; |
280 case SDL_GL_DEPTH_SIZE: | 290 case SDL_GL_DEPTH_SIZE: |
281 mesa_attrib = GL_DEPTH_BITS; | 291 mesa_attrib = GL_DEPTH_BITS; |
282 break; | 292 break; |
283 case SDL_GL_STENCIL_SIZE: | 293 case SDL_GL_STENCIL_SIZE: |
284 mesa_attrib = GL_STENCIL_BITS; | 294 mesa_attrib = GL_STENCIL_BITS; |
285 break; | 295 break; |
286 case SDL_GL_ACCUM_RED_SIZE: | 296 case SDL_GL_ACCUM_RED_SIZE: |
287 mesa_attrib = GL_ACCUM_RED_BITS; | 297 mesa_attrib = GL_ACCUM_RED_BITS; |
288 break; | 298 break; |
289 case SDL_GL_ACCUM_GREEN_SIZE: | 299 case SDL_GL_ACCUM_GREEN_SIZE: |
290 mesa_attrib = GL_ACCUM_GREEN_BITS; | 300 mesa_attrib = GL_ACCUM_GREEN_BITS; |
291 break; | 301 break; |
292 case SDL_GL_ACCUM_BLUE_SIZE: | 302 case SDL_GL_ACCUM_BLUE_SIZE: |
293 mesa_attrib = GL_ACCUM_BLUE_BITS; | 303 mesa_attrib = GL_ACCUM_BLUE_BITS; |
294 break; | 304 break; |
295 case SDL_GL_ACCUM_ALPHA_SIZE: | 305 case SDL_GL_ACCUM_ALPHA_SIZE: |
296 mesa_attrib = GL_ACCUM_ALPHA_BITS; | 306 mesa_attrib = GL_ACCUM_ALPHA_BITS; |
297 break; | 307 break; |
298 default : | 308 default: |
299 return -1; | 309 return -1; |
300 } | 310 } |
301 | 311 |
302 this->gl_data->glGetIntegerv(mesa_attrib, value); | 312 this->gl_data->glGetIntegerv (mesa_attrib, value); |
303 return 0; | 313 return 0; |
304 #else | 314 #else |
305 return -1; | 315 return -1; |
306 #endif | 316 #endif |
307 } | 317 } |
308 | 318 |
309 int SDL_AtariGL_MakeCurrent(_THIS) | 319 int |
320 SDL_AtariGL_MakeCurrent (_THIS) | |
310 { | 321 { |
311 #if SDL_VIDEO_OPENGL | 322 #if SDL_VIDEO_OPENGL |
312 SDL_Surface *surface; | 323 SDL_Surface *surface; |
313 GLenum type; | 324 GLenum type; |
314 | 325 |
315 if (gl_oldmesa && gl_active) { | 326 if (gl_oldmesa && gl_active) { |
316 return 0; | 327 return 0; |
317 } | 328 } |
318 | 329 |
319 if (this->gl_config.dll_handle) { | 330 if (this->gl_config.dll_handle) { |
320 if ((this->gl_data->OSMesaMakeCurrent == NULL) || | 331 if ((this->gl_data->OSMesaMakeCurrent == NULL) || |
321 (this->gl_data->OSMesaPixelStore == NULL)) { | 332 (this->gl_data->OSMesaPixelStore == NULL)) { |
322 return -1; | 333 return -1; |
323 } | 334 } |
324 } | 335 } |
325 | 336 |
326 if (!gl_active) { | 337 if (!gl_active) { |
327 SDL_SetError("Invalid OpenGL context"); | 338 SDL_SetError ("Invalid OpenGL context"); |
328 return -1; | 339 return -1; |
329 } | 340 } |
330 | 341 |
331 surface = this->screen; | 342 surface = this->screen; |
332 | 343 |
333 if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) { | 344 if ((surface->format->BitsPerPixel == 15) |
334 type = GL_UNSIGNED_SHORT_5_6_5; | 345 || (surface->format->BitsPerPixel == 16)) { |
335 } else { | 346 type = GL_UNSIGNED_SHORT_5_6_5; |
336 type = GL_UNSIGNED_BYTE; | 347 } else { |
337 } | 348 type = GL_UNSIGNED_BYTE; |
338 | 349 } |
339 if (!(this->gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, surface->h))) { | 350 |
340 SDL_SetError("Can not make OpenGL context current"); | 351 if (! |
341 return -1; | 352 (this->gl_data-> |
342 } | 353 OSMesaMakeCurrent (gl_ctx, surface->pixels, type, surface->w, |
343 | 354 surface->h))) { |
344 /* OSMesa draws upside down */ | 355 SDL_SetError ("Can not make OpenGL context current"); |
345 this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0); | 356 return -1; |
346 | 357 } |
347 return 0; | 358 |
359 /* OSMesa draws upside down */ | |
360 this->gl_data->OSMesaPixelStore (OSMESA_Y_UP, 0); | |
361 | |
362 return 0; | |
348 #else | 363 #else |
349 return -1; | 364 return -1; |
350 #endif | 365 #endif |
351 } | 366 } |
352 | 367 |
353 void SDL_AtariGL_SwapBuffers(_THIS) | 368 void |
369 SDL_AtariGL_SwapBuffers (_THIS) | |
354 { | 370 { |
355 #if SDL_VIDEO_OPENGL | 371 #if SDL_VIDEO_OPENGL |
356 if (gl_active) { | 372 if (gl_active) { |
357 if (this->gl_config.dll_handle) { | 373 if (this->gl_config.dll_handle) { |
358 if (this->gl_data->glFinish) { | 374 if (this->gl_data->glFinish) { |
359 this->gl_data->glFinish(); | 375 this->gl_data->glFinish (); |
360 } else if (this->gl_data->glFlush) { | 376 } else if (this->gl_data->glFlush) { |
361 this->gl_data->glFlush(); | 377 this->gl_data->glFlush (); |
362 } | 378 } |
363 } else { | 379 } else { |
364 this->gl_data->glFinish(); | 380 this->gl_data->glFinish (); |
365 } | 381 } |
366 gl_copyshadow(this, this->screen); | 382 gl_copyshadow (this, this->screen); |
367 gl_convert(this, this->screen); | 383 gl_convert (this, this->screen); |
368 } | 384 } |
369 #endif | 385 #endif |
370 } | 386 } |
371 | 387 |
372 void SDL_AtariGL_InitPointers(_THIS) | 388 void |
389 SDL_AtariGL_InitPointers (_THIS) | |
373 { | 390 { |
374 #if SDL_VIDEO_OPENGL | 391 #if SDL_VIDEO_OPENGL |
375 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; | 392 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; |
376 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; | 393 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; |
377 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; | 394 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; |
378 this->gl_data->OSMesaPixelStore = OSMesaPixelStore; | 395 this->gl_data->OSMesaPixelStore = OSMesaPixelStore; |
379 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; | 396 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; |
380 | 397 |
381 this->gl_data->glGetIntegerv = glGetIntegerv; | 398 this->gl_data->glGetIntegerv = glGetIntegerv; |
382 this->gl_data->glFinish = glFinish; | 399 this->gl_data->glFinish = glFinish; |
383 this->gl_data->glFlush = glFlush; | 400 this->gl_data->glFlush = glFlush; |
384 | 401 |
385 this->gl_data->OSMesaCreateLDG = NULL; | 402 this->gl_data->OSMesaCreateLDG = NULL; |
386 this->gl_data->OSMesaDestroyLDG = NULL; | 403 this->gl_data->OSMesaDestroyLDG = NULL; |
387 #endif | 404 #endif |
388 } | 405 } |
389 | 406 |
390 /*--- Private functions ---*/ | 407 /*--- Private functions ---*/ |
391 | 408 |
392 static void SDL_AtariGL_UnloadLibrary(_THIS) | 409 static void |
410 SDL_AtariGL_UnloadLibrary (_THIS) | |
393 { | 411 { |
394 #if SDL_VIDEO_OPENGL | 412 #if SDL_VIDEO_OPENGL |
395 if (this->gl_config.dll_handle) { | 413 if (this->gl_config.dll_handle) { |
396 SDL_UnloadObject(this->gl_config.dll_handle); | 414 SDL_UnloadObject (this->gl_config.dll_handle); |
397 this->gl_config.dll_handle = NULL; | 415 this->gl_config.dll_handle = NULL; |
398 | 416 |
399 /* Restore pointers to static library */ | 417 /* Restore pointers to static library */ |
400 SDL_AtariGL_InitPointers(this); | 418 SDL_AtariGL_InitPointers (this); |
401 } | 419 } |
402 #endif | 420 #endif |
403 } | 421 } |
404 | 422 |
405 /*--- Creation of an OpenGL context using new/old functions ---*/ | 423 /*--- Creation of an OpenGL context using new/old functions ---*/ |
406 | 424 |
407 #if SDL_VIDEO_OPENGL | 425 #if SDL_VIDEO_OPENGL |
408 static int InitNew(_THIS, SDL_Surface *current) | 426 static int |
409 { | 427 InitNew (_THIS, SDL_Surface * current) |
410 GLenum osmesa_format; | 428 { |
411 SDL_PixelFormat *pixel_format; | 429 GLenum osmesa_format; |
412 Uint32 redmask; | 430 SDL_PixelFormat *pixel_format; |
413 int recreatecontext; | 431 Uint32 redmask; |
414 GLint newaccumsize; | 432 int recreatecontext; |
415 | 433 GLint newaccumsize; |
416 if (this->gl_config.dll_handle) { | 434 |
417 if (this->gl_data->OSMesaCreateContextExt == NULL) { | 435 if (this->gl_config.dll_handle) { |
418 return 0; | 436 if (this->gl_data->OSMesaCreateContextExt == NULL) { |
419 } | 437 return 0; |
420 } | 438 } |
421 | 439 } |
422 /* Init OpenGL context using OSMesa */ | 440 |
423 gl_convert = ConvertNull; | 441 /* Init OpenGL context using OSMesa */ |
424 gl_copyshadow = CopyShadowNull; | 442 gl_convert = ConvertNull; |
425 gl_upsidedown = SDL_FALSE; | 443 gl_copyshadow = CopyShadowNull; |
426 | 444 gl_upsidedown = SDL_FALSE; |
427 pixel_format = current->format; | 445 |
428 redmask = pixel_format->Rmask; | 446 pixel_format = current->format; |
429 switch (pixel_format->BitsPerPixel) { | 447 redmask = pixel_format->Rmask; |
430 case 15: | 448 switch (pixel_format->BitsPerPixel) { |
431 /* 1555, big and little endian, unsupported */ | 449 case 15: |
432 gl_pixelsize = 2; | 450 /* 1555, big and little endian, unsupported */ |
433 osmesa_format = OSMESA_RGB_565; | 451 gl_pixelsize = 2; |
434 if (redmask == 31<<10) { | 452 osmesa_format = OSMESA_RGB_565; |
435 gl_convert = Convert565To555be; | 453 if (redmask == 31 << 10) { |
436 } else { | 454 gl_convert = Convert565To555be; |
437 gl_convert = Convert565To555le; | 455 } else { |
438 } | 456 gl_convert = Convert565To555le; |
439 break; | 457 } |
440 case 16: | 458 break; |
441 gl_pixelsize = 2; | 459 case 16: |
442 if (redmask == 31<<11) { | 460 gl_pixelsize = 2; |
443 osmesa_format = OSMESA_RGB_565; | 461 if (redmask == 31 << 11) { |
444 } else { | 462 osmesa_format = OSMESA_RGB_565; |
445 /* 565, little endian, unsupported */ | 463 } else { |
446 osmesa_format = OSMESA_RGB_565; | 464 /* 565, little endian, unsupported */ |
447 gl_convert = Convert565le; | 465 osmesa_format = OSMESA_RGB_565; |
448 } | 466 gl_convert = Convert565le; |
449 break; | 467 } |
450 case 24: | 468 break; |
451 gl_pixelsize = 3; | 469 case 24: |
452 if (redmask == 255<<16) { | 470 gl_pixelsize = 3; |
453 osmesa_format = OSMESA_RGB; | 471 if (redmask == 255 << 16) { |
454 } else { | 472 osmesa_format = OSMESA_RGB; |
455 osmesa_format = OSMESA_BGR; | 473 } else { |
456 } | 474 osmesa_format = OSMESA_BGR; |
457 break; | 475 } |
458 case 32: | 476 break; |
459 gl_pixelsize = 4; | 477 case 32: |
460 if (redmask == 255<<16) { | 478 gl_pixelsize = 4; |
461 osmesa_format = OSMESA_ARGB; | 479 if (redmask == 255 << 16) { |
462 } else if (redmask == 255<<8) { | 480 osmesa_format = OSMESA_ARGB; |
463 osmesa_format = OSMESA_BGRA; | 481 } else if (redmask == 255 << 8) { |
464 } else if (redmask == 255<<24) { | 482 osmesa_format = OSMESA_BGRA; |
465 osmesa_format = OSMESA_RGBA; | 483 } else if (redmask == 255 << 24) { |
466 } else { | 484 osmesa_format = OSMESA_RGBA; |
467 /* ABGR format unsupported */ | 485 } else { |
468 osmesa_format = OSMESA_BGRA; | 486 /* ABGR format unsupported */ |
469 gl_convert = ConvertBGRAToABGR; | 487 osmesa_format = OSMESA_BGRA; |
470 } | 488 gl_convert = ConvertBGRAToABGR; |
471 break; | 489 } |
472 default: | 490 break; |
473 gl_pixelsize = 1; | 491 default: |
474 osmesa_format = OSMESA_COLOR_INDEX; | 492 gl_pixelsize = 1; |
475 break; | 493 osmesa_format = OSMESA_COLOR_INDEX; |
476 } | 494 break; |
477 | 495 } |
478 /* Try to keep current context if possible */ | 496 |
479 newaccumsize = | 497 /* Try to keep current context if possible */ |
480 this->gl_config.accum_red_size + | 498 newaccumsize = |
481 this->gl_config.accum_green_size + | 499 this->gl_config.accum_red_size + |
482 this->gl_config.accum_blue_size + | 500 this->gl_config.accum_green_size + |
483 this->gl_config.accum_alpha_size; | 501 this->gl_config.accum_blue_size + this->gl_config.accum_alpha_size; |
484 recreatecontext=1; | 502 recreatecontext = 1; |
485 if (gl_ctx && | 503 if (gl_ctx && |
486 (gl_curformat == osmesa_format) && | 504 (gl_curformat == osmesa_format) && |
487 (gl_curdepth == this->gl_config.depth_size) && | 505 (gl_curdepth == this->gl_config.depth_size) && |
488 (gl_curstencil == this->gl_config.stencil_size) && | 506 (gl_curstencil == this->gl_config.stencil_size) && |
489 (gl_curaccum == newaccumsize)) { | 507 (gl_curaccum == newaccumsize)) { |
490 recreatecontext = 0; | 508 recreatecontext = 0; |
491 } | 509 } |
492 if (recreatecontext) { | 510 if (recreatecontext) { |
493 SDL_AtariGL_Quit(this, SDL_FALSE); | 511 SDL_AtariGL_Quit (this, SDL_FALSE); |
494 | 512 |
495 gl_ctx = this->gl_data->OSMesaCreateContextExt( | 513 gl_ctx = |
496 osmesa_format, this->gl_config.depth_size, | 514 this->gl_data->OSMesaCreateContextExt (osmesa_format, |
497 this->gl_config.stencil_size, newaccumsize, NULL ); | 515 this->gl_config. |
498 | 516 depth_size, |
499 if (gl_ctx) { | 517 this->gl_config. |
500 gl_curformat = osmesa_format; | 518 stencil_size, |
501 gl_curdepth = this->gl_config.depth_size; | 519 newaccumsize, NULL); |
502 gl_curstencil = this->gl_config.stencil_size; | 520 |
503 gl_curaccum = newaccumsize; | 521 if (gl_ctx) { |
504 } else { | 522 gl_curformat = osmesa_format; |
505 gl_curformat = 0; | 523 gl_curdepth = this->gl_config.depth_size; |
506 gl_curdepth = 0; | 524 gl_curstencil = this->gl_config.stencil_size; |
507 gl_curstencil = 0; | 525 gl_curaccum = newaccumsize; |
508 gl_curaccum = 0; | 526 } else { |
509 } | 527 gl_curformat = 0; |
510 } | 528 gl_curdepth = 0; |
511 | 529 gl_curstencil = 0; |
512 return (gl_ctx != NULL); | 530 gl_curaccum = 0; |
513 } | 531 } |
514 | 532 } |
515 | 533 |
516 static int InitOld(_THIS, SDL_Surface *current) | 534 return (gl_ctx != NULL); |
517 { | 535 } |
518 GLenum osmesa_format; | 536 |
519 SDL_PixelFormat *pixel_format; | 537 |
520 Uint32 redmask; | 538 static int |
521 int recreatecontext, tinygl_present; | 539 InitOld (_THIS, SDL_Surface * current) |
522 | 540 { |
523 if (this->gl_config.dll_handle) { | 541 GLenum osmesa_format; |
524 if (this->gl_data->OSMesaCreateLDG == NULL) { | 542 SDL_PixelFormat *pixel_format; |
525 return 0; | 543 Uint32 redmask; |
526 } | 544 int recreatecontext, tinygl_present; |
527 } | 545 |
528 | 546 if (this->gl_config.dll_handle) { |
529 /* TinyGL only supports VDI_RGB (OSMESA_RGB) */ | 547 if (this->gl_data->OSMesaCreateLDG == NULL) { |
530 tinygl_present=0; | 548 return 0; |
531 if (this->gl_config.dll_handle) { | 549 } |
532 if (this->gl_data->glFinish == NULL) { | 550 } |
533 tinygl_present=1; | 551 |
534 } | 552 /* TinyGL only supports VDI_RGB (OSMESA_RGB) */ |
535 } | 553 tinygl_present = 0; |
536 | 554 if (this->gl_config.dll_handle) { |
537 /* Init OpenGL context using OSMesa */ | 555 if (this->gl_data->glFinish == NULL) { |
538 gl_convert = ConvertNull; | 556 tinygl_present = 1; |
539 gl_copyshadow = CopyShadowNull; | 557 } |
540 gl_upsidedown = SDL_FALSE; | 558 } |
541 | 559 |
542 pixel_format = current->format; | 560 /* Init OpenGL context using OSMesa */ |
543 redmask = pixel_format->Rmask; | 561 gl_convert = ConvertNull; |
544 switch (pixel_format->BitsPerPixel) { | 562 gl_copyshadow = CopyShadowNull; |
545 case 15: | 563 gl_upsidedown = SDL_FALSE; |
546 /* 15 bits unsupported */ | 564 |
547 if (tinygl_present) { | 565 pixel_format = current->format; |
548 gl_pixelsize = 3; | 566 redmask = pixel_format->Rmask; |
549 osmesa_format = VDI_RGB; | 567 switch (pixel_format->BitsPerPixel) { |
550 if (redmask == 31<<10) { | 568 case 15: |
551 gl_copyshadow = CopyShadowRGBTo555; | 569 /* 15 bits unsupported */ |
552 } else { | 570 if (tinygl_present) { |
553 gl_copyshadow = CopyShadowRGBTo565; | 571 gl_pixelsize = 3; |
554 gl_convert = Convert565To555le; | 572 osmesa_format = VDI_RGB; |
555 } | 573 if (redmask == 31 << 10) { |
556 } else { | 574 gl_copyshadow = CopyShadowRGBTo555; |
557 gl_pixelsize = 4; | 575 } else { |
558 gl_upsidedown = SDL_TRUE; | 576 gl_copyshadow = CopyShadowRGBTo565; |
559 osmesa_format = OSMESA_ARGB; | 577 gl_convert = Convert565To555le; |
560 if (redmask == 31<<10) { | 578 } |
561 gl_copyshadow = CopyShadow8888To555; | 579 } else { |
562 } else { | 580 gl_pixelsize = 4; |
563 gl_copyshadow = CopyShadow8888To565; | 581 gl_upsidedown = SDL_TRUE; |
564 gl_convert = Convert565To555le; | 582 osmesa_format = OSMESA_ARGB; |
565 } | 583 if (redmask == 31 << 10) { |
566 } | 584 gl_copyshadow = CopyShadow8888To555; |
567 break; | 585 } else { |
568 case 16: | 586 gl_copyshadow = CopyShadow8888To565; |
569 /* 16 bits unsupported */ | 587 gl_convert = Convert565To555le; |
570 if (tinygl_present) { | 588 } |
571 gl_pixelsize = 3; | 589 } |
572 osmesa_format = VDI_RGB; | 590 break; |
573 gl_copyshadow = CopyShadowRGBTo565; | 591 case 16: |
574 if (redmask != 31<<11) { | 592 /* 16 bits unsupported */ |
575 /* 565, little endian, unsupported */ | 593 if (tinygl_present) { |
576 gl_convert = Convert565le; | 594 gl_pixelsize = 3; |
577 } | 595 osmesa_format = VDI_RGB; |
578 } else { | 596 gl_copyshadow = CopyShadowRGBTo565; |
579 gl_pixelsize = 4; | 597 if (redmask != 31 << 11) { |
580 gl_upsidedown = SDL_TRUE; | 598 /* 565, little endian, unsupported */ |
581 osmesa_format = OSMESA_ARGB; | 599 gl_convert = Convert565le; |
582 gl_copyshadow = CopyShadow8888To565; | 600 } |
583 if (redmask != 31<<11) { | 601 } else { |
584 /* 565, little endian, unsupported */ | 602 gl_pixelsize = 4; |
585 gl_convert = Convert565le; | 603 gl_upsidedown = SDL_TRUE; |
586 } | 604 osmesa_format = OSMESA_ARGB; |
587 } | 605 gl_copyshadow = CopyShadow8888To565; |
588 break; | 606 if (redmask != 31 << 11) { |
589 case 24: | 607 /* 565, little endian, unsupported */ |
590 gl_pixelsize = 3; | 608 gl_convert = Convert565le; |
591 if (tinygl_present) { | 609 } |
592 osmesa_format = VDI_RGB; | 610 } |
593 gl_copyshadow = CopyShadowDirect; | 611 break; |
594 if (redmask != 255<<16) { | 612 case 24: |
595 gl_copyshadow = CopyShadowRGBSwap; | 613 gl_pixelsize = 3; |
596 } | 614 if (tinygl_present) { |
597 } else { | 615 osmesa_format = VDI_RGB; |
598 gl_copyshadow = CopyShadowDirect; | 616 gl_copyshadow = CopyShadowDirect; |
599 gl_upsidedown = SDL_TRUE; | 617 if (redmask != 255 << 16) { |
600 if (redmask == 255<<16) { | 618 gl_copyshadow = CopyShadowRGBSwap; |
601 osmesa_format = OSMESA_RGB; | 619 } |
602 } else { | 620 } else { |
603 osmesa_format = OSMESA_BGR; | 621 gl_copyshadow = CopyShadowDirect; |
604 } | 622 gl_upsidedown = SDL_TRUE; |
605 } | 623 if (redmask == 255 << 16) { |
606 break; | 624 osmesa_format = OSMESA_RGB; |
607 case 32: | 625 } else { |
608 if (tinygl_present) { | 626 osmesa_format = OSMESA_BGR; |
609 gl_pixelsize = 3; | 627 } |
610 osmesa_format = VDI_RGB; | 628 } |
611 gl_copyshadow = CopyShadowRGBToARGB; | 629 break; |
612 if (redmask == 255) { | 630 case 32: |
613 gl_convert = CopyShadowRGBToABGR; | 631 if (tinygl_present) { |
614 } else if (redmask == 255<<8) { | 632 gl_pixelsize = 3; |
615 gl_convert = CopyShadowRGBToBGRA; | 633 osmesa_format = VDI_RGB; |
616 } else if (redmask == 255<<24) { | 634 gl_copyshadow = CopyShadowRGBToARGB; |
617 gl_convert = CopyShadowRGBToRGBA; | 635 if (redmask == 255) { |
618 } | 636 gl_convert = CopyShadowRGBToABGR; |
619 } else { | 637 } else if (redmask == 255 << 8) { |
620 gl_pixelsize = 4; | 638 gl_convert = CopyShadowRGBToBGRA; |
621 gl_upsidedown = SDL_TRUE; | 639 } else if (redmask == 255 << 24) { |
622 gl_copyshadow = CopyShadowDirect; | 640 gl_convert = CopyShadowRGBToRGBA; |
623 if (redmask == 255<<16) { | 641 } |
624 osmesa_format = OSMESA_ARGB; | 642 } else { |
625 } else if (redmask == 255<<8) { | 643 gl_pixelsize = 4; |
626 osmesa_format = OSMESA_BGRA; | 644 gl_upsidedown = SDL_TRUE; |
627 } else if (redmask == 255<<24) { | 645 gl_copyshadow = CopyShadowDirect; |
628 osmesa_format = OSMESA_RGBA; | 646 if (redmask == 255 << 16) { |
629 } else { | 647 osmesa_format = OSMESA_ARGB; |
630 /* ABGR format unsupported */ | 648 } else if (redmask == 255 << 8) { |
631 osmesa_format = OSMESA_BGRA; | 649 osmesa_format = OSMESA_BGRA; |
632 gl_convert = ConvertBGRAToABGR; | 650 } else if (redmask == 255 << 24) { |
633 } | 651 osmesa_format = OSMESA_RGBA; |
634 } | 652 } else { |
635 break; | 653 /* ABGR format unsupported */ |
636 default: | 654 osmesa_format = OSMESA_BGRA; |
637 if (tinygl_present) { | 655 gl_convert = ConvertBGRAToABGR; |
638 SDL_AtariGL_Quit(this, SDL_FALSE); | 656 } |
639 return 0; | 657 } |
640 } | 658 break; |
641 gl_pixelsize = 1; | 659 default: |
642 gl_copyshadow = CopyShadowDirect; | 660 if (tinygl_present) { |
643 osmesa_format = OSMESA_COLOR_INDEX; | 661 SDL_AtariGL_Quit (this, SDL_FALSE); |
644 break; | 662 return 0; |
645 } | 663 } |
646 | 664 gl_pixelsize = 1; |
647 /* Try to keep current context if possible */ | 665 gl_copyshadow = CopyShadowDirect; |
648 recreatecontext=1; | 666 osmesa_format = OSMESA_COLOR_INDEX; |
649 if (gl_shadow && | 667 break; |
650 (gl_curformat == osmesa_format) && | 668 } |
651 (gl_curwidth == current->w) && | 669 |
652 (gl_curheight == current->h)) { | 670 /* Try to keep current context if possible */ |
653 recreatecontext = 0; | 671 recreatecontext = 1; |
654 } | 672 if (gl_shadow && |
655 if (recreatecontext) { | 673 (gl_curformat == osmesa_format) && |
656 SDL_AtariGL_Quit(this, SDL_FALSE); | 674 (gl_curwidth == current->w) && (gl_curheight == current->h)) { |
657 | 675 recreatecontext = 0; |
658 gl_shadow = this->gl_data->OSMesaCreateLDG( | 676 } |
659 osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h | 677 if (recreatecontext) { |
660 ); | 678 SDL_AtariGL_Quit (this, SDL_FALSE); |
661 | 679 |
662 if (gl_shadow) { | 680 gl_shadow = |
663 gl_curformat = osmesa_format; | 681 this->gl_data->OSMesaCreateLDG (osmesa_format, GL_UNSIGNED_BYTE, |
664 gl_curwidth = current->w; | 682 current->w, current->h); |
665 gl_curheight = current->h; | 683 |
666 } else { | 684 if (gl_shadow) { |
667 gl_curformat = 0; | 685 gl_curformat = osmesa_format; |
668 gl_curwidth = 0; | 686 gl_curwidth = current->w; |
669 gl_curheight = 0; | 687 gl_curheight = current->h; |
670 } | 688 } else { |
671 } | 689 gl_curformat = 0; |
672 | 690 gl_curwidth = 0; |
673 return (gl_shadow != NULL); | 691 gl_curheight = 0; |
692 } | |
693 } | |
694 | |
695 return (gl_shadow != NULL); | |
674 } | 696 } |
675 | 697 |
676 /*--- Conversions routines from shadow buffer to the screen ---*/ | 698 /*--- Conversions routines from shadow buffer to the screen ---*/ |
677 | 699 |
678 static void CopyShadowNull(_THIS, SDL_Surface *surface) | 700 static void |
679 { | 701 CopyShadowNull (_THIS, SDL_Surface * surface) |
680 } | 702 { |
681 | 703 } |
682 static void CopyShadowDirect(_THIS, SDL_Surface *surface) | 704 |
683 { | 705 static void |
684 int y, srcpitch, dstpitch; | 706 CopyShadowDirect (_THIS, SDL_Surface * surface) |
685 Uint8 *srcline, *dstline; | 707 { |
686 | 708 int y, srcpitch, dstpitch; |
687 srcline = gl_shadow; | 709 Uint8 *srcline, *dstline; |
688 srcpitch = surface->w * gl_pixelsize; | 710 |
689 dstline = surface->pixels; | 711 srcline = gl_shadow; |
690 dstpitch = surface->pitch; | 712 srcpitch = surface->w * gl_pixelsize; |
691 if (gl_upsidedown) { | 713 dstline = surface->pixels; |
692 srcline += (surface->h-1)*srcpitch; | 714 dstpitch = surface->pitch; |
693 srcpitch = -srcpitch; | 715 if (gl_upsidedown) { |
694 } | 716 srcline += (surface->h - 1) * srcpitch; |
695 | 717 srcpitch = -srcpitch; |
696 for (y=0; y<surface->h; y++) { | 718 } |
697 SDL_memcpy(dstline, srcline, srcpitch); | 719 |
698 | 720 for (y = 0; y < surface->h; y++) { |
699 srcline += srcpitch; | 721 SDL_memcpy (dstline, srcline, srcpitch); |
700 dstline += dstpitch; | 722 |
701 } | 723 srcline += srcpitch; |
702 } | 724 dstline += dstpitch; |
703 | 725 } |
704 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface) | 726 } |
705 { | 727 |
706 int x,y, srcpitch, dstpitch; | 728 static void |
707 Uint16 *dstline, *dstcol; | 729 CopyShadowRGBTo555 (_THIS, SDL_Surface * surface) |
708 Uint8 *srcline, *srccol; | 730 { |
709 | 731 int x, y, srcpitch, dstpitch; |
710 srcline = (Uint8 *)gl_shadow; | 732 Uint16 *dstline, *dstcol; |
711 srcpitch = surface->w * gl_pixelsize; | 733 Uint8 *srcline, *srccol; |
712 dstline = surface->pixels; | 734 |
713 dstpitch = surface->pitch >>1; | 735 srcline = (Uint8 *) gl_shadow; |
714 if (gl_upsidedown) { | 736 srcpitch = surface->w * gl_pixelsize; |
715 srcline += (surface->h-1)*srcpitch; | 737 dstline = surface->pixels; |
716 srcpitch = -srcpitch; | 738 dstpitch = surface->pitch >> 1; |
717 } | 739 if (gl_upsidedown) { |
718 | 740 srcline += (surface->h - 1) * srcpitch; |
719 for (y=0; y<surface->h; y++) { | 741 srcpitch = -srcpitch; |
720 srccol = srcline; | 742 } |
721 dstcol = dstline; | 743 |
722 for (x=0; x<surface->w; x++) { | 744 for (y = 0; y < surface->h; y++) { |
723 Uint16 dstcolor; | 745 srccol = srcline; |
724 | 746 dstcol = dstline; |
725 dstcolor = ((*srccol++)<<7) & (31<<10); | 747 for (x = 0; x < surface->w; x++) { |
726 dstcolor |= ((*srccol++)<<2) & (31<<5); | 748 Uint16 dstcolor; |
727 dstcolor |= ((*srccol++)>>3) & 31; | 749 |
728 *dstcol++ = dstcolor; | 750 dstcolor = ((*srccol++) << 7) & (31 << 10); |
729 } | 751 dstcolor |= ((*srccol++) << 2) & (31 << 5); |
730 | 752 dstcolor |= ((*srccol++) >> 3) & 31; |
731 srcline += srcpitch; | 753 *dstcol++ = dstcolor; |
732 dstline += dstpitch; | 754 } |
733 } | 755 |
734 } | 756 srcline += srcpitch; |
735 | 757 dstline += dstpitch; |
736 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface) | 758 } |
737 { | 759 } |
738 int x,y, srcpitch, dstpitch; | 760 |
739 Uint16 *dstline, *dstcol; | 761 static void |
740 Uint8 *srcline, *srccol; | 762 CopyShadowRGBTo565 (_THIS, SDL_Surface * surface) |
741 | 763 { |
742 srcline = (Uint8 *)gl_shadow; | 764 int x, y, srcpitch, dstpitch; |
743 srcpitch = surface->w * gl_pixelsize; | 765 Uint16 *dstline, *dstcol; |
744 dstline = surface->pixels; | 766 Uint8 *srcline, *srccol; |
745 dstpitch = surface->pitch >>1; | 767 |
746 if (gl_upsidedown) { | 768 srcline = (Uint8 *) gl_shadow; |
747 srcline += (surface->h-1)*srcpitch; | 769 srcpitch = surface->w * gl_pixelsize; |
748 srcpitch = -srcpitch; | 770 dstline = surface->pixels; |
749 } | 771 dstpitch = surface->pitch >> 1; |
750 | 772 if (gl_upsidedown) { |
751 for (y=0; y<surface->h; y++) { | 773 srcline += (surface->h - 1) * srcpitch; |
752 srccol = srcline; | 774 srcpitch = -srcpitch; |
753 dstcol = dstline; | 775 } |
754 | 776 |
755 for (x=0; x<surface->w; x++) { | 777 for (y = 0; y < surface->h; y++) { |
756 Uint16 dstcolor; | 778 srccol = srcline; |
757 | 779 dstcol = dstline; |
758 dstcolor = ((*srccol++)<<8) & (31<<11); | 780 |
759 dstcolor |= ((*srccol++)<<3) & (63<<5); | 781 for (x = 0; x < surface->w; x++) { |
760 dstcolor |= ((*srccol++)>>3) & 31; | 782 Uint16 dstcolor; |
761 *dstcol++ = dstcolor; | 783 |
762 } | 784 dstcolor = ((*srccol++) << 8) & (31 << 11); |
763 | 785 dstcolor |= ((*srccol++) << 3) & (63 << 5); |
764 srcline += srcpitch; | 786 dstcolor |= ((*srccol++) >> 3) & 31; |
765 dstline += dstpitch; | 787 *dstcol++ = dstcolor; |
766 } | 788 } |
767 } | 789 |
768 | 790 srcline += srcpitch; |
769 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface) | 791 dstline += dstpitch; |
770 { | 792 } |
771 int x,y, srcpitch, dstpitch; | 793 } |
772 Uint8 *dstline, *dstcol; | 794 |
773 Uint8 *srcline, *srccol; | 795 static void |
774 | 796 CopyShadowRGBSwap (_THIS, SDL_Surface * surface) |
775 srcline = (Uint8 *)gl_shadow; | 797 { |
776 srcpitch = surface->w * gl_pixelsize; | 798 int x, y, srcpitch, dstpitch; |
777 dstline = surface->pixels; | 799 Uint8 *dstline, *dstcol; |
778 dstpitch = surface->pitch; | 800 Uint8 *srcline, *srccol; |
779 if (gl_upsidedown) { | 801 |
780 srcline += (surface->h-1)*srcpitch; | 802 srcline = (Uint8 *) gl_shadow; |
781 srcpitch = -srcpitch; | 803 srcpitch = surface->w * gl_pixelsize; |
782 } | 804 dstline = surface->pixels; |
783 | 805 dstpitch = surface->pitch; |
784 for (y=0; y<surface->h; y++) { | 806 if (gl_upsidedown) { |
785 srccol = srcline; | 807 srcline += (surface->h - 1) * srcpitch; |
786 dstcol = dstline; | 808 srcpitch = -srcpitch; |
787 | 809 } |
788 for (x=0; x<surface->w; x++) { | 810 |
789 *dstcol++ = srccol[2]; | 811 for (y = 0; y < surface->h; y++) { |
790 *dstcol++ = srccol[1]; | 812 srccol = srcline; |
791 *dstcol++ = srccol[0]; | 813 dstcol = dstline; |
792 srccol += 3; | 814 |
793 } | 815 for (x = 0; x < surface->w; x++) { |
794 | 816 *dstcol++ = srccol[2]; |
795 srcline += srcpitch; | 817 *dstcol++ = srccol[1]; |
796 dstline += dstpitch; | 818 *dstcol++ = srccol[0]; |
797 } | 819 srccol += 3; |
798 } | 820 } |
799 | 821 |
800 static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface) | 822 srcline += srcpitch; |
801 { | 823 dstline += dstpitch; |
802 int x,y, srcpitch, dstpitch; | 824 } |
803 Uint32 *dstline, *dstcol; | 825 } |
804 Uint8 *srcline, *srccol; | 826 |
805 | 827 static void |
806 srcline = (Uint8 *)gl_shadow; | 828 CopyShadowRGBToARGB (_THIS, SDL_Surface * surface) |
807 srcpitch = surface->w * gl_pixelsize; | 829 { |
808 dstline = surface->pixels; | 830 int x, y, srcpitch, dstpitch; |
809 dstpitch = surface->pitch >>2; | 831 Uint32 *dstline, *dstcol; |
810 if (gl_upsidedown) { | 832 Uint8 *srcline, *srccol; |
811 srcline += (surface->h-1)*srcpitch; | 833 |
812 srcpitch = -srcpitch; | 834 srcline = (Uint8 *) gl_shadow; |
813 } | 835 srcpitch = surface->w * gl_pixelsize; |
814 | 836 dstline = surface->pixels; |
815 for (y=0; y<surface->h; y++) { | 837 dstpitch = surface->pitch >> 2; |
816 srccol = srcline; | 838 if (gl_upsidedown) { |
817 dstcol = dstline; | 839 srcline += (surface->h - 1) * srcpitch; |
818 | 840 srcpitch = -srcpitch; |
819 for (x=0; x<surface->w; x++) { | 841 } |
820 Uint32 dstcolor; | 842 |
821 | 843 for (y = 0; y < surface->h; y++) { |
822 dstcolor = (*srccol++)<<16; | 844 srccol = srcline; |
823 dstcolor |= (*srccol++)<<8; | 845 dstcol = dstline; |
824 dstcolor |= *srccol++; | 846 |
825 | 847 for (x = 0; x < surface->w; x++) { |
826 *dstcol++ = dstcolor; | 848 Uint32 dstcolor; |
827 } | 849 |
828 | 850 dstcolor = (*srccol++) << 16; |
829 srcline += srcpitch; | 851 dstcolor |= (*srccol++) << 8; |
830 dstline += dstpitch; | 852 dstcolor |= *srccol++; |
831 } | 853 |
832 } | 854 *dstcol++ = dstcolor; |
833 | 855 } |
834 static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface) | 856 |
835 { | 857 srcline += srcpitch; |
836 int x,y, srcpitch, dstpitch; | 858 dstline += dstpitch; |
837 Uint32 *dstline, *dstcol; | 859 } |
838 Uint8 *srcline, *srccol; | 860 } |
839 | 861 |
840 srcline = (Uint8 *)gl_shadow; | 862 static void |
841 srcpitch = surface->w * gl_pixelsize; | 863 CopyShadowRGBToABGR (_THIS, SDL_Surface * surface) |
842 dstline = surface->pixels; | 864 { |
843 dstpitch = surface->pitch >>2; | 865 int x, y, srcpitch, dstpitch; |
844 if (gl_upsidedown) { | 866 Uint32 *dstline, *dstcol; |
845 srcline += (surface->h-1)*srcpitch; | 867 Uint8 *srcline, *srccol; |
846 srcpitch = -srcpitch; | 868 |
847 } | 869 srcline = (Uint8 *) gl_shadow; |
848 | 870 srcpitch = surface->w * gl_pixelsize; |
849 for (y=0; y<surface->h; y++) { | 871 dstline = surface->pixels; |
850 srccol = srcline; | 872 dstpitch = surface->pitch >> 2; |
851 dstcol = dstline; | 873 if (gl_upsidedown) { |
852 | 874 srcline += (surface->h - 1) * srcpitch; |
853 for (x=0; x<surface->w; x++) { | 875 srcpitch = -srcpitch; |
854 Uint32 dstcolor; | 876 } |
855 | 877 |
856 dstcolor = *srccol++; | 878 for (y = 0; y < surface->h; y++) { |
857 dstcolor |= (*srccol++)<<8; | 879 srccol = srcline; |
858 dstcolor |= (*srccol++)<<16; | 880 dstcol = dstline; |
859 | 881 |
860 *dstcol++ = dstcolor; | 882 for (x = 0; x < surface->w; x++) { |
861 } | 883 Uint32 dstcolor; |
862 | 884 |
863 srcline += srcpitch; | 885 dstcolor = *srccol++; |
864 dstline += dstpitch; | 886 dstcolor |= (*srccol++) << 8; |
865 } | 887 dstcolor |= (*srccol++) << 16; |
866 } | 888 |
867 | 889 *dstcol++ = dstcolor; |
868 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface) | 890 } |
869 { | 891 |
870 int x,y, srcpitch, dstpitch; | 892 srcline += srcpitch; |
871 Uint32 *dstline, *dstcol; | 893 dstline += dstpitch; |
872 Uint8 *srcline, *srccol; | 894 } |
873 | 895 } |
874 srcline = (Uint8 *)gl_shadow; | 896 |
875 srcpitch = surface->w * gl_pixelsize; | 897 static void |
876 dstline = surface->pixels; | 898 CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface) |
877 dstpitch = surface->pitch >>2; | 899 { |
878 if (gl_upsidedown) { | 900 int x, y, srcpitch, dstpitch; |
879 srcline += (surface->h-1)*srcpitch; | 901 Uint32 *dstline, *dstcol; |
880 srcpitch = -srcpitch; | 902 Uint8 *srcline, *srccol; |
881 } | 903 |
882 | 904 srcline = (Uint8 *) gl_shadow; |
883 for (y=0; y<surface->h; y++) { | 905 srcpitch = surface->w * gl_pixelsize; |
884 srccol = srcline; | 906 dstline = surface->pixels; |
885 dstcol = dstline; | 907 dstpitch = surface->pitch >> 2; |
886 | 908 if (gl_upsidedown) { |
887 for (x=0; x<surface->w; x++) { | 909 srcline += (surface->h - 1) * srcpitch; |
888 Uint32 dstcolor; | 910 srcpitch = -srcpitch; |
889 | 911 } |
890 dstcolor = (*srccol++)<<8; | 912 |
891 dstcolor |= (*srccol++)<<16; | 913 for (y = 0; y < surface->h; y++) { |
892 dstcolor |= (*srccol++)<<24; | 914 srccol = srcline; |
893 | 915 dstcol = dstline; |
894 *dstcol++ = dstcolor; | 916 |
895 } | 917 for (x = 0; x < surface->w; x++) { |
896 | 918 Uint32 dstcolor; |
897 srcline += srcpitch; | 919 |
898 dstline += dstpitch; | 920 dstcolor = (*srccol++) << 8; |
899 } | 921 dstcolor |= (*srccol++) << 16; |
900 } | 922 dstcolor |= (*srccol++) << 24; |
901 | 923 |
902 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface) | 924 *dstcol++ = dstcolor; |
903 { | 925 } |
904 int x,y, srcpitch, dstpitch; | 926 |
905 Uint32 *dstline, *dstcol; | 927 srcline += srcpitch; |
906 Uint8 *srcline, *srccol; | 928 dstline += dstpitch; |
907 | 929 } |
908 srcline = (Uint8 *)gl_shadow; | 930 } |
909 srcpitch = surface->w * gl_pixelsize; | 931 |
910 dstline = surface->pixels; | 932 static void |
911 dstpitch = surface->pitch >>2; | 933 CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface) |
912 if (gl_upsidedown) { | 934 { |
913 srcline += (surface->h-1)*srcpitch; | 935 int x, y, srcpitch, dstpitch; |
914 srcpitch = -srcpitch; | 936 Uint32 *dstline, *dstcol; |
915 } | 937 Uint8 *srcline, *srccol; |
916 | 938 |
917 for (y=0; y<surface->h; y++) { | 939 srcline = (Uint8 *) gl_shadow; |
918 srccol = srcline; | 940 srcpitch = surface->w * gl_pixelsize; |
919 dstcol = dstline; | 941 dstline = surface->pixels; |
920 | 942 dstpitch = surface->pitch >> 2; |
921 for (x=0; x<surface->w; x++) { | 943 if (gl_upsidedown) { |
922 Uint32 dstcolor; | 944 srcline += (surface->h - 1) * srcpitch; |
923 | 945 srcpitch = -srcpitch; |
924 dstcolor = (*srccol++)<<24; | 946 } |
925 dstcolor |= (*srccol++)<<16; | 947 |
926 dstcolor |= (*srccol++)<<8; | 948 for (y = 0; y < surface->h; y++) { |
927 | 949 srccol = srcline; |
928 *dstcol++ = dstcolor; | 950 dstcol = dstline; |
929 } | 951 |
930 | 952 for (x = 0; x < surface->w; x++) { |
931 srcline += srcpitch; | 953 Uint32 dstcolor; |
932 dstline += dstpitch; | 954 |
933 } | 955 dstcolor = (*srccol++) << 24; |
934 } | 956 dstcolor |= (*srccol++) << 16; |
935 | 957 dstcolor |= (*srccol++) << 8; |
936 static void CopyShadow8888To555(_THIS, SDL_Surface *surface) | 958 |
937 { | 959 *dstcol++ = dstcolor; |
938 int x,y, srcpitch, dstpitch; | 960 } |
939 Uint16 *dstline, *dstcol; | 961 |
940 Uint32 *srcline, *srccol; | 962 srcline += srcpitch; |
941 | 963 dstline += dstpitch; |
942 srcline = (Uint32 *)gl_shadow; | 964 } |
943 srcpitch = (surface->w * gl_pixelsize) >>2; | 965 } |
944 dstline = surface->pixels; | 966 |
945 dstpitch = surface->pitch >>1; | 967 static void |
946 if (gl_upsidedown) { | 968 CopyShadow8888To555 (_THIS, SDL_Surface * surface) |
947 srcline += (surface->h-1)*srcpitch; | 969 { |
948 srcpitch = -srcpitch; | 970 int x, y, srcpitch, dstpitch; |
949 } | 971 Uint16 *dstline, *dstcol; |
950 | 972 Uint32 *srcline, *srccol; |
951 for (y=0; y<surface->h; y++) { | 973 |
952 srccol = srcline; | 974 srcline = (Uint32 *) gl_shadow; |
953 dstcol = dstline; | 975 srcpitch = (surface->w * gl_pixelsize) >> 2; |
954 for (x=0; x<surface->w; x++) { | 976 dstline = surface->pixels; |
955 Uint32 srccolor; | 977 dstpitch = surface->pitch >> 1; |
956 Uint16 dstcolor; | 978 if (gl_upsidedown) { |
957 | 979 srcline += (surface->h - 1) * srcpitch; |
958 srccolor = *srccol++; | 980 srcpitch = -srcpitch; |
959 dstcolor = (srccolor>>9) & (31<<10); | 981 } |
960 dstcolor |= (srccolor>>6) & (31<<5); | 982 |
961 dstcolor |= (srccolor>>3) & 31; | 983 for (y = 0; y < surface->h; y++) { |
962 *dstcol++ = dstcolor; | 984 srccol = srcline; |
963 } | 985 dstcol = dstline; |
964 | 986 for (x = 0; x < surface->w; x++) { |
965 srcline += srcpitch; | 987 Uint32 srccolor; |
966 dstline += dstpitch; | 988 Uint16 dstcolor; |
967 } | 989 |
968 } | 990 srccolor = *srccol++; |
969 | 991 dstcolor = (srccolor >> 9) & (31 << 10); |
970 static void CopyShadow8888To565(_THIS, SDL_Surface *surface) | 992 dstcolor |= (srccolor >> 6) & (31 << 5); |
971 { | 993 dstcolor |= (srccolor >> 3) & 31; |
972 int x,y, srcpitch, dstpitch; | 994 *dstcol++ = dstcolor; |
973 Uint16 *dstline, *dstcol; | 995 } |
974 Uint32 *srcline, *srccol; | 996 |
975 | 997 srcline += srcpitch; |
976 srcline = (Uint32 *)gl_shadow; | 998 dstline += dstpitch; |
977 srcpitch = (surface->w * gl_pixelsize) >> 2; | 999 } |
978 dstline = surface->pixels; | 1000 } |
979 dstpitch = surface->pitch >>1; | 1001 |
980 if (gl_upsidedown) { | 1002 static void |
981 srcline += (surface->h-1)*srcpitch; | 1003 CopyShadow8888To565 (_THIS, SDL_Surface * surface) |
982 srcpitch = -srcpitch; | 1004 { |
983 } | 1005 int x, y, srcpitch, dstpitch; |
984 | 1006 Uint16 *dstline, *dstcol; |
985 for (y=0; y<surface->h; y++) { | 1007 Uint32 *srcline, *srccol; |
986 srccol = srcline; | 1008 |
987 dstcol = dstline; | 1009 srcline = (Uint32 *) gl_shadow; |
988 | 1010 srcpitch = (surface->w * gl_pixelsize) >> 2; |
989 for (x=0; x<surface->w; x++) { | 1011 dstline = surface->pixels; |
990 Uint32 srccolor; | 1012 dstpitch = surface->pitch >> 1; |
991 Uint16 dstcolor; | 1013 if (gl_upsidedown) { |
992 | 1014 srcline += (surface->h - 1) * srcpitch; |
993 srccolor = *srccol++; | 1015 srcpitch = -srcpitch; |
994 dstcolor = (srccolor>>8) & (31<<11); | 1016 } |
995 dstcolor |= (srccolor>>5) & (63<<5); | 1017 |
996 dstcolor |= (srccolor>>3) & 31; | 1018 for (y = 0; y < surface->h; y++) { |
997 *dstcol++ = dstcolor; | 1019 srccol = srcline; |
998 } | 1020 dstcol = dstline; |
999 | 1021 |
1000 srcline += srcpitch; | 1022 for (x = 0; x < surface->w; x++) { |
1001 dstline += dstpitch; | 1023 Uint32 srccolor; |
1002 } | 1024 Uint16 dstcolor; |
1025 | |
1026 srccolor = *srccol++; | |
1027 dstcolor = (srccolor >> 8) & (31 << 11); | |
1028 dstcolor |= (srccolor >> 5) & (63 << 5); | |
1029 dstcolor |= (srccolor >> 3) & 31; | |
1030 *dstcol++ = dstcolor; | |
1031 } | |
1032 | |
1033 srcline += srcpitch; | |
1034 dstline += dstpitch; | |
1035 } | |
1003 } | 1036 } |
1004 | 1037 |
1005 /*--- Conversions routines in the screen ---*/ | 1038 /*--- Conversions routines in the screen ---*/ |
1006 | 1039 |
1007 static void ConvertNull(_THIS, SDL_Surface *surface) | 1040 static void |
1008 { | 1041 ConvertNull (_THIS, SDL_Surface * surface) |
1009 } | 1042 { |
1010 | 1043 } |
1011 static void Convert565To555be(_THIS, SDL_Surface *surface) | 1044 |
1012 { | 1045 static void |
1013 int x,y, pitch; | 1046 Convert565To555be (_THIS, SDL_Surface * surface) |
1014 unsigned short *line, *pixel; | 1047 { |
1015 | 1048 int x, y, pitch; |
1016 line = surface->pixels; | 1049 unsigned short *line, *pixel; |
1017 pitch = surface->pitch >> 1; | 1050 |
1018 for (y=0; y<surface->h; y++) { | 1051 line = surface->pixels; |
1019 pixel = line; | 1052 pitch = surface->pitch >> 1; |
1020 for (x=0; x<surface->w; x++) { | 1053 for (y = 0; y < surface->h; y++) { |
1021 unsigned short color = *pixel; | 1054 pixel = line; |
1022 | 1055 for (x = 0; x < surface->w; x++) { |
1023 *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0); | 1056 unsigned short color = *pixel; |
1024 } | 1057 |
1025 | 1058 *pixel++ = (color & 0x1f) | ((color >> 1) & 0xffe0); |
1026 line += pitch; | 1059 } |
1027 } | 1060 |
1028 } | 1061 line += pitch; |
1029 | 1062 } |
1030 static void Convert565To555le(_THIS, SDL_Surface *surface) | 1063 } |
1031 { | 1064 |
1032 int x,y, pitch; | 1065 static void |
1033 unsigned short *line, *pixel; | 1066 Convert565To555le (_THIS, SDL_Surface * surface) |
1034 | 1067 { |
1035 line = surface->pixels; | 1068 int x, y, pitch; |
1036 pitch = surface->pitch >>1; | 1069 unsigned short *line, *pixel; |
1037 for (y=0; y<surface->h; y++) { | 1070 |
1038 pixel = line; | 1071 line = surface->pixels; |
1039 for (x=0; x<surface->w; x++) { | 1072 pitch = surface->pitch >> 1; |
1040 unsigned short color = *pixel; | 1073 for (y = 0; y < surface->h; y++) { |
1041 | 1074 pixel = line; |
1042 color = (color & 0x1f)|((color>>1) & 0xffe0); | 1075 for (x = 0; x < surface->w; x++) { |
1043 *pixel++ = SDL_Swap16(color); | 1076 unsigned short color = *pixel; |
1044 } | 1077 |
1045 | 1078 color = (color & 0x1f) | ((color >> 1) & 0xffe0); |
1046 line += pitch; | 1079 *pixel++ = SDL_Swap16 (color); |
1047 } | 1080 } |
1048 } | 1081 |
1049 | 1082 line += pitch; |
1050 static void Convert565le(_THIS, SDL_Surface *surface) | 1083 } |
1051 { | 1084 } |
1052 int x,y, pitch; | 1085 |
1053 unsigned short *line, *pixel; | 1086 static void |
1054 | 1087 Convert565le (_THIS, SDL_Surface * surface) |
1055 line = surface->pixels; | 1088 { |
1056 pitch = surface->pitch >>1; | 1089 int x, y, pitch; |
1057 for (y=0; y<surface->h; y++) { | 1090 unsigned short *line, *pixel; |
1058 pixel = line; | 1091 |
1059 for (x=0; x<surface->w; x++) { | 1092 line = surface->pixels; |
1060 unsigned short color = *pixel; | 1093 pitch = surface->pitch >> 1; |
1061 | 1094 for (y = 0; y < surface->h; y++) { |
1062 *pixel++ = SDL_Swap16(color); | 1095 pixel = line; |
1063 } | 1096 for (x = 0; x < surface->w; x++) { |
1064 | 1097 unsigned short color = *pixel; |
1065 line += pitch; | 1098 |
1066 } | 1099 *pixel++ = SDL_Swap16 (color); |
1067 } | 1100 } |
1068 | 1101 |
1069 static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface) | 1102 line += pitch; |
1070 { | 1103 } |
1071 int x,y, pitch; | 1104 } |
1072 unsigned long *line, *pixel; | 1105 |
1073 | 1106 static void |
1074 line = surface->pixels; | 1107 ConvertBGRAToABGR (_THIS, SDL_Surface * surface) |
1075 pitch = surface->pitch >>2; | 1108 { |
1076 for (y=0; y<surface->h; y++) { | 1109 int x, y, pitch; |
1077 pixel = line; | 1110 unsigned long *line, *pixel; |
1078 for (x=0; x<surface->w; x++) { | 1111 |
1079 unsigned long color = *pixel; | 1112 line = surface->pixels; |
1080 | 1113 pitch = surface->pitch >> 2; |
1081 *pixel++ = (color<<24)|(color>>8); | 1114 for (y = 0; y < surface->h; y++) { |
1082 } | 1115 pixel = line; |
1083 | 1116 for (x = 0; x < surface->w; x++) { |
1084 line += pitch; | 1117 unsigned long color = *pixel; |
1085 } | 1118 |
1119 *pixel++ = (color << 24) | (color >> 8); | |
1120 } | |
1121 | |
1122 line += pitch; | |
1123 } | |
1086 } | 1124 } |
1087 | 1125 |
1088 #endif /* SDL_VIDEO_OPENGL */ | 1126 #endif /* SDL_VIDEO_OPENGL */ |
1127 /* vi: set ts=4 sw=4 expandtab: */ |