comparison src/video/win32/SDL_win32video.c @ 1724:6c63fc2bd986 SDL-1.3

Proof of concept done - Win32 GDI implementation mostly complete.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 06 Jul 2006 07:17:11 +0000
parents a1ebb17f9c52
children 98a3207ddde8
comparison
equal deleted inserted replaced
1723:4bdbb9b2bd0a 1724:6c63fc2bd986
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_win32events.h" 31 #include "SDL_dibrender.h"
32 #include "SDL_win32window.h"
33 32
34 /* Initialization/Query functions */ 33 /* Initialization/Query functions */
35 static int WIN_VideoInit(_THIS); 34 static int WIN_VideoInit(_THIS);
36 static int WIN_SetDisplayMode(_THIS, const SDL_DisplayMode * mode); 35 static int WIN_SetDisplayMode(_THIS, const SDL_DisplayMode * mode);
37 static void WIN_VideoQuit(_THIS); 36 static void WIN_VideoQuit(_THIS);
107 106
108 107
109 int 108 int
110 WIN_VideoInit(_THIS) 109 WIN_VideoInit(_THIS)
111 { 110 {
111 int bmi_size;
112 LPBITMAPINFO bmi;
112 SDL_DisplayMode mode; 113 SDL_DisplayMode mode;
113 114
114 SDL_AddBasicVideoDisplay(NULL); 115 /* Find out the desktop mode */
115 //SDL_AddRenderDriver(0, &SDL_WIN_RenderDriver); 116 mode.format = SDL_PixelFormat_Unknown;
117 mode.w = GetSystemMetrics(SM_CXSCREEN);
118 mode.h = GetSystemMetrics(SM_CYSCREEN);
119 mode.refresh_rate = 0;
120
121 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
122 bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
123 if (bmi) {
124 HDC hdc;
125 HBITMAP hbm;
126
127 SDL_memset(bmi, 0, bmi_size);
128 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
129 hdc = GetDC(NULL);
130 hbm = CreateCompatibleBitmap(hdc, 1, 1);
131 GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
132 GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
133 DeleteObject(hbm);
134 ReleaseDC(NULL, hdc);
135 if (bmi->bmiHeader.biCompression == BI_BITFIELDS) {
136 switch (*(Uint32 *) bmi->bmiColors) {
137 case 0x00FF0000:
138 mode.format = SDL_PixelFormat_RGB888;
139 break;
140 case 0x000000FF:
141 mode.format = SDL_PixelFormat_BGR888;
142 break;
143 case 0xF800:
144 mode.format = SDL_PixelFormat_RGB565;
145 break;
146 case 0x7C00:
147 mode.format = SDL_PixelFormat_RGB555;
148 break;
149 }
150 } else if (bmi->bmiHeader.biBitCount == 8) {
151 mode.format = SDL_PixelFormat_Index8;
152 }
153 }
154 SDL_AddBasicVideoDisplay(&mode);
155 SDL_AddRenderDriver(0, &SDL_DIB_RenderDriver);
116 156
117 SDL_zero(mode); 157 SDL_zero(mode);
118 SDL_AddDisplayMode(0, &mode); 158 SDL_AddDisplayMode(0, &mode);
119 159
120 WIN_AddKeyboard(_this); 160 WIN_AddKeyboard(_this);
132 } 172 }
133 173
134 void 174 void
135 WIN_VideoQuit(_THIS) 175 WIN_VideoQuit(_THIS)
136 { 176 {
177 WIN_DelKeyboard(_this);
178 WIN_DelMouse(_this);
137 } 179 }
138 180
139 /* vim: set ts=4 sw=4 expandtab: */ 181 /* vim: set ts=4 sw=4 expandtab: */