Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_wingl.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | c0a74f199ecf |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* WGL implementation of SDL OpenGL support */ | |
24 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
25 #if SDL_VIDEO_OPENGL |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
26 #include "SDL_opengl.h" |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
450
diff
changeset
|
27 #endif |
0 | 28 #include "SDL_lowvideo.h" |
29 #include "SDL_wingl_c.h" | |
30 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 #if SDL_VIDEO_OPENGL |
0 | 32 #define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL" |
33 #endif | |
34 | |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
35 /* If setting the HDC fails, we may need to recreate the window (MSDN) */ |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
36 static int WIN_GL_ResetWindow(_THIS) |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
37 { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
38 int status = 0; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
39 |
889
eac8c69b5706
ate: Fri, 09 Apr 2004 20:07:10 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
40 #if 0 /* This doesn't work with DirectX code (see CVS comments) */ |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
41 #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */ |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1261
diff
changeset
|
42 /* If we were passed a window, then we can't create a new one */ |
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1261
diff
changeset
|
43 if ( !SDL_windowid ) { |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
44 /* Save the existing window attributes */ |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
45 LONG style; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
46 RECT rect = { 0, 0, 0, 0 }; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
47 style = GetWindowLong(SDL_Window, GWL_STYLE); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
48 GetWindowRect(SDL_Window, &rect); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
49 DestroyWindow(SDL_Window); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
50 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
51 style, |
1316
0781906086fa
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
52 rect.left, rect.top, |
0781906086fa
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
53 (rect.right-rect.left)+1, |
0781906086fa
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
54 (rect.top-rect.bottom)+1, |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
55 NULL, NULL, SDL_Instance, NULL); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
56 if ( SDL_Window ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
57 this->SetCaption(this, this->wm_title, this->wm_icon); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
58 } else { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
59 SDL_SetError("Couldn't create window"); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
60 status = -1; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
61 } |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
62 } else |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
63 #endif /* !_WIN32_WCE */ |
889
eac8c69b5706
ate: Fri, 09 Apr 2004 20:07:10 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 #endif |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
65 { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
66 SDL_SetError("Unable to reset window for OpenGL context"); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
67 status = -1; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
68 } |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
69 return(status); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
70 } |
0 | 71 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
72 #if SDL_VIDEO_OPENGL |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
73 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
74 static int ExtensionSupported(const char *extension, const char *extensions) |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
75 { |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
76 const char *start; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
77 const char *where, *terminator; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
78 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
79 /* Extension names should not have spaces. */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
80 where = SDL_strchr(extension, ' '); |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
81 if ( where || *extension == '\0' ) |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
82 return 0; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
83 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
84 if ( ! extensions ) |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
85 return 0; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
86 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
87 /* It takes a bit of care to be fool-proof about parsing the |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
88 * OpenGL extensions string. Don't be fooled by sub-strings, |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
89 * etc. */ |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
90 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
91 start = extensions; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
92 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
93 for (;;) |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
94 { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
95 where = SDL_strstr(start, extension); |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
96 if (!where) break; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
97 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
98 terminator = where + SDL_strlen(extension); |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
99 if (where == start || *(where - 1) == ' ') |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
100 if (*terminator == ' ' || *terminator == '\0') return 1; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
101 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
102 start = terminator; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
103 } |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
104 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
105 return 0; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
106 } |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
107 |
677
92a933bf2f0f
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
671
diff
changeset
|
108 static void Init_WGL_ARB_extensions(_THIS) |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
109 { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
110 HWND hwnd; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
111 HDC hdc; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
112 HGLRC hglrc; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
113 int pformat; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
114 const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0; |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
115 const char *extensions; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
116 |
671
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
117 hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
118 0, 0, 10, 10, |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
119 NULL, NULL, SDL_Instance, NULL); |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
120 hdc = GetDC(hwnd); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
121 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
122 pformat = ChoosePixelFormat(hdc, &GL_pfd); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
123 SetPixelFormat(hdc, pformat, &GL_pfd); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
124 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
125 hglrc = this->gl_data->wglCreateContext(hdc); |
671
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
126 if ( hglrc ) { |
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
127 this->gl_data->wglMakeCurrent(hdc, hglrc); |
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
128 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
129 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
130 wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC)) |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
131 this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
132 |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
133 if( wglGetExtensionsStringARB ) { |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
134 extensions = wglGetExtensionsStringARB(hdc); |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
135 } else { |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
136 extensions = NULL; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
137 } |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
138 |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
139 this->gl_data->WGL_ARB_pixel_format = 0; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
140 if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
141 this->gl_data->wglChoosePixelFormatARB = |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
142 (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
143 this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB"); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
144 this->gl_data->wglGetPixelFormatAttribivARB = |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
145 (BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *)) |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
146 this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB"); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
147 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
148 if( (this->gl_data->wglChoosePixelFormatARB != NULL) && |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
149 (this->gl_data->wglGetPixelFormatAttribivARB != NULL) ) { |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
150 this->gl_data->WGL_ARB_pixel_format = 1; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
151 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
152 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
153 |
671
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
154 if ( hglrc ) { |
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
155 this->gl_data->wglMakeCurrent(NULL, NULL); |
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
156 this->gl_data->wglDeleteContext(hglrc); |
338a62f9a528
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
157 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
158 ReleaseDC(hwnd, hdc); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
159 DestroyWindow(hwnd); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
160 } |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
161 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
162 #endif /* SDL_VIDEO_OPENGL */ |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
163 |
0 | 164 int WIN_GL_SetupWindow(_THIS) |
165 { | |
166 int retval; | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
167 #if SDL_VIDEO_OPENGL |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
168 int i; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
169 unsigned int matching; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
170 int iAttribs[64]; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
171 int *iAttr; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
172 float fAttribs[1] = { 0 }; |
0 | 173 |
174 /* load the gl driver from a default path */ | |
175 if ( ! this->gl_config.driver_loaded ) { | |
176 /* no driver has been loaded, use default (ourselves) */ | |
177 if ( WIN_GL_LoadLibrary(this, NULL) < 0 ) { | |
178 return(-1); | |
179 } | |
180 } | |
181 | |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
182 for ( i=0; ; ++i ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
183 /* Get the window device context for our OpenGL drawing */ |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
184 GL_hdc = GetDC(SDL_Window); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
185 if ( GL_hdc == NULL ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
186 SDL_SetError("Unable to get DC for SDL_Window"); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
187 return(-1); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
188 } |
0 | 189 |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
190 /* Set up the pixel format descriptor with our needed format */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
191 SDL_memset(&GL_pfd, 0, sizeof(GL_pfd)); |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
192 GL_pfd.nSize = sizeof(GL_pfd); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
193 GL_pfd.nVersion = 1; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
194 GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
195 if ( this->gl_config.double_buffer ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
196 GL_pfd.dwFlags |= PFD_DOUBLEBUFFER; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
197 } |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
198 if ( this->gl_config.stereo ) { |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
199 GL_pfd.dwFlags |= PFD_STEREO; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
200 } |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
201 GL_pfd.iPixelType = PFD_TYPE_RGBA; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
202 GL_pfd.cColorBits = this->gl_config.buffer_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
203 GL_pfd.cRedBits = this->gl_config.red_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
204 GL_pfd.cGreenBits = this->gl_config.green_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
205 GL_pfd.cBlueBits = this->gl_config.blue_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
206 GL_pfd.cAlphaBits = this->gl_config.alpha_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
207 GL_pfd.cAccumRedBits = this->gl_config.accum_red_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
208 GL_pfd.cAccumGreenBits = this->gl_config.accum_green_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
209 GL_pfd.cAccumBlueBits = this->gl_config.accum_blue_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
210 GL_pfd.cAccumAlphaBits = this->gl_config.accum_alpha_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
211 GL_pfd.cAccumBits = |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
212 (GL_pfd.cAccumRedBits + GL_pfd.cAccumGreenBits + |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
213 GL_pfd.cAccumBlueBits + GL_pfd.cAccumAlphaBits); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
214 GL_pfd.cDepthBits = this->gl_config.depth_size; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
215 GL_pfd.cStencilBits = this->gl_config.stencil_size; |
0 | 216 |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
217 /* initialize WGL_ARB_pixel_format */ |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
218 Init_WGL_ARB_extensions(this); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
219 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
220 /* setup WGL_ARB_pixel_format attribs */ |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
221 iAttr = &iAttribs[0]; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
222 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
223 *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
224 *iAttr++ = GL_TRUE; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
225 *iAttr++ = WGL_ACCELERATION_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
226 *iAttr++ = WGL_FULL_ACCELERATION_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
227 *iAttr++ = WGL_RED_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
228 *iAttr++ = this->gl_config.red_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
229 *iAttr++ = WGL_GREEN_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
230 *iAttr++ = this->gl_config.green_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
231 *iAttr++ = WGL_BLUE_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
232 *iAttr++ = this->gl_config.blue_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
233 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
234 if ( this->gl_config.alpha_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
235 *iAttr++ = WGL_ALPHA_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
236 *iAttr++ = this->gl_config.alpha_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
237 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
238 |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
239 *iAttr++ = WGL_DOUBLE_BUFFER_ARB; |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
240 *iAttr++ = this->gl_config.double_buffer; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
241 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
242 *iAttr++ = WGL_DEPTH_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
243 *iAttr++ = this->gl_config.depth_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
244 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
245 if ( this->gl_config.stencil_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
246 *iAttr++ = WGL_STENCIL_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
247 *iAttr++ = this->gl_config.stencil_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
248 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
249 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
250 if ( this->gl_config.accum_red_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
251 *iAttr++ = WGL_ACCUM_RED_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
252 *iAttr++ = this->gl_config.accum_red_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
253 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
254 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
255 if ( this->gl_config.accum_green_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
256 *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
257 *iAttr++ = this->gl_config.accum_green_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
258 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
259 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
260 if ( this->gl_config.accum_blue_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
261 *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
262 *iAttr++ = this->gl_config.accum_blue_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
263 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
264 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
265 if ( this->gl_config.accum_alpha_size ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
266 *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
267 *iAttr++ = this->gl_config.accum_alpha_size; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
268 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
269 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
270 if ( this->gl_config.stereo ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
271 *iAttr++ = WGL_STEREO_ARB; |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
272 *iAttr++ = GL_TRUE; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
273 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
274 |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
275 if ( this->gl_config.multisamplebuffers ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
276 *iAttr++ = WGL_SAMPLE_BUFFERS_ARB; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
277 *iAttr++ = this->gl_config.multisamplebuffers; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
278 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
279 |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
280 if ( this->gl_config.multisamplesamples ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
281 *iAttr++ = WGL_SAMPLES_ARB; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
282 *iAttr++ = this->gl_config.multisamplesamples; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
283 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
284 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
285 *iAttr = 0; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
286 |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
287 /* Choose and set the closest available pixel format */ |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
288 if ( !this->gl_data->WGL_ARB_pixel_format || |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
289 !this->gl_data->wglChoosePixelFormatARB(GL_hdc, iAttribs, fAttribs, 1, &pixel_format, &matching) || |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
290 !matching ) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
291 pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd); |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
292 this->gl_data->WGL_ARB_pixel_format = 0; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
293 } |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
294 if ( !pixel_format ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
295 SDL_SetError("No matching GL pixel format available"); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
296 return(-1); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
297 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
298 if ( !SetPixelFormat(GL_hdc, pixel_format, &GL_pfd) ) { |
373
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
299 if ( i == 0 ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
300 /* First time through, try resetting the window */ |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
301 if ( WIN_GL_ResetWindow(this) < 0 ) { |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
302 return(-1); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
303 } |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
304 continue; |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
305 } |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
306 SDL_SetError("Unable to set HDC pixel format"); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
307 return(-1); |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
308 } |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
309 /* We either succeeded or failed by this point */ |
c638fde8a824
Fixed setting OpenGL mode multiple times on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
327
diff
changeset
|
310 break; |
0 | 311 } |
312 DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd); | |
313 | |
314 GL_hrc = this->gl_data->wglCreateContext(GL_hdc); | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
315 if ( GL_hrc == NULL ) { |
0 | 316 SDL_SetError("Unable to create GL context"); |
317 return(-1); | |
318 } | |
319 gl_active = 1; | |
320 #else | |
321 SDL_SetError("WIN driver not configured with OpenGL"); | |
322 #endif | |
323 if ( gl_active ) { | |
324 retval = 0; | |
325 } else { | |
326 retval = -1; | |
327 } | |
328 return(retval); | |
329 } | |
330 | |
331 void WIN_GL_ShutDown(_THIS) | |
332 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
333 #if SDL_VIDEO_OPENGL |
0 | 334 /* Clean up OpenGL */ |
335 if ( GL_hrc ) { | |
336 this->gl_data->wglMakeCurrent(NULL, NULL); | |
337 this->gl_data->wglDeleteContext(GL_hrc); | |
338 GL_hrc = NULL; | |
339 } | |
340 if ( GL_hdc ) { | |
341 ReleaseDC(SDL_Window, GL_hdc); | |
342 GL_hdc = NULL; | |
343 } | |
344 gl_active = 0; | |
345 | |
346 WIN_GL_UnloadLibrary(this); | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
347 #endif /* SDL_VIDEO_OPENGL */ |
0 | 348 } |
349 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
350 #if SDL_VIDEO_OPENGL |
0 | 351 |
352 /* Make the current context active */ | |
353 int WIN_GL_MakeCurrent(_THIS) | |
354 { | |
355 int retval; | |
356 | |
357 retval = 0; | |
358 if ( ! this->gl_data->wglMakeCurrent(GL_hdc, GL_hrc) ) { | |
359 SDL_SetError("Unable to make GL context current"); | |
360 retval = -1; | |
361 } | |
362 return(retval); | |
363 } | |
364 | |
365 /* Get attribute data from glX. */ | |
366 int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) | |
367 { | |
368 int retval; | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
369 |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
370 if ( this->gl_data->WGL_ARB_pixel_format ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
371 int wgl_attrib; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
372 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
373 switch(attrib) { |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
374 case SDL_GL_RED_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
375 wgl_attrib = WGL_RED_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
376 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
377 case SDL_GL_GREEN_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
378 wgl_attrib = WGL_GREEN_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
379 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
380 case SDL_GL_BLUE_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
381 wgl_attrib = WGL_BLUE_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
382 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
383 case SDL_GL_ALPHA_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
384 wgl_attrib = WGL_ALPHA_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
385 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
386 case SDL_GL_DOUBLEBUFFER: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
387 wgl_attrib = WGL_DOUBLE_BUFFER_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
388 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
389 case SDL_GL_BUFFER_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
390 wgl_attrib = WGL_COLOR_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
391 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
392 case SDL_GL_DEPTH_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
393 wgl_attrib = WGL_DEPTH_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
394 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
395 case SDL_GL_STENCIL_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
396 wgl_attrib = WGL_STENCIL_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
397 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
398 case SDL_GL_ACCUM_RED_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
399 wgl_attrib = WGL_ACCUM_RED_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
400 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
401 case SDL_GL_ACCUM_GREEN_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
402 wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
403 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
404 case SDL_GL_ACCUM_BLUE_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
405 wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
406 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
407 case SDL_GL_ACCUM_ALPHA_SIZE: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
408 wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
409 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
410 case SDL_GL_STEREO: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
411 wgl_attrib = WGL_STEREO_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
412 break; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
413 case SDL_GL_MULTISAMPLEBUFFERS: |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
414 wgl_attrib = WGL_SAMPLE_BUFFERS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
415 break; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
416 case SDL_GL_MULTISAMPLESAMPLES: |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
417 wgl_attrib = WGL_SAMPLES_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
418 break; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
419 default: |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
420 return(-1); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
421 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
422 this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value); |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
423 |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
424 return 0; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
425 } |
0 | 426 |
427 retval = 0; | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
428 switch ( attrib ) { |
0 | 429 case SDL_GL_RED_SIZE: |
430 *value = GL_pfd.cRedBits; | |
431 break; | |
432 case SDL_GL_GREEN_SIZE: | |
433 *value = GL_pfd.cGreenBits; | |
434 break; | |
435 case SDL_GL_BLUE_SIZE: | |
436 *value = GL_pfd.cBlueBits; | |
437 break; | |
438 case SDL_GL_ALPHA_SIZE: | |
439 *value = GL_pfd.cAlphaBits; | |
440 break; | |
441 case SDL_GL_DOUBLEBUFFER: | |
442 if ( GL_pfd.dwFlags & PFD_DOUBLEBUFFER ) { | |
443 *value = 1; | |
444 } else { | |
445 *value = 0; | |
446 } | |
447 break; | |
448 case SDL_GL_BUFFER_SIZE: | |
449 *value = GL_pfd.cColorBits; | |
450 break; | |
451 case SDL_GL_DEPTH_SIZE: | |
452 *value = GL_pfd.cDepthBits; | |
453 break; | |
454 case SDL_GL_STENCIL_SIZE: | |
455 *value = GL_pfd.cStencilBits; | |
456 break; | |
457 case SDL_GL_ACCUM_RED_SIZE: | |
458 *value = GL_pfd.cAccumRedBits; | |
459 break; | |
460 case SDL_GL_ACCUM_GREEN_SIZE: | |
461 *value = GL_pfd.cAccumGreenBits; | |
462 break; | |
463 case SDL_GL_ACCUM_BLUE_SIZE: | |
464 *value = GL_pfd.cAccumBlueBits; | |
465 break; | |
466 case SDL_GL_ACCUM_ALPHA_SIZE: | |
467 *value = GL_pfd.cAccumAlphaBits; | |
468 break; | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
469 case SDL_GL_STEREO: |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
470 if ( GL_pfd.dwFlags & PFD_STEREO ) { |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
471 *value = 1; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
472 } else { |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
473 *value = 0; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
474 } |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
373
diff
changeset
|
475 break; |
1261
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
476 case SDL_GL_MULTISAMPLEBUFFERS: |
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
477 *value = 0; |
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
478 break; |
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
479 case SDL_GL_MULTISAMPLESAMPLES: |
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
480 *value = 1; |
031e093ba2a5
Date: Thu, 04 Sep 2003 02:12:35 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
889
diff
changeset
|
481 break; |
0 | 482 default: |
483 retval = -1; | |
484 break; | |
485 } | |
486 return retval; | |
487 } | |
488 | |
489 void WIN_GL_SwapBuffers(_THIS) | |
490 { | |
491 SwapBuffers(GL_hdc); | |
492 } | |
493 | |
494 void WIN_GL_UnloadLibrary(_THIS) | |
495 { | |
496 if ( this->gl_config.driver_loaded ) { | |
497 FreeLibrary((HMODULE)this->gl_config.dll_handle); | |
498 | |
499 this->gl_data->wglGetProcAddress = NULL; | |
500 this->gl_data->wglCreateContext = NULL; | |
501 this->gl_data->wglDeleteContext = NULL; | |
502 this->gl_data->wglMakeCurrent = NULL; | |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
503 this->gl_data->wglChoosePixelFormatARB = NULL; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
504 this->gl_data->wglGetPixelFormatAttribivARB = NULL; |
0 | 505 |
506 this->gl_config.dll_handle = NULL; | |
507 this->gl_config.driver_loaded = 0; | |
508 } | |
509 } | |
510 | |
511 /* Passing a NULL path means load pointers from the application */ | |
512 int WIN_GL_LoadLibrary(_THIS, const char* path) | |
513 { | |
514 HMODULE handle; | |
515 | |
516 if ( gl_active ) { | |
517 SDL_SetError("OpenGL context already created"); | |
518 return -1; | |
519 } | |
520 | |
521 if ( path == NULL ) { | |
522 path = DEFAULT_GL_DRIVER_PATH; | |
523 } | |
524 handle = LoadLibrary(path); | |
525 if ( handle == NULL ) { | |
526 SDL_SetError("Could not load OpenGL library"); | |
527 return -1; | |
528 } | |
529 | |
530 /* Unload the old driver and reset the pointers */ | |
531 WIN_GL_UnloadLibrary(this); | |
532 | |
533 /* Load new function pointers */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
534 SDL_memset(this->gl_data, 0, sizeof(*this->gl_data)); |
0 | 535 this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *)) |
536 GetProcAddress(handle, "wglGetProcAddress"); | |
537 this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) | |
538 GetProcAddress(handle, "wglCreateContext"); | |
539 this->gl_data->wglDeleteContext = (BOOL (WINAPI *)(HGLRC)) | |
540 GetProcAddress(handle, "wglDeleteContext"); | |
541 this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC)) | |
542 GetProcAddress(handle, "wglMakeCurrent"); | |
543 | |
544 if ( (this->gl_data->wglGetProcAddress == NULL) || | |
545 (this->gl_data->wglCreateContext == NULL) || | |
546 (this->gl_data->wglDeleteContext == NULL) || | |
547 (this->gl_data->wglMakeCurrent == NULL) ) { | |
548 SDL_SetError("Could not retrieve OpenGL functions"); | |
549 FreeLibrary(handle); | |
550 return -1; | |
551 } | |
552 | |
553 this->gl_config.dll_handle = handle; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
554 SDL_strcpy(this->gl_config.driver_path, path); |
0 | 555 this->gl_config.driver_loaded = 1; |
556 return 0; | |
557 } | |
558 | |
559 void *WIN_GL_GetProcAddress(_THIS, const char* proc) | |
560 { | |
561 void *func; | |
562 | |
563 /* This is to pick up extensions */ | |
564 func = this->gl_data->wglGetProcAddress(proc); | |
565 if ( ! func ) { | |
566 /* This is probably a normal GL function */ | |
567 func = GetProcAddress(this->gl_config.dll_handle, proc); | |
568 } | |
569 return func; | |
570 } | |
571 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
572 #endif /* SDL_VIDEO_OPENGL */ |