Mercurial > sdl-ios-xcode
comparison src/video/windows/SDL_gapirender.c @ 5092:327f181542f1
Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 24 Jan 2011 21:20:30 -0800 |
parents | c2539ff054c8 |
children | da10636e5eca |
comparison
equal
deleted
inserted
replaced
5091:79bd1e289005 | 5092:327f181542f1 |
---|---|
76 typedef int (*PFNGXResume)(); | 76 typedef int (*PFNGXResume)(); |
77 | 77 |
78 typedef struct | 78 typedef struct |
79 { | 79 { |
80 // gx.dll | 80 // gx.dll |
81 HMODULE hGapiLib; | 81 void* hGapiLib; |
82 PFNGXOpenDisplay GXOpenDisplay; | 82 PFNGXOpenDisplay GXOpenDisplay; |
83 PFNGXCloseDisplay GXCloseDisplay; | 83 PFNGXCloseDisplay GXCloseDisplay; |
84 PFNGXBeginDraw GXBeginDraw; | 84 PFNGXBeginDraw GXBeginDraw; |
85 PFNGXEndDraw GXEndDraw; | 85 PFNGXEndDraw GXEndDraw; |
86 PFNGXGetDisplayProperties GXGetDisplayProperties; | 86 PFNGXGetDisplayProperties GXGetDisplayProperties; |
249 } | 249 } |
250 }; | 250 }; |
251 | 251 |
252 int WINCE_Available(void) | 252 int WINCE_Available(void) |
253 { | 253 { |
254 HMODULE render_gapi; | 254 void* render_gapi; |
255 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); | 255 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); |
256 | 256 |
257 // raw check | 257 // raw check |
258 RawFrameBufferInfo rfbi = { 0 }; | 258 RawFrameBufferInfo rfbi = { 0 }; |
259 HDC hdc = GetDC(NULL); | 259 HDC hdc = GetDC(NULL); |
265 render_raw = 1; | 265 render_raw = 1; |
266 | 266 |
267 if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw; | 267 if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw; |
268 | 268 |
269 // gapi check | 269 // gapi check |
270 render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll")); | 270 render_gapi = SDL_LoadObject("\\Windows\\gx.dll"); |
271 if(0 == render_gapi) | 271 if(0 == render_gapi) |
272 render_gapi = LoadLibrary(TEXT("gx.dll")); | 272 render_gapi = SDL_LoadObject("gx.dll"); |
273 FreeLibrary(render_gapi); | 273 SDL_UnloadObject(render_gapi); |
274 | 274 |
275 if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi; | 275 if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi; |
276 | 276 |
277 return 0 != render_raw || 0 != render_gapi; | 277 return 0 != render_raw || 0 != render_gapi; |
278 } | 278 } |
279 | 279 |
280 void WINCE_AddRenderDriver(_THIS) | 280 void WINCE_AddRenderDriver(_THIS) |
281 { | 281 { |
282 HDC hdc; | 282 HDC hdc; |
283 HMODULE render_gapi; | 283 void* render_gapi; |
284 int render_raw, ii; | 284 int render_raw, ii; |
285 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); | 285 const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); |
286 | 286 |
287 // raw check | 287 // raw check |
288 RawFrameBufferInfo rfbi = { 0 }; | 288 RawFrameBufferInfo rfbi = { 0 }; |
293 if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 && | 293 if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 && |
294 rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0) | 294 rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0) |
295 render_raw = 1; | 295 render_raw = 1; |
296 | 296 |
297 // gapi check | 297 // gapi check |
298 render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll")); | 298 render_gapi = SDL_LoadObject("\\Windows\\gx.dll"); |
299 if(0 == render_gapi) | 299 if(0 == render_gapi) |
300 render_gapi = LoadLibrary(TEXT("gx.dll")); | 300 render_gapi = SDL_LoadObject("gx.dll"); |
301 | 301 |
302 if(render_gapi) | 302 if(render_gapi) |
303 FreeLibrary(render_gapi); | 303 SDL_UnloadObject(render_gapi); |
304 | 304 |
305 for(ii = 0; ii < _this->num_displays; ++ii) | 305 for(ii = 0; ii < _this->num_displays; ++ii) |
306 { | 306 { |
307 if(preferably) | 307 if(preferably) |
308 { | 308 { |
883 { | 883 { |
884 SDL_OutOfMemory(); | 884 SDL_OutOfMemory(); |
885 return 0; | 885 return 0; |
886 } | 886 } |
887 | 887 |
888 data->gapi->hGapiLib = LoadLibrary(TEXT("\\Windows\\gx.dll")); | 888 data->gapi->hGapiLib = SDL_LoadObject("\\Windows\\gx.dll"); |
889 if(0 == data->gapi->hGapiLib) | 889 if(0 == data->gapi->hGapiLib) |
890 { | 890 { |
891 data->gapi->hGapiLib = LoadLibrary(TEXT("gx.dll")); | 891 data->gapi->hGapiLib = SDL_LoadObject("gx.dll"); |
892 if(0 == data->gapi->hGapiLib) return 0; | 892 if(0 == data->gapi->hGapiLib) return 0; |
893 } | 893 } |
894 | 894 |
895 // load gapi library | 895 // load gapi library |
896 #define LINK(type,name,import) name=(PFN##type)GetProcAddress(data->gapi->hGapiLib,TEXT(import)) | 896 #define LINK(type,name,import) name=(PFN##type)SDL_LoadFunction(data->gapi->hGapiLib,import) |
897 LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z"); | 897 LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z"); |
898 LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ"); | 898 LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ"); |
899 LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ"); | 899 LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ"); |
900 LINK(GXEndDraw, data->gapi->GXEndDraw, "?GXEndDraw@@YAHXZ"); | 900 LINK(GXEndDraw, data->gapi->GXEndDraw, "?GXEndDraw@@YAHXZ"); |
901 LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"); | 901 LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"); |
1003 void GAPI_Quit(WINCE_RenderData* data) | 1003 void GAPI_Quit(WINCE_RenderData* data) |
1004 { | 1004 { |
1005 if(data->gapi) | 1005 if(data->gapi) |
1006 { | 1006 { |
1007 if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); | 1007 if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); |
1008 if(data->gapi->hGapiLib) FreeLibrary(data->gapi->hGapiLib); | 1008 if(data->gapi->hGapiLib) SDL_UnloadObject(data->gapi->hGapiLib); |
1009 | 1009 |
1010 SDL_free(data->gapi); | 1010 SDL_free(data->gapi); |
1011 data->gapi = NULL; | 1011 data->gapi = NULL; |
1012 } | 1012 } |
1013 } | 1013 } |