5 #include "../fb_gfx_gl.h"
9 #ifndef WGL_ARB_pixel_format
10 #define WGL_ARB_pixel_format
12 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
13 #define WGL_DRAW_TO_WINDOW_ARB 0x2001
14 #define WGL_DRAW_TO_BITMAP_ARB 0x2002
15 #define WGL_ACCELERATION_ARB 0x2003
16 #define WGL_NEED_PALETTE_ARB 0x2004
17 #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
18 #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
19 #define WGL_SWAP_METHOD_ARB 0x2007
20 #define WGL_NUMBER_OVERLAYS_ARB 0x2008
21 #define WGL_NUMBER_UNDERLAYS_ARB 0x2009
22 #define WGL_TRANSPARENT_ARB 0x200A
23 #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
24 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
25 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
26 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
27 #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
28 #define WGL_SHARE_DEPTH_ARB 0x200C
29 #define WGL_SHARE_STENCIL_ARB 0x200D
30 #define WGL_SHARE_ACCUM_ARB 0x200E
31 #define WGL_SUPPORT_GDI_ARB 0x200F
32 #define WGL_SUPPORT_OPENGL_ARB 0x2010
33 #define WGL_DOUBLE_BUFFER_ARB 0x2011
34 #define WGL_STEREO_ARB 0x2012
35 #define WGL_PIXEL_TYPE_ARB 0x2013
36 #define WGL_COLOR_BITS_ARB 0x2014
37 #define WGL_RED_BITS_ARB 0x2015
38 #define WGL_RED_SHIFT_ARB 0x2016
39 #define WGL_GREEN_BITS_ARB 0x2017
40 #define WGL_GREEN_SHIFT_ARB 0x2018
41 #define WGL_BLUE_BITS_ARB 0x2019
42 #define WGL_BLUE_SHIFT_ARB 0x201A
43 #define WGL_ALPHA_BITS_ARB 0x201B
44 #define WGL_ALPHA_SHIFT_ARB 0x201C
45 #define WGL_ACCUM_BITS_ARB 0x201D
46 #define WGL_ACCUM_RED_BITS_ARB 0x201E
47 #define WGL_ACCUM_GREEN_BITS_ARB 0x201F
48 #define WGL_ACCUM_BLUE_BITS_ARB 0x2020
49 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
50 #define WGL_DEPTH_BITS_ARB 0x2022
51 #define WGL_STENCIL_BITS_ARB 0x2023
52 #define WGL_AUX_BUFFERS_ARB 0x2024
53 #define WGL_NO_ACCELERATION_ARB 0x2025
54 #define WGL_GENERIC_ACCELERATION_ARB 0x2026
55 #define WGL_FULL_ACCELERATION_ARB 0x2027
56 #define WGL_SWAP_EXCHANGE_ARB 0x2028
57 #define WGL_SWAP_COPY_ARB 0x2029
58 #define WGL_SWAP_UNDEFINED_ARB 0x202A
59 #define WGL_TYPE_RGBA_ARB 0x202B
60 #define WGL_TYPE_COLORINDEX_ARB 0x202C
61 #define WGL_SAMPLE_BUFFERS_ARB 0x2041
62 #define WGL_SAMPLES_ARB 0x2042
66 static int driver_init(
char *title,
int w,
int h,
int depth,
int refresh_rate,
int flags);
121 static int GL_init(PIXELFORMATDESCRIPTOR *pfd)
127 char *wgl_extensions =
NULL;
129 wnd = CreateWindow(
fb_win32.
window_class,
"OpenGL setup", WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
135 pf = ChoosePixelFormat(hdc, pfd);
136 SetPixelFormat(hdc, pf, pfd);
174 MONITORINFOEX monitor_info;
175 const char *devname =
NULL;
177 monitor_info.cbSize =
sizeof(MONITORINFOEX);
178 monitor_info.szDevice[0] =
'\0';
181 devname = monitor_info.szDevice;
185 flags = SWP_FRAMECHANGED;
188 mode.dmSize =
sizeof(mode);
193 mode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
197 }
else if (ChangeDisplaySettings(&mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
200 style &= ~WS_OVERLAPPEDWINDOW;
205 style &= ~WS_OVERLAPPEDWINDOW;
209 style |= WS_OVERLAPPEDWINDOW;
210 style &= ~(WS_POPUP | WS_THICKFRAME);
212 style &= ~WS_MAXIMIZEBOX;
214 flags |= SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER;
217 rect.left = rect.top = x = y = 0;
221 AdjustWindowRect(&rect, style,
FALSE);
222 if (monitor_info.szDevice[0]) {
223 x = monitor_info.rcMonitor.left + ((monitor_info.rcMonitor.right - monitor_info.rcMonitor.left - rect.right) >> 1);
224 y = monitor_info.rcMonitor.top + ((monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top - rect.bottom) >> 1);
226 x = (GetSystemMetrics(SM_CXSCREEN) - rect.right) >> 1;
227 y = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) >> 1;
229 }
else if (monitor_info.szDevice[0]) {
231 x = monitor_info.rcMonitor.left;
232 y = monitor_info.rcMonitor.top;
248 ChangeDisplaySettings(
NULL, 0);
252 static int driver_init(
char *title,
int w,
int h,
int depth_arg,
int refresh_rate,
int flags)
254 const char *wgl_funcs[] = {
"wglCreateContext",
"wglMakeCurrent",
"wglDeleteContext",
NULL };
255 PIXELFORMATDESCRIPTOR pfd = {
256 sizeof(PIXELFORMATDESCRIPTOR), 1,
257 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
258 PFD_TYPE_RGBA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0,
259 PFD_MAIN_PLANE, 0, 0, 0, 0
266 }, *attrib = &attribs[6], *samples_attrib =
NULL;
267 int depth =
MAX(8, depth_arg);
268 int pf = 0, num_formats, format;
293 if (
fb_hInitWindow((WS_CLIPSIBLINGS | WS_CLIPCHILDREN) & ~WS_THICKFRAME, 0, 0, 0, w, h))
341 samples_attrib = attrib;
353 }
while ((samples_attrib) && ((*samples_attrib -= 2) >= 0));
357 pf = ChoosePixelFormat(
hdc, &pfd);
360 if ((!pf) || (!SetPixelFormat(
hdc, pf, &pfd)))
367 if ((samples_attrib) && (*samples_attrib > 0))
383 ChangeDisplaySettings(
NULL, 0);
409 unsigned char keystate[256];
411 GetKeyboardState(keystate);
432 if (!EnumDisplaySettings(
NULL, index, &devmode))
435 if (devmode.dmBitsPerPel == depth) {
437 modes = (
int *)realloc(modes, *size *
sizeof(
int));
438 modes[(*size) - 1] = (devmode.dmPelsWidth << 16) | devmode.dmPelsHeight;