Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_win32video.c @ 1730:e70477157db9 SDL-1.3
Starting support for Direct3D render driver.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 08 Jul 2006 18:06:02 +0000 |
parents | 98a3207ddde8 |
children | 0b1070f2f94d |
comparison
equal
deleted
inserted
replaced
1729:0ef52d56e8bb | 1730:e70477157db9 |
---|---|
26 #include "SDL_mouse.h" | 26 #include "SDL_mouse.h" |
27 #include "../SDL_sysvideo.h" | 27 #include "../SDL_sysvideo.h" |
28 #include "../SDL_pixels_c.h" | 28 #include "../SDL_pixels_c.h" |
29 | 29 |
30 #include "SDL_win32video.h" | 30 #include "SDL_win32video.h" |
31 #include "SDL_dibrender.h" | 31 #include "SDL_d3drender.h" |
32 #include "SDL_gdirender.h" | |
32 | 33 |
33 /* Initialization/Query functions */ | 34 /* Initialization/Query functions */ |
34 static int WIN_VideoInit(_THIS); | 35 static int WIN_VideoInit(_THIS); |
35 static void WIN_VideoQuit(_THIS); | 36 static void WIN_VideoQuit(_THIS); |
36 | 37 |
43 } | 44 } |
44 | 45 |
45 static void | 46 static void |
46 WIN_DeleteDevice(SDL_VideoDevice * device) | 47 WIN_DeleteDevice(SDL_VideoDevice * device) |
47 { | 48 { |
49 SDL_VideoData *data = (SDL_VideoData *) device->driverdata; | |
50 | |
48 SDL_UnregisterApp(); | 51 SDL_UnregisterApp(); |
52 #if SDL_VIDEO_RENDER_D3D | |
53 if (data->d3d) { | |
54 IDirect3D9_Release(data->d3d); | |
55 FreeLibrary(data->d3dDLL); | |
56 } | |
57 #endif | |
49 SDL_free(device->driverdata); | 58 SDL_free(device->driverdata); |
50 SDL_free(device); | 59 SDL_free(device); |
51 } | 60 } |
52 | 61 |
53 static SDL_VideoDevice * | 62 static SDL_VideoDevice * |
54 WIN_CreateDevice(int devindex) | 63 WIN_CreateDevice(int devindex) |
55 { | 64 { |
56 SDL_VideoDevice *device; | 65 SDL_VideoDevice *device; |
66 SDL_VideoData *data; | |
57 | 67 |
58 SDL_RegisterApp(NULL, 0, NULL); | 68 SDL_RegisterApp(NULL, 0, NULL); |
59 | 69 |
60 /* Initialize all variables that we clean on shutdown */ | 70 /* Initialize all variables that we clean on shutdown */ |
61 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); | 71 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); |
62 if (device) { | 72 if (device) { |
63 device->driverdata = | 73 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); |
64 (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); | |
65 } | 74 } |
66 if (!device || !device->driverdata) { | 75 if (!device || !data) { |
67 SDL_OutOfMemory(); | 76 SDL_OutOfMemory(); |
68 if (device) { | 77 if (device) { |
69 SDL_free(device); | 78 SDL_free(device); |
70 } | 79 } |
71 return NULL; | 80 return NULL; |
72 } | 81 } |
82 device->driverdata = data; | |
83 | |
84 #if SDL_VIDEO_RENDER_D3D | |
85 data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL")); | |
86 if (data->d3dDLL) { | |
87 IDirect3D9 *WINAPI(*D3DCreate) (UINT SDKVersion); | |
88 | |
89 D3DCreate = | |
90 (IDirect3D9 * WINAPI(*)(UINT)) GetProcAddress(data->d3dDLL, | |
91 "Direct3DCreate9"); | |
92 if (D3DCreate) { | |
93 data->d3d = D3DCreate(D3D_SDK_VERSION); | |
94 } | |
95 if (!data->d3d) { | |
96 FreeLibrary(data->d3dDLL); | |
97 data->d3dDLL = NULL; | |
98 } | |
99 } | |
100 #endif /* SDL_VIDEO_RENDER_D3D */ | |
73 | 101 |
74 /* Set the function pointers */ | 102 /* Set the function pointers */ |
75 device->VideoInit = WIN_VideoInit; | 103 device->VideoInit = WIN_VideoInit; |
76 device->SetDisplayMode = WIN_SetDisplayMode; | 104 device->SetDisplayMode = WIN_SetDisplayMode; |
77 device->VideoQuit = WIN_VideoQuit; | 105 device->VideoQuit = WIN_VideoQuit; |
106 | 134 |
107 int | 135 int |
108 WIN_VideoInit(_THIS) | 136 WIN_VideoInit(_THIS) |
109 { | 137 { |
110 WIN_InitModes(_this); | 138 WIN_InitModes(_this); |
111 SDL_AddRenderDriver(0, &SDL_DIB_RenderDriver); | 139 |
140 #if SDL_VIDEO_RENDER_GDI | |
141 GDI_AddRenderDriver(_this); | |
142 #endif | |
143 #if SDL_VIDEO_RENDER_D3D | |
144 D3D_AddRenderDriver(_this); | |
145 #endif | |
112 | 146 |
113 WIN_InitKeyboard(_this); | 147 WIN_InitKeyboard(_this); |
114 WIN_InitMouse(_this); | 148 WIN_InitMouse(_this); |
115 | 149 |
116 return 0; | 150 return 0; |