Mercurial > sdl-ios-xcode
annotate src/video/SDL_video.c @ 2789:985001797115
Fixed bug #605, per Martin's suggestion
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 25 Nov 2008 20:06:27 +0000 |
parents | 93764fe8601a |
children | 27cb878a278e |
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:
1296
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:
1296
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:
1296
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:
1296
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:
1296
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:
1296
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:
1296
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:
229
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1385
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* The high-level video driver subsystem */ | |
25 | |
26 #include "SDL.h" | |
27 #include "SDL_sysvideo.h" | |
28 #include "SDL_blit.h" | |
29 #include "SDL_pixels_c.h" | |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
30 #include "SDL_renderer_gl.h" |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
31 #include "SDL_renderer_gles.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
32 #include "SDL_renderer_sw.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
33 #include "../events/SDL_sysevents.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
34 #include "../events/SDL_events_c.h" |
0 | 35 |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
36 #if SDL_VIDEO_OPENGL_ES |
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
37 #include "SDL_opengles.h" |
2753 | 38 #endif /* SDL_VIDEO_OPENGL_ES */ |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
39 |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
40 #if SDL_VIDEO_OPENGL |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
41 #include "SDL_opengl.h" |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
42 |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
43 /* On Windows, windows.h defines CreateWindow */ |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
44 #ifdef CreateWindow |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
45 #undef CreateWindow |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
46 #endif |
2753 | 47 #endif /* SDL_VIDEO_OPENGL */ |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
48 |
0 | 49 /* Available video drivers */ |
50 static VideoBootStrap *bootstrap[] = { | |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
1930
diff
changeset
|
51 #if SDL_VIDEO_DRIVER_COCOA |
2753 | 52 &COCOA_bootstrap, |
1133
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
1076
diff
changeset
|
53 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
54 #if SDL_VIDEO_DRIVER_X11 |
2753 | 55 &X11_bootstrap, |
0 | 56 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
57 #if SDL_VIDEO_DRIVER_NANOX |
2753 | 58 &NX_bootstrap, |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
19
diff
changeset
|
59 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
60 #if SDL_VIDEO_DRIVER_IPOD |
2753 | 61 &iPod_bootstrap, |
1140
af8b0f9ac2f4
iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1133
diff
changeset
|
62 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
63 #if SDL_VIDEO_DRIVER_WSCONS |
2753 | 64 &WSCONS_bootstrap, |
1187 | 65 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
66 #if SDL_VIDEO_DRIVER_FBCON |
2753 | 67 &FBCON_bootstrap, |
0 | 68 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
69 #if SDL_VIDEO_DRIVER_DIRECTFB |
2753 | 70 &DirectFB_bootstrap, |
167
cb384ef627f6
Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
125
diff
changeset
|
71 #endif |
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_DRIVER_PS2GS |
2753 | 73 &PS2GS_bootstrap, |
0 | 74 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
75 #if SDL_VIDEO_DRIVER_VGL |
2753 | 76 &VGL_bootstrap, |
75
b0ae59d0f3ee
Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
58
diff
changeset
|
77 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
78 #if SDL_VIDEO_DRIVER_SVGALIB |
2753 | 79 &SVGALIB_bootstrap, |
0 | 80 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
81 #if SDL_VIDEO_DRIVER_GAPI |
2753 | 82 &GAPI_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
83 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
84 #if SDL_VIDEO_DRIVER_WIN32 |
2753 | 85 &WIN32_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
86 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
87 #if SDL_VIDEO_DRIVER_BWINDOW |
2753 | 88 &BWINDOW_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
89 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
90 #if SDL_VIDEO_DRIVER_PHOTON |
2753 | 91 &ph_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
92 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
93 #if SDL_VIDEO_DRIVER_EPOC |
2753 | 94 &EPOC_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
95 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
96 #if SDL_VIDEO_DRIVER_XBIOS |
2753 | 97 &XBIOS_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
98 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
99 #if SDL_VIDEO_DRIVER_GEM |
2753 | 100 &GEM_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
101 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
102 #if SDL_VIDEO_DRIVER_DC |
2753 | 103 &DC_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
104 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
105 #if SDL_VIDEO_DRIVER_RISCOS |
2753 | 106 &RISCOS_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
107 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
108 #if SDL_VIDEO_DRIVER_OS2FS |
2753 | 109 &OS2FSLib_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
110 #endif |
2743
453ec0c21f6f
Rolling back changes to revision 4071 ... made some mistakes, will try merging work again.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2740
diff
changeset
|
111 #if SDL_VIDEO_DRIVER_NDS |
2753 | 112 &NDS_bootstrap, |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2702
diff
changeset
|
113 #endif |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
114 #if SDL_VIDEO_DRIVER_UIKIT |
2753 | 115 &UIKIT_bootstrap, |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
116 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
117 #if SDL_VIDEO_DRIVER_DUMMY |
2753 | 118 &DUMMY_bootstrap, |
610
95433459fbd2
Date: Mon, 14 Apr 2003 22:08:27 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
580
diff
changeset
|
119 #endif |
2753 | 120 NULL |
0 | 121 }; |
173
83018110dce8
Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
167
diff
changeset
|
122 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
123 static SDL_VideoDevice *_this = NULL; |
0 | 124 |
125 /* Various local functions */ | |
2753 | 126 int SDL_VideoInit(const char *driver_name, Uint32 flags); |
127 void SDL_VideoQuit(void); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
128 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
129 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
130 cmpmodes(const void *A, const void *B) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
131 { |
2753 | 132 SDL_DisplayMode a = *(const SDL_DisplayMode *) A; |
133 SDL_DisplayMode b = *(const SDL_DisplayMode *) B; | |
0 | 134 |
2753 | 135 if (a.w != b.w) { |
136 return b.w - a.w; | |
137 } | |
138 if (a.h != b.h) { | |
139 return b.h - a.h; | |
140 } | |
141 if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) { | |
142 return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format); | |
143 } | |
144 if (a.refresh_rate != b.refresh_rate) { | |
145 return b.refresh_rate - a.refresh_rate; | |
146 } | |
147 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
148 } |
0 | 149 |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
150 static void |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
151 SDL_UninitializedVideo() |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
152 { |
2753 | 153 SDL_SetError("Video subsystem has not been initialized"); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
154 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
155 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
156 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
157 SDL_GetNumVideoDrivers(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
158 { |
2753 | 159 return SDL_arraysize(bootstrap) - 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
160 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
161 |
2753 | 162 const char * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
163 SDL_GetVideoDriver(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
164 { |
2753 | 165 if (index >= 0 && index < SDL_GetNumVideoDrivers()) { |
166 return bootstrap[index]->name; | |
167 } | |
168 return NULL; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
169 } |
0 | 170 |
171 /* | |
172 * Initialize the video and event subsystems -- determine native pixel format | |
173 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
174 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
175 SDL_VideoInit(const char *driver_name, Uint32 flags) |
0 | 176 { |
2753 | 177 SDL_VideoDevice *video; |
178 int index; | |
179 int i; | |
0 | 180 |
2753 | 181 /* Toggle the event thread flags, based on OS requirements */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
182 #if defined(MUST_THREAD_EVENTS) |
2753 | 183 flags |= SDL_INIT_EVENTTHREAD; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
184 #elif defined(CANT_THREAD_EVENTS) |
2753 | 185 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { |
186 SDL_SetError("OS doesn't support threaded events"); | |
187 return -1; | |
188 } | |
1190 | 189 #endif |
229
4d24d5a660a8
Fix a crash if an OpenGL video mode can't be set.
Sam Lantinga <slouken@libsdl.org>
parents:
216
diff
changeset
|
190 |
2753 | 191 /* Start the event loop */ |
192 if (SDL_StartEventLoop(flags) < 0) { | |
193 return -1; | |
194 } | |
195 /* Check to make sure we don't overwrite '_this' */ | |
196 if (_this != NULL) { | |
197 SDL_VideoQuit(); | |
198 } | |
199 /* Select the proper video driver */ | |
200 index = 0; | |
201 video = NULL; | |
202 if (driver_name == NULL) { | |
203 driver_name = SDL_getenv("SDL_VIDEODRIVER"); | |
204 } | |
205 if (driver_name != NULL) { | |
206 for (i = 0; bootstrap[i]; ++i) { | |
207 if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { | |
208 if (bootstrap[i]->available()) { | |
209 video = bootstrap[i]->create(index); | |
210 } | |
211 break; | |
212 } | |
213 } | |
214 } else { | |
215 for (i = 0; bootstrap[i]; ++i) { | |
216 if (bootstrap[i]->available()) { | |
217 video = bootstrap[i]->create(index); | |
218 if (video != NULL) { | |
219 break; | |
220 } | |
221 } | |
222 } | |
223 } | |
224 if (video == NULL) { | |
225 if (driver_name) { | |
226 SDL_SetError("%s not available", driver_name); | |
227 } else { | |
228 SDL_SetError("No available video device"); | |
229 } | |
230 return -1; | |
231 } | |
232 _this = video; | |
233 _this->name = bootstrap[i]->name; | |
234 _this->next_object_id = 1; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
235 |
0 | 236 |
2753 | 237 /* Set some very sane GL defaults */ |
238 _this->gl_config.driver_loaded = 0; | |
239 _this->gl_config.dll_handle = NULL; | |
240 _this->gl_config.red_size = 3; | |
241 _this->gl_config.green_size = 3; | |
242 _this->gl_config.blue_size = 2; | |
243 _this->gl_config.alpha_size = 0; | |
244 _this->gl_config.buffer_size = 0; | |
245 _this->gl_config.depth_size = 16; | |
246 _this->gl_config.stencil_size = 0; | |
247 _this->gl_config.double_buffer = 1; | |
248 _this->gl_config.accum_red_size = 0; | |
249 _this->gl_config.accum_green_size = 0; | |
250 _this->gl_config.accum_blue_size = 0; | |
251 _this->gl_config.accum_alpha_size = 0; | |
252 _this->gl_config.stereo = 0; | |
253 _this->gl_config.multisamplebuffers = 0; | |
254 _this->gl_config.multisamplesamples = 0; | |
255 _this->gl_config.retained_backing = 1; | |
256 _this->gl_config.accelerated = -1; /* not known, don't set */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
257 |
2753 | 258 /* Initialize the video subsystem */ |
259 if (_this->VideoInit(_this) < 0) { | |
260 SDL_VideoQuit(); | |
261 return -1; | |
262 } | |
263 /* Make sure some displays were added */ | |
264 if (_this->num_displays == 0) { | |
265 SDL_SetError("The video driver did not add any displays"); | |
266 SDL_VideoQuit(); | |
267 return (-1); | |
268 } | |
269 /* The software renderer is always available */ | |
270 for (i = 0; i < _this->num_displays; ++i) { | |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
271 #if SDL_VIDEO_RENDER_OGL |
2753 | 272 SDL_AddRenderDriver(i, &GL_RenderDriver); |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
273 #endif |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
274 |
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
275 #if SDL_VIDEO_RENDER_OGL_ES |
2753 | 276 SDL_AddRenderDriver(i, &GL_ES_RenderDriver); |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
277 #endif |
2753 | 278 if (_this->displays[i].num_render_drivers > 0) { |
279 SDL_AddRenderDriver(i, &SW_RenderDriver); | |
280 } | |
281 } | |
0 | 282 |
2753 | 283 /* We're ready to go! */ |
284 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
285 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
286 |
2753 | 287 const char * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
288 SDL_GetCurrentVideoDriver() |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
289 { |
2753 | 290 if (!_this) { |
291 SDL_UninitializedVideo(); | |
292 return NULL; | |
293 } | |
294 return _this->name; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
295 } |
0 | 296 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
297 SDL_VideoDevice * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
298 SDL_GetVideoDevice() |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
299 { |
2753 | 300 return _this; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
301 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
302 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
303 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
304 SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
305 { |
2753 | 306 SDL_VideoDisplay display; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
307 |
2753 | 308 SDL_zero(display); |
309 if (desktop_mode) { | |
310 display.desktop_mode = *desktop_mode; | |
311 } | |
312 display.current_mode = display.desktop_mode; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
313 |
2753 | 314 return SDL_AddVideoDisplay(&display); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
315 } |
0 | 316 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
317 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
318 SDL_AddVideoDisplay(const SDL_VideoDisplay * display) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
319 { |
2753 | 320 SDL_VideoDisplay *displays; |
321 int index = -1; | |
0 | 322 |
2753 | 323 displays = |
324 SDL_realloc(_this->displays, | |
325 (_this->num_displays + 1) * sizeof(*displays)); | |
326 if (displays) { | |
327 index = _this->num_displays++; | |
328 displays[index] = *display; | |
329 displays[index].device = _this; | |
330 _this->displays = displays; | |
331 } else { | |
332 SDL_OutOfMemory(); | |
333 } | |
334 return index; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
335 } |
0 | 336 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
337 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
338 SDL_GetNumVideoDisplays(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
339 { |
2753 | 340 if (!_this) { |
341 SDL_UninitializedVideo(); | |
342 return 0; | |
343 } | |
344 return _this->num_displays; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
345 } |
0 | 346 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
347 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
348 SDL_SelectVideoDisplay(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
349 { |
2753 | 350 if (!_this) { |
351 SDL_UninitializedVideo(); | |
352 return (-1); | |
353 } | |
354 if (index < 0 || index >= _this->num_displays) { | |
355 SDL_SetError("index must be in the range 0 - %d", | |
356 _this->num_displays - 1); | |
357 return -1; | |
358 } | |
359 _this->current_display = index; | |
360 return 0; | |
1963
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
361 } |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
362 |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
363 int |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
364 SDL_GetCurrentVideoDisplay(void) |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
365 { |
2753 | 366 if (!_this) { |
367 SDL_UninitializedVideo(); | |
368 return (-1); | |
369 } | |
370 return _this->current_display; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
371 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
372 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
373 SDL_bool |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
374 SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
375 { |
2753 | 376 SDL_VideoDisplay *display = &_this->displays[displayIndex]; |
377 SDL_DisplayMode *modes; | |
378 int i, nmodes; | |
910
4ab6d1fd028f
Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
883
diff
changeset
|
379 |
2753 | 380 /* Make sure we don't already have the mode in the list */ |
381 modes = display->display_modes; | |
382 nmodes = display->num_display_modes; | |
383 for (i = nmodes; i--;) { | |
384 if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) { | |
385 return SDL_FALSE; | |
386 } | |
387 } | |
910
4ab6d1fd028f
Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
883
diff
changeset
|
388 |
2753 | 389 /* Go ahead and add the new mode */ |
390 if (nmodes == display->max_display_modes) { | |
391 modes = | |
392 SDL_realloc(modes, | |
393 (display->max_display_modes + 32) * sizeof(*modes)); | |
394 if (!modes) { | |
395 return SDL_FALSE; | |
396 } | |
397 display->display_modes = modes; | |
398 display->max_display_modes += 32; | |
399 } | |
400 modes[nmodes] = *mode; | |
401 display->num_display_modes++; | |
650
fe445b59d307
We need to lookup the address of glGetString before calling GL_MakeCurrent(),
Ryan C. Gordon <icculus@icculus.org>
parents:
630
diff
changeset
|
402 |
2753 | 403 return SDL_TRUE; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
404 } |
0 | 405 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
406 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
407 SDL_GetNumDisplayModes() |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
408 { |
2753 | 409 if (_this) { |
410 SDL_VideoDisplay *display = &SDL_CurrentDisplay; | |
411 if (!display->num_display_modes && _this->GetDisplayModes) { | |
412 _this->GetDisplayModes(_this); | |
413 SDL_qsort(display->display_modes, display->num_display_modes, | |
414 sizeof(SDL_DisplayMode), cmpmodes); | |
415 } | |
416 return display->num_display_modes; | |
417 } | |
418 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
419 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
420 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
421 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
422 SDL_GetDisplayMode(int index, SDL_DisplayMode * mode) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
423 { |
2753 | 424 if (index < 0 || index >= SDL_GetNumDisplayModes()) { |
425 SDL_SetError("index must be in the range of 0 - %d", | |
426 SDL_GetNumDisplayModes() - 1); | |
427 return -1; | |
428 } | |
429 if (mode) { | |
430 *mode = SDL_CurrentDisplay.display_modes[index]; | |
431 } | |
432 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
433 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
434 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
435 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
436 SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
437 { |
2753 | 438 if (!_this) { |
439 SDL_UninitializedVideo(); | |
440 return -1; | |
441 } | |
442 if (mode) { | |
443 *mode = SDL_CurrentDisplay.desktop_mode; | |
444 } | |
445 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
446 } |
0 | 447 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
448 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
449 SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
450 { |
2753 | 451 if (!_this) { |
452 SDL_UninitializedVideo(); | |
453 return -1; | |
454 } | |
455 if (mode) { | |
456 *mode = SDL_CurrentDisplay.current_mode; | |
457 } | |
458 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
459 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
460 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
461 SDL_DisplayMode * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
462 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, |
2753 | 463 SDL_DisplayMode * closest) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
464 { |
2753 | 465 Uint32 target_format; |
466 int target_refresh_rate; | |
467 int i; | |
468 SDL_DisplayMode *current, *match; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
469 |
2753 | 470 if (!_this || !mode || !closest) { |
471 return NULL; | |
472 } | |
473 /* Default to the desktop format */ | |
474 if (mode->format) { | |
475 target_format = mode->format; | |
476 } else { | |
477 target_format = SDL_CurrentDisplay.desktop_mode.format; | |
478 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
479 |
2753 | 480 /* Default to the desktop refresh rate */ |
481 if (mode->refresh_rate) { | |
482 target_refresh_rate = mode->refresh_rate; | |
483 } else { | |
484 target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate; | |
485 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
486 |
2753 | 487 match = NULL; |
488 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { | |
489 current = &SDL_CurrentDisplay.display_modes[i]; | |
0 | 490 |
2789
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
491 if (current->w && (current->w < mode->w)) { |
2753 | 492 /* Out of sorted modes large enough here */ |
493 break; | |
494 } | |
2789
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
495 if (current->h && (current->h < mode->h)) { |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
496 if (current->w && (current->w == mode->w)) { |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
497 /* Out of sorted modes large enough here */ |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
498 break; |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
499 } |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
500 /* Wider, but not tall enough, due to a different |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
501 aspect ratio. This mode must be skipped, but closer |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
502 modes may still follow. */ |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
503 continue; |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
504 } |
2753 | 505 if (!match || current->w < match->w || current->h < match->h) { |
506 match = current; | |
507 continue; | |
508 } | |
509 if (current->format != match->format) { | |
510 /* Sorted highest depth to lowest */ | |
511 if (current->format == target_format || | |
512 (SDL_BITSPERPIXEL(current->format) >= | |
513 SDL_BITSPERPIXEL(target_format) | |
514 && SDL_PIXELTYPE(current->format) == | |
515 SDL_PIXELTYPE(target_format))) { | |
516 match = current; | |
517 } | |
518 continue; | |
519 } | |
520 if (current->refresh_rate != match->refresh_rate) { | |
521 /* Sorted highest refresh to lowest */ | |
522 if (current->refresh_rate >= target_refresh_rate) { | |
523 match = current; | |
524 } | |
525 } | |
526 } | |
527 if (match) { | |
528 if (match->format) { | |
529 closest->format = match->format; | |
530 } else { | |
531 closest->format = mode->format; | |
532 } | |
533 if (match->w && match->h) { | |
534 closest->w = match->w; | |
535 closest->h = match->h; | |
536 } else { | |
537 closest->w = mode->w; | |
538 closest->h = mode->h; | |
539 } | |
540 if (match->refresh_rate) { | |
541 closest->refresh_rate = match->refresh_rate; | |
542 } else { | |
543 closest->refresh_rate = mode->refresh_rate; | |
544 } | |
545 closest->driverdata = match->driverdata; | |
0 | 546 |
2753 | 547 /* |
548 * Pick some reasonable defaults if the app and driver don't | |
549 * care | |
550 */ | |
551 if (!closest->format) { | |
552 closest->format = SDL_PIXELFORMAT_RGB888; | |
553 } | |
554 if (!closest->w) { | |
555 closest->w = 640; | |
556 } | |
557 if (!closest->h) { | |
558 closest->h = 480; | |
559 } | |
560 return closest; | |
561 } | |
562 return NULL; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
563 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
564 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
565 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
566 SDL_SetDisplayMode(const SDL_DisplayMode * mode) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
567 { |
2753 | 568 SDL_VideoDisplay *display; |
569 SDL_DisplayMode display_mode; | |
570 SDL_DisplayMode current_mode; | |
571 int i, ncolors; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
572 |
2753 | 573 if (!_this) { |
574 SDL_UninitializedVideo(); | |
575 return -1; | |
576 } | |
577 display = &SDL_CurrentDisplay; | |
578 if (!mode) { | |
579 mode = &display->desktop_mode; | |
580 } | |
581 display_mode = *mode; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
582 |
2753 | 583 /* Default to the current mode */ |
584 if (!display_mode.format) { | |
585 display_mode.format = display->current_mode.format; | |
586 } | |
587 if (!display_mode.w) { | |
588 display_mode.w = display->current_mode.w; | |
589 } | |
590 if (!display_mode.h) { | |
591 display_mode.h = display->current_mode.h; | |
592 } | |
593 if (!display_mode.refresh_rate) { | |
594 display_mode.refresh_rate = display->current_mode.refresh_rate; | |
595 } | |
596 /* Get a good video mode, the closest one possible */ | |
597 if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) { | |
598 SDL_SetError("No video mode large enough for %dx%d", | |
599 display_mode.w, display_mode.h); | |
600 return -1; | |
601 } | |
602 /* See if there's anything left to do */ | |
603 SDL_GetCurrentDisplayMode(¤t_mode); | |
604 if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) { | |
605 return 0; | |
606 } | |
607 /* Actually change the display mode */ | |
608 if (_this->SetDisplayMode(_this, &display_mode) < 0) { | |
609 return -1; | |
610 } | |
611 display->current_mode = display_mode; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
612 |
2753 | 613 /* Set up a palette, if necessary */ |
614 if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) { | |
615 ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format)); | |
616 } else { | |
617 ncolors = 0; | |
618 } | |
619 if ((!ncolors && display->palette) || (ncolors && !display->palette) | |
620 || (ncolors && ncolors != display->palette->ncolors)) { | |
621 if (display->palette) { | |
622 SDL_FreePalette(display->palette); | |
623 display->palette = NULL; | |
624 } | |
625 if (ncolors) { | |
626 display->palette = SDL_AllocPalette(ncolors); | |
627 if (!display->palette) { | |
628 return -1; | |
629 } | |
630 SDL_DitherColors(display->palette->colors, | |
631 SDL_BITSPERPIXEL(display_mode.format)); | |
632 } | |
633 } | |
634 /* Move any fullscreen windows into position */ | |
635 for (i = 0; i < display->num_windows; ++i) { | |
636 SDL_Window *window = &display->windows[i]; | |
637 if (FULLSCREEN_VISIBLE(window)) { | |
638 SDL_SetWindowPosition(window->id, SDL_WINDOWPOS_CENTERED, | |
639 SDL_WINDOWPOS_CENTERED); | |
640 } | |
641 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
642 |
2753 | 643 return 0; |
0 | 644 } |
645 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
646 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
647 SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
648 { |
2753 | 649 SDL_VideoDisplay *display; |
650 SDL_DisplayMode fullscreen_mode; | |
651 int i; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
652 |
2753 | 653 if (!_this) { |
654 SDL_UninitializedVideo(); | |
655 return -1; | |
656 } | |
657 display = &SDL_CurrentDisplay; | |
658 if (!mode) { | |
659 mode = &display->desktop_mode; | |
660 } | |
661 SDL_GetClosestDisplayMode(mode, &fullscreen_mode); | |
662 if (SDL_memcmp | |
663 (&fullscreen_mode, &display->fullscreen_mode, | |
664 sizeof(fullscreen_mode)) == 0) { | |
665 /* Nothing to do... */ | |
666 return 0; | |
667 } | |
668 display->fullscreen_mode = fullscreen_mode; | |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
669 |
2753 | 670 /* Actually set the mode if we have a fullscreen window visible */ |
671 for (i = 0; i < display->num_windows; ++i) { | |
672 SDL_Window *window = &display->windows[i]; | |
673 if (FULLSCREEN_VISIBLE(window)) { | |
674 if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) { | |
675 return -1; | |
676 } | |
677 } | |
678 if (window->flags & SDL_WINDOW_FULLSCREEN) { | |
679 SDL_OnWindowResized(window); | |
680 } | |
681 } | |
682 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
683 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
684 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
685 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
686 SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
687 { |
2753 | 688 if (!_this) { |
689 SDL_UninitializedVideo(); | |
690 return -1; | |
691 } | |
692 if (mode) { | |
693 *mode = SDL_CurrentDisplay.fullscreen_mode; | |
694 } | |
695 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
696 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
697 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
698 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
699 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) |
0 | 700 { |
2753 | 701 SDL_Palette *palette; |
702 int status = 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
703 |
2753 | 704 if (!_this) { |
705 SDL_UninitializedVideo(); | |
706 return -1; | |
707 } | |
708 palette = SDL_CurrentDisplay.palette; | |
709 if (!palette) { | |
710 SDL_SetError("Display mode does not have a palette"); | |
711 return -1; | |
712 } | |
713 status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
714 |
2753 | 715 if (_this->SetDisplayPalette) { |
716 if (_this->SetDisplayPalette(_this, palette) < 0) { | |
717 status = -1; | |
718 } | |
719 } | |
720 return status; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
721 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
722 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
723 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
724 SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
725 { |
2753 | 726 SDL_Palette *palette; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
727 |
2753 | 728 if (!_this) { |
729 SDL_UninitializedVideo(); | |
730 return -1; | |
731 } | |
732 palette = SDL_CurrentDisplay.palette; | |
733 if (!palette->ncolors) { | |
734 SDL_SetError("Display mode does not have a palette"); | |
735 return -1; | |
736 } | |
737 if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) { | |
738 SDL_SetError("Palette indices are out of range"); | |
739 return -1; | |
740 } | |
741 SDL_memcpy(colors, &palette->colors[firstcolor], | |
742 ncolors * sizeof(*colors)); | |
743 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
744 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
745 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
746 SDL_WindowID |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
747 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
748 { |
2753 | 749 const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | |
750 SDL_WINDOW_OPENGL | | |
751 SDL_WINDOW_BORDERLESS | | |
752 SDL_WINDOW_RESIZABLE); | |
753 SDL_VideoDisplay *display; | |
754 SDL_Window window; | |
755 int num_windows; | |
756 SDL_Window *windows; | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
757 |
2753 | 758 if (!_this) { |
759 SDL_UninitializedVideo(); | |
760 return 0; | |
761 } | |
762 if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) { | |
763 SDL_SetError("No OpenGL support in video driver"); | |
764 return 0; | |
765 } | |
766 /* Fullscreen windows don't have any window decorations */ | |
767 if (flags & SDL_WINDOW_FULLSCREEN) { | |
768 flags |= SDL_WINDOW_BORDERLESS; | |
769 flags &= ~SDL_WINDOW_RESIZABLE; | |
770 } | |
771 SDL_zero(window); | |
772 window.id = _this->next_object_id++; | |
773 window.x = x; | |
774 window.y = y; | |
775 window.w = w; | |
776 window.h = h; | |
777 window.flags = (flags & allowed_flags); | |
778 window.display = _this->current_display; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
779 |
2753 | 780 if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) { |
781 return 0; | |
782 } | |
783 display = &SDL_CurrentDisplay; | |
784 num_windows = display->num_windows; | |
785 windows = | |
786 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); | |
787 if (!windows) { | |
788 if (_this->DestroyWindow) { | |
789 _this->DestroyWindow(_this, &window); | |
790 } | |
791 return 0; | |
792 } | |
793 windows[num_windows] = window; | |
794 display->windows = windows; | |
795 display->num_windows++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
796 |
2753 | 797 if (title) { |
798 SDL_SetWindowTitle(window.id, title); | |
799 } | |
800 if (flags & SDL_WINDOW_MAXIMIZED) { | |
801 SDL_MaximizeWindow(window.id); | |
802 } | |
803 if (flags & SDL_WINDOW_MINIMIZED) { | |
804 SDL_MinimizeWindow(window.id); | |
805 } | |
806 if (flags & SDL_WINDOW_SHOWN) { | |
807 SDL_ShowWindow(window.id); | |
808 } | |
809 if (flags & SDL_WINDOW_INPUT_GRABBED) { | |
810 SDL_SetWindowGrab(window.id, 1); | |
811 } | |
812 return window.id; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
813 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
814 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
815 SDL_WindowID |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
816 SDL_CreateWindowFrom(const void *data) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
817 { |
2753 | 818 SDL_VideoDisplay *display; |
819 SDL_Window window; | |
820 int num_windows; | |
821 SDL_Window *windows; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
822 |
2753 | 823 if (!_this) { |
824 SDL_UninitializedVideo(); | |
825 return (0); | |
826 } | |
827 SDL_zero(window); | |
828 window.id = _this->next_object_id++; | |
829 window.display = _this->current_display; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
830 |
2753 | 831 if (!_this->CreateWindowFrom || |
832 _this->CreateWindowFrom(_this, &window, data) < 0) { | |
833 return 0; | |
834 } | |
835 display = &SDL_CurrentDisplay; | |
836 num_windows = display->num_windows; | |
837 windows = | |
838 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); | |
839 if (!windows) { | |
840 if (_this->DestroyWindow) { | |
841 _this->DestroyWindow(_this, &window); | |
842 } | |
843 if (window.title) { | |
844 SDL_free(window.title); | |
845 } | |
846 return 0; | |
847 } | |
848 windows[num_windows] = window; | |
849 display->windows = windows; | |
850 display->num_windows++; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
851 |
2753 | 852 return window.id; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
853 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
854 |
1924
69217fdd2c0a
If the OpenGL renderer is selected for a non-OpenGL window, recreate the window with OpenGL enabled.
Sam Lantinga <slouken@libsdl.org>
parents:
1923
diff
changeset
|
855 int |
1928
861bc36f0ab3
Fixed crash with multiple windows
Sam Lantinga <slouken@libsdl.org>
parents:
1926
diff
changeset
|
856 SDL_RecreateWindow(SDL_Window * window, Uint32 flags) |
1924
69217fdd2c0a
If the OpenGL renderer is selected for a non-OpenGL window, recreate the window with OpenGL enabled.
Sam Lantinga <slouken@libsdl.org>
parents:
1923
diff
changeset
|
857 { |
2753 | 858 char *title = window->title; |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
859 |
2753 | 860 if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) { |
861 SDL_SetError("No OpenGL support in video driver"); | |
862 return -1; | |
863 } | |
864 if (_this->DestroyWindow) { | |
865 _this->DestroyWindow(_this, window); | |
866 } | |
867 window->title = NULL; | |
868 window->flags = | |
869 (flags & | |
870 ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_SHOWN | | |
871 SDL_WINDOW_INPUT_GRABBED)); | |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
872 |
2753 | 873 if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) { |
874 return -1; | |
875 } | |
876 if (title) { | |
877 SDL_SetWindowTitle(window->id, title); | |
878 SDL_free(title); | |
879 } | |
880 if (flags & SDL_WINDOW_MAXIMIZED) { | |
881 SDL_MaximizeWindow(window->id); | |
882 } | |
883 if (flags & SDL_WINDOW_MINIMIZED) { | |
884 SDL_MinimizeWindow(window->id); | |
885 } | |
886 if (flags & SDL_WINDOW_SHOWN) { | |
887 SDL_ShowWindow(window->id); | |
888 } | |
889 if (flags & SDL_WINDOW_INPUT_GRABBED) { | |
890 SDL_SetWindowGrab(window->id, 1); | |
891 } | |
892 return 0; | |
1924
69217fdd2c0a
If the OpenGL renderer is selected for a non-OpenGL window, recreate the window with OpenGL enabled.
Sam Lantinga <slouken@libsdl.org>
parents:
1923
diff
changeset
|
893 } |
69217fdd2c0a
If the OpenGL renderer is selected for a non-OpenGL window, recreate the window with OpenGL enabled.
Sam Lantinga <slouken@libsdl.org>
parents:
1923
diff
changeset
|
894 |
2753 | 895 SDL_Window * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
896 SDL_GetWindowFromID(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
897 { |
2753 | 898 int i, j; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
899 |
2753 | 900 if (!_this) { |
901 SDL_UninitializedVideo(); | |
902 return NULL; | |
903 } | |
904 for (i = 0; i < _this->num_displays; ++i) { | |
905 SDL_VideoDisplay *display = &_this->displays[i]; | |
906 for (j = 0; j < display->num_windows; ++j) { | |
907 SDL_Window *window = &display->windows[j]; | |
908 if (window->id == windowID) { | |
909 return window; | |
910 } | |
911 } | |
912 } | |
913 return NULL; | |
0 | 914 } |
915 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
916 SDL_VideoDisplay * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
917 SDL_GetDisplayFromWindow(SDL_Window * window) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
918 { |
2753 | 919 if (!_this) { |
920 SDL_UninitializedVideo(); | |
921 return NULL; | |
922 } | |
923 if (!window) { | |
924 return NULL; | |
925 } | |
926 return &_this->displays[window->display]; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
927 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
928 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
929 Uint32 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
930 SDL_GetWindowFlags(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
931 { |
2753 | 932 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
933 |
2753 | 934 if (!window) { |
935 return 0; | |
936 } | |
937 return window->flags; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
938 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
939 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
940 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
941 SDL_SetWindowTitle(SDL_WindowID windowID, const char *title) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
942 { |
2753 | 943 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
944 |
2753 | 945 if (!window || title == window->title) { |
946 return; | |
947 } | |
948 if (window->title) { | |
949 SDL_free(window->title); | |
950 } | |
951 if (title) { | |
952 window->title = SDL_strdup(title); | |
953 } else { | |
954 window->title = NULL; | |
955 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
956 |
2753 | 957 if (_this->SetWindowTitle) { |
958 _this->SetWindowTitle(_this, window); | |
959 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
960 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
961 |
2753 | 962 const char * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
963 SDL_GetWindowTitle(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
964 { |
2753 | 965 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
966 |
2753 | 967 if (!window) { |
968 return NULL; | |
969 } | |
970 return window->title; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
971 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
972 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
973 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
974 SDL_SetWindowData(SDL_WindowID windowID, void *userdata) |
0 | 975 { |
2753 | 976 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
977 |
2753 | 978 if (!window) { |
979 return; | |
980 } | |
981 window->userdata = userdata; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
982 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
983 |
2753 | 984 void * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
985 SDL_GetWindowData(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
986 { |
2753 | 987 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
988 |
2753 | 989 if (!window) { |
990 return NULL; | |
991 } | |
992 return window->userdata; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
993 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
994 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
995 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
996 SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
997 { |
2753 | 998 SDL_Window *window = SDL_GetWindowFromID(windowID); |
999 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
0 | 1000 |
2753 | 1001 if (!window) { |
1002 return; | |
1003 } | |
1004 if (x == SDL_WINDOWPOS_CENTERED) { | |
1005 window->x = (display->current_mode.w - window->w) / 2; | |
1006 } else if (x != SDL_WINDOWPOS_UNDEFINED) { | |
1007 window->x = x; | |
1008 } | |
1009 if (y == SDL_WINDOWPOS_CENTERED) { | |
1010 window->y = (display->current_mode.h - window->h) / 2; | |
1011 } else if (y != SDL_WINDOWPOS_UNDEFINED) { | |
1012 window->y = y; | |
1013 } | |
1014 if (_this->SetWindowPosition) { | |
1015 _this->SetWindowPosition(_this, window); | |
1016 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1017 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1018 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1019 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1020 SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1021 { |
2753 | 1022 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1023 |
2753 | 1024 if (!window) { |
1025 return; | |
1026 } | |
1027 if (x) { | |
1028 *x = window->x; | |
1029 } | |
1030 if (y) { | |
1031 *y = window->y; | |
1032 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1033 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1034 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1035 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1036 SDL_SetWindowSize(SDL_WindowID windowID, int w, int h) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1037 { |
2753 | 1038 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 1039 |
2753 | 1040 if (!window) { |
1041 return; | |
1042 } | |
1043 window->w = w; | |
1044 window->h = h; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1045 |
2753 | 1046 if (_this->SetWindowSize) { |
1047 _this->SetWindowSize(_this, window); | |
1048 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1049 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1050 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1051 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1052 SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1053 { |
2753 | 1054 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1055 |
2753 | 1056 if (!window) { |
1057 return; | |
1058 } | |
1059 if (w) { | |
1060 *w = window->w; | |
1061 } | |
1062 if (h) { | |
1063 *h = window->h; | |
1064 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1065 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1066 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1067 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1068 SDL_ShowWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1069 { |
2753 | 1070 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1071 |
2753 | 1072 if (!window || (window->flags & SDL_WINDOW_SHOWN)) { |
1073 return; | |
1074 } | |
1075 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_SHOWN, 0, 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1076 |
2753 | 1077 if (_this->ShowWindow) { |
1078 _this->ShowWindow(_this, window); | |
1079 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1080 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1081 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1082 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1083 SDL_HideWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1084 { |
2753 | 1085 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1086 |
2753 | 1087 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1088 return; | |
1089 } | |
1090 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_HIDDEN, 0, 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1091 |
2753 | 1092 if (_this->HideWindow) { |
1093 _this->HideWindow(_this, window); | |
1094 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1095 } |
0 | 1096 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1097 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1098 SDL_RaiseWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1099 { |
2753 | 1100 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1101 |
2753 | 1102 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1103 return; | |
1104 } | |
1105 if (_this->RaiseWindow) { | |
1106 _this->RaiseWindow(_this, window); | |
1107 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1108 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1109 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1110 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1111 SDL_MaximizeWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1112 { |
2753 | 1113 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1114 |
2753 | 1115 if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) { |
1116 return; | |
1117 } | |
1118 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1119 |
2753 | 1120 if (_this->MaximizeWindow) { |
1121 _this->MaximizeWindow(_this, window); | |
1122 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1123 } |
0 | 1124 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1125 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1126 SDL_MinimizeWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1127 { |
2753 | 1128 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1129 |
2753 | 1130 if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) { |
1131 return; | |
1132 } | |
1133 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MINIMIZED, 0, 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1134 |
2753 | 1135 if (_this->MinimizeWindow) { |
1136 _this->MinimizeWindow(_this, window); | |
1137 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1138 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1139 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1140 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1141 SDL_RestoreWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1142 { |
2753 | 1143 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1144 |
2753 | 1145 if (!window |
1146 || (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { | |
1147 return; | |
1148 } | |
1149 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1150 |
2753 | 1151 if (_this->RestoreWindow) { |
1152 _this->RestoreWindow(_this, window); | |
1153 } | |
0 | 1154 } |
1155 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1156 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1157 SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen) |
0 | 1158 { |
2753 | 1159 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1160 |
2753 | 1161 if (!window) { |
1162 return -1; | |
1163 } | |
1164 if (fullscreen) { | |
1165 fullscreen = SDL_WINDOW_FULLSCREEN; | |
1166 } | |
1167 if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) { | |
1168 return 0; | |
1169 } | |
1170 if (fullscreen) { | |
1171 window->flags |= SDL_WINDOW_FULLSCREEN; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1172 |
2753 | 1173 if (FULLSCREEN_VISIBLE(window)) { |
1174 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1175 |
2753 | 1176 /* Hide any other fullscreen windows */ |
1177 int i; | |
1178 for (i = 0; i < display->num_windows; ++i) { | |
1179 SDL_Window *other = &display->windows[i]; | |
1180 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { | |
1181 SDL_MinimizeWindow(other->id); | |
1182 } | |
1183 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1184 |
2753 | 1185 SDL_SetDisplayMode(&display->fullscreen_mode); |
1186 } | |
1187 } else { | |
1188 window->flags &= ~SDL_WINDOW_FULLSCREEN; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1189 |
2753 | 1190 if (FULLSCREEN_VISIBLE(window)) { |
1191 SDL_SetDisplayMode(NULL); | |
1192 } | |
1193 } | |
1194 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1195 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1196 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1197 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1198 SDL_SetWindowGrab(SDL_WindowID windowID, int mode) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1199 { |
2753 | 1200 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 1201 |
2753 | 1202 if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { |
1203 return; | |
1204 } | |
1205 if (mode) { | |
1206 window->flags |= SDL_WINDOW_INPUT_GRABBED; | |
1207 } else { | |
1208 window->flags &= ~SDL_WINDOW_INPUT_GRABBED; | |
1209 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1210 |
2753 | 1211 if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) { |
1212 _this->SetWindowGrab(_this, window); | |
1213 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1214 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1215 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1216 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1217 SDL_GetWindowGrab(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1218 { |
2753 | 1219 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1220 |
2753 | 1221 if (!window) { |
1222 return 0; | |
1223 } | |
1224 return ((window->flags & SDL_WINDOW_INPUT_GRABBED) != 0); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1225 } |
0 | 1226 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1227 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1228 SDL_OnWindowShown(SDL_Window * window) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1229 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1230 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1231 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1232 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1233 SDL_OnWindowHidden(SDL_Window * window) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1234 { |
0 | 1235 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1236 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1237 void |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1238 SDL_OnWindowResized(SDL_Window * window) |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1239 { |
2753 | 1240 SDL_Renderer *renderer = window->renderer; |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1241 |
2753 | 1242 if (renderer && renderer->DisplayModeChanged) { |
1243 renderer->DisplayModeChanged(renderer); | |
1244 } | |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1245 } |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1246 |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1247 void |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1248 SDL_OnWindowFocusGained(SDL_Window * window) |
0 | 1249 { |
2753 | 1250 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1251 |
2753 | 1252 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1253 SDL_SetDisplayMode(&display->fullscreen_mode); | |
1254 } | |
1255 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1256 _this->SetDisplayGammaRamp(_this, display->gamma); | |
1257 } | |
1258 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { | |
1259 _this->SetWindowGrab(_this, window); | |
1260 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1261 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1262 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1263 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1264 SDL_OnWindowFocusLost(SDL_Window * window) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1265 { |
2753 | 1266 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
0 | 1267 |
2753 | 1268 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1269 SDL_MinimizeWindow(window->id); | |
1270 SDL_SetDisplayMode(NULL); | |
1271 } | |
1272 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1273 _this->SetDisplayGammaRamp(_this, display->saved_gamma); | |
1274 } | |
1275 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { | |
1276 _this->SetWindowGrab(_this, window); | |
1277 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1278 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1279 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1280 SDL_WindowID |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1281 SDL_GetFocusWindow(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1282 { |
2753 | 1283 SDL_VideoDisplay *display; |
1284 int i; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1285 |
2753 | 1286 if (!_this) { |
1287 return 0; | |
1288 } | |
1289 display = &SDL_CurrentDisplay; | |
1290 for (i = 0; i < display->num_windows; ++i) { | |
1291 SDL_Window *window = &display->windows[i]; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1292 |
2753 | 1293 if (window->flags & SDL_WINDOW_INPUT_FOCUS) { |
1294 return window->id; | |
1295 } | |
1296 } | |
1297 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1298 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1299 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1300 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1301 SDL_DestroyWindow(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1302 { |
2753 | 1303 int i, j; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1304 |
2753 | 1305 if (!_this) { |
1306 return; | |
1307 } | |
1308 /* Restore video mode, etc. */ | |
1309 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); | |
0 | 1310 |
2753 | 1311 for (i = 0; i < _this->num_displays; ++i) { |
1312 SDL_VideoDisplay *display = &_this->displays[i]; | |
1313 for (j = 0; j < display->num_windows; ++j) { | |
1314 SDL_Window *window = &display->windows[j]; | |
1315 if (window->id != windowID) { | |
1316 continue; | |
1317 } | |
1318 if (window->title) { | |
1319 SDL_free(window->title); | |
1320 window->title = NULL; | |
1321 } | |
1322 if (window->renderer) { | |
1323 SDL_DestroyRenderer(window->id); | |
1324 window->renderer = NULL; | |
1325 } | |
1326 if (_this->DestroyWindow) { | |
1327 _this->DestroyWindow(_this, window); | |
1328 } | |
1329 if (j != display->num_windows - 1) { | |
1330 SDL_memcpy(&display->windows[i], | |
1331 &display->windows[i + 1], | |
1332 (display->num_windows - i - 1) * sizeof(*window)); | |
1333 } | |
1334 --display->num_windows; | |
1335 return; | |
1336 } | |
1337 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1338 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1339 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1340 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1341 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1342 { |
2753 | 1343 SDL_VideoDisplay *display; |
1344 SDL_RenderDriver *render_drivers; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1345 |
2753 | 1346 if (displayIndex >= _this->num_displays) { |
1347 return; | |
1348 } | |
1349 display = &_this->displays[displayIndex]; | |
2119
9341a884a4d9
Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents:
2075
diff
changeset
|
1350 |
2753 | 1351 render_drivers = |
1352 SDL_realloc(display->render_drivers, | |
1353 (display->num_render_drivers + | |
1354 1) * sizeof(*render_drivers)); | |
1355 if (render_drivers) { | |
1356 render_drivers[display->num_render_drivers] = *driver; | |
1357 display->render_drivers = render_drivers; | |
1358 display->num_render_drivers++; | |
1359 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1360 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1361 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1362 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1363 SDL_GetNumRenderDrivers(void) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1364 { |
2753 | 1365 if (_this) { |
1366 return SDL_CurrentDisplay.num_render_drivers; | |
1367 } | |
1368 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1369 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1370 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1371 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1372 SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1373 { |
2753 | 1374 if (!_this) { |
1375 SDL_UninitializedVideo(); | |
1376 return -1; | |
1377 } | |
1378 if (index < 0 || index >= SDL_GetNumRenderDrivers()) { | |
1379 SDL_SetError("index must be in the range of 0 - %d", | |
1380 SDL_GetNumRenderDrivers() - 1); | |
1381 return -1; | |
1382 } | |
1383 *info = SDL_CurrentDisplay.render_drivers[index].info; | |
1384 return 0; | |
0 | 1385 } |
1386 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1387 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1388 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) |
0 | 1389 { |
2753 | 1390 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1391 |
2753 | 1392 if (!window) { |
1393 return 0; | |
1394 } | |
1395 if (index < 0) { | |
1396 const char *override = SDL_getenv("SDL_VIDEO_RENDERER"); | |
1397 int n = SDL_GetNumRenderDrivers(); | |
1398 for (index = 0; index < n; ++index) { | |
1399 SDL_RenderDriver *driver = | |
1400 &SDL_CurrentDisplay.render_drivers[index]; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1401 |
2753 | 1402 if (override) { |
1403 if (SDL_strcasecmp(override, driver->info.name) == 0) { | |
1404 break; | |
1405 } | |
1406 } else { | |
1407 if ((driver->info.flags & flags) == flags) { | |
1408 break; | |
1409 } | |
1410 } | |
1411 } | |
1412 if (index == n) { | |
1413 SDL_SetError("Couldn't find matching render driver"); | |
1414 return -1; | |
1415 } | |
1416 } | |
1417 if (index >= SDL_GetNumRenderDrivers()) { | |
1418 SDL_SetError("index must be -1 or in the range of 0 - %d", | |
1419 SDL_GetNumRenderDrivers() - 1); | |
1420 return -1; | |
1421 } | |
1422 /* Free any existing renderer */ | |
1423 SDL_DestroyRenderer(windowID); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1424 |
2753 | 1425 /* Create a new renderer instance */ |
1426 window->renderer = SDL_CurrentDisplay.render_drivers[index] | |
1427 .CreateRenderer(window, flags); | |
1428 SDL_SelectRenderer(window->id); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1429 |
2753 | 1430 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1431 } |
0 | 1432 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1433 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1434 SDL_SelectRenderer(SDL_WindowID windowID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1435 { |
2753 | 1436 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1437 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1438 |
2753 | 1439 if (!window || !window->renderer) { |
1440 return -1; | |
1441 } | |
1442 renderer = window->renderer; | |
1443 if (renderer && renderer->ActivateRenderer) { | |
1444 if (renderer->ActivateRenderer(renderer) < 0) { | |
1445 return -1; | |
1446 } | |
1447 } | |
1448 SDL_CurrentDisplay.current_renderer = renderer; | |
1449 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1450 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1451 |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1452 int |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1453 SDL_GetRendererInfo(SDL_RendererInfo * info) |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1454 { |
2753 | 1455 if (!_this) { |
1456 SDL_UninitializedVideo(); | |
1457 return -1; | |
1458 } | |
1459 if (!SDL_CurrentDisplay.current_renderer) { | |
1460 SDL_SetError("There is no current renderer"); | |
1461 return -1; | |
1462 } | |
1463 *info = SDL_CurrentDisplay.current_renderer->info; | |
1464 return 0; | |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1465 } |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1466 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1467 SDL_TextureID |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1468 SDL_CreateTexture(Uint32 format, int access, int w, int h) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1469 { |
2753 | 1470 int hash; |
1471 SDL_Renderer *renderer; | |
1472 SDL_Texture *texture; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1473 |
2753 | 1474 if (!_this) { |
1475 SDL_UninitializedVideo(); | |
1476 return 0; | |
1477 } | |
1478 renderer = SDL_CurrentDisplay.current_renderer; | |
1479 if (!renderer || !renderer->CreateTexture) { | |
1480 return 0; | |
1481 } | |
1482 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); | |
1483 if (!texture) { | |
1484 SDL_OutOfMemory(); | |
1485 return 0; | |
1486 } | |
1487 texture->id = _this->next_object_id++; | |
1488 texture->format = format; | |
1489 texture->access = access; | |
1490 texture->w = w; | |
1491 texture->h = h; | |
1492 texture->r = 255; | |
1493 texture->g = 255; | |
1494 texture->b = 255; | |
1495 texture->a = 255; | |
1496 texture->renderer = renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1497 |
2753 | 1498 if (renderer->CreateTexture(renderer, texture) < 0) { |
1499 if (renderer->DestroyTexture) { | |
1500 renderer->DestroyTexture(renderer, texture); | |
1501 } | |
1502 SDL_free(texture); | |
1503 return 0; | |
1504 } | |
1505 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1506 texture->next = SDL_CurrentDisplay.textures[hash]; | |
1507 SDL_CurrentDisplay.textures[hash] = texture; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1508 |
2753 | 1509 return texture->id; |
0 | 1510 } |
1511 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1512 SDL_TextureID |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1513 SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) |
0 | 1514 { |
2753 | 1515 SDL_TextureID textureID; |
1516 SDL_PixelFormat *fmt; | |
1517 int bpp; | |
1518 Uint32 Rmask, Gmask, Bmask, Amask; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1519 |
2753 | 1520 if (!surface) { |
1521 SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); | |
1522 return 0; | |
1523 } | |
1524 fmt = surface->format; | |
0 | 1525 |
2753 | 1526 if (format) { |
1527 if (!SDL_PixelFormatEnumToMasks | |
1528 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { | |
1529 SDL_SetError("Unknown pixel format"); | |
1530 return 0; | |
1531 } | |
1532 } else { | |
1533 if (surface->format->Amask | |
1534 || !(surface->map->info.flags & | |
1535 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) { | |
1536 bpp = fmt->BitsPerPixel; | |
1537 Rmask = fmt->Rmask; | |
1538 Gmask = fmt->Gmask; | |
1539 Bmask = fmt->Bmask; | |
1540 Amask = fmt->Amask; | |
1541 } else { | |
1542 /* Need a format with alpha */ | |
1543 bpp = 32; | |
1544 Rmask = 0x00FF0000; | |
1545 Gmask = 0x0000FF00; | |
1546 Bmask = 0x000000FF; | |
1547 Amask = 0xFF000000; | |
1548 } | |
1549 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); | |
1550 if (!format) { | |
1551 SDL_SetError("Unknown pixel format"); | |
1552 return 0; | |
1553 } | |
1554 } | |
0 | 1555 |
2753 | 1556 textureID = |
1557 SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, | |
1558 surface->h); | |
1559 if (!textureID) { | |
1560 return 0; | |
1561 } | |
1562 if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask | |
1563 && Bmask == fmt->Bmask && Amask == fmt->Amask) { | |
1564 if (SDL_MUSTLOCK(surface)) { | |
1565 if (SDL_LockSurface(surface) < 0) { | |
1566 SDL_DestroyTexture(textureID); | |
1567 return 0; | |
1568 } | |
1569 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1570 surface->pitch); | |
1571 SDL_UnlockSurface(surface); | |
1572 } else { | |
1573 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1574 surface->pitch); | |
1575 } | |
1576 } else { | |
1577 SDL_PixelFormat *dst_fmt; | |
1578 SDL_Surface *dst = NULL; | |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1579 |
2753 | 1580 /* Set up a destination surface for the texture update */ |
1581 dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); | |
1582 if (dst_fmt) { | |
1583 if (SDL_ISPIXELFORMAT_INDEXED(format)) { | |
1584 dst_fmt->palette = | |
1585 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); | |
1586 if (dst_fmt->palette) { | |
1587 /* | |
1588 * FIXME: Should we try to copy | |
1589 * fmt->palette? | |
1590 */ | |
1591 SDL_DitherColors(dst_fmt->palette->colors, | |
1592 SDL_BITSPERPIXEL(format)); | |
1593 } | |
1594 } | |
1595 dst = SDL_ConvertSurface(surface, dst_fmt, 0); | |
1596 if (dst) { | |
1597 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); | |
1598 SDL_FreeSurface(dst); | |
1599 } | |
1600 if (dst_fmt->palette) { | |
1601 SDL_FreePalette(dst_fmt->palette); | |
1602 } | |
1603 SDL_FreeFormat(dst_fmt); | |
1604 } | |
1605 if (!dst) { | |
1606 SDL_DestroyTexture(textureID); | |
1607 return 0; | |
1608 } | |
1609 } | |
2743
453ec0c21f6f
Rolling back changes to revision 4071 ... made some mistakes, will try merging work again.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2740
diff
changeset
|
1610 |
2753 | 1611 if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { |
1612 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, | |
1613 fmt->palette->ncolors); | |
1614 } | |
1615 return textureID; | |
0 | 1616 } |
1617 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1618 static __inline__ SDL_Texture * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1619 SDL_GetTextureFromID(SDL_TextureID textureID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1620 { |
2753 | 1621 int hash; |
1622 SDL_Texture *texture; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1623 |
2753 | 1624 if (!_this) { |
1625 return NULL; | |
1626 } | |
1627 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1628 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
1629 texture = texture->next) { | |
1630 if (texture->id == textureID) { | |
1631 return texture; | |
1632 } | |
1633 } | |
1634 return NULL; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1635 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1636 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1637 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1638 SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access, |
2753 | 1639 int *w, int *h) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1640 { |
2753 | 1641 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1642 |
2753 | 1643 if (!texture) { |
1644 return -1; | |
1645 } | |
1646 if (format) { | |
1647 *format = texture->format; | |
1648 } | |
1649 if (access) { | |
1650 *access = texture->access; | |
1651 } | |
1652 if (w) { | |
1653 *w = texture->w; | |
1654 } | |
1655 if (h) { | |
1656 *h = texture->h; | |
1657 } | |
1658 return 0; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1659 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1660 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1661 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1662 SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch) |
0 | 1663 { |
2753 | 1664 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1665 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1666 |
2753 | 1667 if (!texture) { |
1668 return -1; | |
1669 } | |
1670 renderer = texture->renderer; | |
1671 if (!renderer->QueryTexturePixels) { | |
1672 return -1; | |
1673 } | |
1674 return renderer->QueryTexturePixels(renderer, texture, pixels, pitch); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1675 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1676 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1677 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1678 SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, |
2753 | 1679 int firstcolor, int ncolors) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1680 { |
2753 | 1681 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1682 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1683 |
2753 | 1684 if (!texture) { |
1685 return -1; | |
1686 } | |
1687 renderer = texture->renderer; | |
1688 if (!renderer->SetTexturePalette) { | |
1689 return -1; | |
1690 } | |
1691 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, | |
1692 ncolors); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1693 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1694 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1695 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1696 SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, |
2753 | 1697 int firstcolor, int ncolors) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1698 { |
2753 | 1699 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1700 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1701 |
2753 | 1702 if (!texture) { |
1703 return -1; | |
1704 } | |
1705 renderer = texture->renderer; | |
1706 if (!renderer->GetTexturePalette) { | |
1707 return -1; | |
1708 } | |
1709 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, | |
1710 ncolors); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1711 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1712 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1713 int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1714 SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1715 { |
2753 | 1716 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1717 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1718 |
2753 | 1719 if (!texture) { |
1720 return -1; | |
1721 } | |
1722 renderer = texture->renderer; | |
1723 if (!renderer->SetTextureColorMod) { | |
1724 return -1; | |
1725 } | |
1726 if (r < 255 || g < 255 || b < 255) { | |
1727 texture->modMode |= SDL_TEXTUREMODULATE_COLOR; | |
1728 } else { | |
1729 texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; | |
1730 } | |
1731 texture->r = r; | |
1732 texture->g = g; | |
1733 texture->b = b; | |
1734 return renderer->SetTextureColorMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1735 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1736 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1737 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1738 SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g, |
2753 | 1739 Uint8 * b) |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1740 { |
2753 | 1741 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1742 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1743 |
2753 | 1744 if (!texture) { |
1745 return -1; | |
1746 } | |
1747 renderer = texture->renderer; | |
1748 if (r) { | |
1749 *r = texture->r; | |
1750 } | |
1751 if (g) { | |
1752 *g = texture->g; | |
1753 } | |
1754 if (b) { | |
1755 *b = texture->b; | |
1756 } | |
1757 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1758 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1759 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1760 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1761 SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1762 { |
2753 | 1763 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1764 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1765 |
2753 | 1766 if (!texture) { |
1767 return -1; | |
1768 } | |
1769 renderer = texture->renderer; | |
1770 if (!renderer->SetTextureAlphaMod) { | |
1771 return -1; | |
1772 } | |
1773 if (alpha < 255) { | |
1774 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; | |
1775 } else { | |
1776 texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; | |
1777 } | |
1778 texture->a = alpha; | |
1779 return renderer->SetTextureAlphaMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1780 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1781 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1782 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1783 SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1784 { |
2753 | 1785 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1786 |
2753 | 1787 if (!texture) { |
1788 return -1; | |
1789 } | |
1790 if (alpha) { | |
1791 *alpha = texture->a; | |
1792 } | |
1793 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1794 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1795 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1796 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1797 SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1798 { |
2753 | 1799 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1800 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1801 |
2753 | 1802 if (!texture) { |
1803 return -1; | |
1804 } | |
1805 renderer = texture->renderer; | |
1806 if (!renderer->SetTextureBlendMode) { | |
1807 return -1; | |
1808 } | |
1809 texture->blendMode = blendMode; | |
1810 return renderer->SetTextureBlendMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1811 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1812 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1813 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1814 SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1815 { |
2753 | 1816 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1817 |
2753 | 1818 if (!texture) { |
1819 return -1; | |
1820 } | |
1821 if (blendMode) { | |
1822 *blendMode = texture->blendMode; | |
1823 } | |
1824 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1825 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1826 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1827 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1828 SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1829 { |
2753 | 1830 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1831 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1832 |
2753 | 1833 if (!texture) { |
1834 return -1; | |
1835 } | |
1836 renderer = texture->renderer; | |
1837 if (!renderer->SetTextureScaleMode) { | |
1838 return -1; | |
1839 } | |
1840 texture->scaleMode = scaleMode; | |
1841 return renderer->SetTextureScaleMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1842 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1843 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1844 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1845 SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1846 { |
2753 | 1847 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1848 |
2753 | 1849 if (!texture) { |
1850 return -1; | |
1851 } | |
1852 if (scaleMode) { | |
1853 *scaleMode = texture->scaleMode; | |
1854 } | |
1855 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1856 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1857 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1858 int |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1859 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, |
2753 | 1860 const void *pixels, int pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1861 { |
2753 | 1862 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1863 SDL_Renderer *renderer; | |
1864 SDL_Rect full_rect; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1865 |
2753 | 1866 if (!texture) { |
1867 return -1; | |
1868 } | |
1869 renderer = texture->renderer; | |
1870 if (!renderer->UpdateTexture) { | |
1871 return -1; | |
1872 } | |
1873 if (!rect) { | |
1874 full_rect.x = 0; | |
1875 full_rect.y = 0; | |
1876 full_rect.w = texture->w; | |
1877 full_rect.h = texture->h; | |
1878 rect = &full_rect; | |
1879 } | |
1880 return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1881 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1882 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1883 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1884 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, |
2753 | 1885 void **pixels, int *pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1886 { |
2753 | 1887 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1888 SDL_Renderer *renderer; | |
1889 SDL_Rect full_rect; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1890 |
2753 | 1891 if (!texture) { |
1892 return -1; | |
1893 } | |
1894 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
1895 SDL_SetError("SDL_LockTexture(): texture must be streaming"); | |
1896 return -1; | |
1897 } | |
1898 renderer = texture->renderer; | |
1899 if (!renderer->LockTexture) { | |
1900 return -1; | |
1901 } | |
1902 if (!rect) { | |
1903 full_rect.x = 0; | |
1904 full_rect.y = 0; | |
1905 full_rect.w = texture->w; | |
1906 full_rect.h = texture->h; | |
1907 rect = &full_rect; | |
1908 } | |
1909 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels, | |
1910 pitch); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1911 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1912 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1913 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1914 SDL_UnlockTexture(SDL_TextureID textureID) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1915 { |
2753 | 1916 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1917 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1918 |
2753 | 1919 if (!texture) { |
1920 return; | |
1921 } | |
1922 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
1923 return; | |
1924 } | |
1925 renderer = texture->renderer; | |
1926 if (!renderer->UnlockTexture) { | |
1927 return; | |
1928 } | |
1929 renderer->UnlockTexture(renderer, texture); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1930 } |
0 | 1931 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1932 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1933 SDL_DirtyTexture(SDL_TextureID textureID, int numrects, |
2753 | 1934 const SDL_Rect * rects) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1935 { |
2753 | 1936 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1937 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1938 |
2753 | 1939 if (!texture) { |
1940 return; | |
1941 } | |
1942 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
1943 return; | |
1944 } | |
1945 renderer = texture->renderer; | |
1946 if (!renderer->DirtyTexture) { | |
1947 return; | |
1948 } | |
1949 renderer->DirtyTexture(renderer, texture, numrects, rects); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1950 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1951 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1952 int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1953 SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1954 { |
2753 | 1955 SDL_Renderer *renderer; |
1956 SDL_Window *window; | |
1957 SDL_Rect real_rect; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1958 |
2753 | 1959 if (!_this) { |
1960 SDL_UninitializedVideo(); | |
1961 return -1; | |
1962 } | |
1963 renderer = SDL_CurrentDisplay.current_renderer; | |
1964 if (!renderer || !renderer->RenderFill) { | |
1965 return -1; | |
1966 } | |
1967 window = SDL_GetWindowFromID(renderer->window); | |
1968 real_rect.x = 0; | |
1969 real_rect.y = 0; | |
1970 real_rect.w = window->w; | |
1971 real_rect.h = window->h; | |
1972 if (rect) { | |
1973 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
1974 return 0; | |
1975 } | |
1976 } | |
1977 return renderer->RenderFill(renderer, r, g, b, a, &real_rect); | |
0 | 1978 } |
1979 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1980 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1981 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, |
2753 | 1982 const SDL_Rect * dstrect) |
0 | 1983 { |
2753 | 1984 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985 SDL_Renderer *renderer; | |
1986 SDL_Window *window; | |
1987 SDL_Rect real_srcrect; | |
1988 SDL_Rect real_dstrect; | |
0 | 1989 |
2753 | 1990 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { |
1991 return -1; | |
1992 } | |
1993 renderer = SDL_CurrentDisplay.current_renderer; | |
1994 if (!renderer || !renderer->RenderCopy) { | |
1995 return -1; | |
1996 } | |
1997 window = SDL_GetWindowFromID(renderer->window); | |
1998 if (srcrect) { | |
1999 real_srcrect = *srcrect; | |
2000 } else { | |
2001 real_srcrect.x = 0; | |
2002 real_srcrect.y = 0; | |
2003 real_srcrect.w = texture->w; | |
2004 real_srcrect.h = texture->h; | |
2005 } | |
2006 if (dstrect) { | |
2007 real_dstrect = *dstrect; | |
2008 } else { | |
2009 real_dstrect.x = 0; | |
2010 real_dstrect.y = 0; | |
2011 real_dstrect.w = window->w; | |
2012 real_dstrect.h = window->h; | |
2013 } | |
0 | 2014 |
2753 | 2015 return renderer->RenderCopy(renderer, texture, &real_srcrect, |
2016 &real_dstrect); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2017 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2018 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2019 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2020 SDL_RenderPresent(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2021 { |
2753 | 2022 SDL_Renderer *renderer; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2023 |
2753 | 2024 if (!_this) { |
2025 SDL_UninitializedVideo(); | |
2026 return; | |
2027 } | |
2028 renderer = SDL_CurrentDisplay.current_renderer; | |
2029 if (!renderer || !renderer->RenderPresent) { | |
2030 return; | |
2031 } | |
2032 renderer->RenderPresent(renderer); | |
0 | 2033 } |
2034 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2035 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2036 SDL_DestroyTexture(SDL_TextureID textureID) |
0 | 2037 { |
2753 | 2038 int hash; |
2039 SDL_Texture *prev, *texture; | |
2040 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2041 |
2753 | 2042 if (!_this) { |
2043 SDL_UninitializedVideo(); | |
2044 return; | |
2045 } | |
2046 /* Look up the texture in the hash table */ | |
2047 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
2048 prev = NULL; | |
2049 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
2050 prev = texture, texture = texture->next) { | |
2051 if (texture->id == textureID) { | |
2052 break; | |
2053 } | |
2054 } | |
2055 if (!texture) { | |
2056 return; | |
2057 } | |
2058 /* Unlink the texture from the list */ | |
2059 if (prev) { | |
2060 prev->next = texture->next; | |
2061 } else { | |
2062 SDL_CurrentDisplay.textures[hash] = texture->next; | |
2063 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2064 |
2753 | 2065 /* Free the texture */ |
2066 renderer = texture->renderer; | |
2067 renderer->DestroyTexture(renderer, texture); | |
2068 SDL_free(texture); | |
0 | 2069 } |
2070 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2071 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2072 SDL_DestroyRenderer(SDL_WindowID windowID) |
0 | 2073 { |
2753 | 2074 SDL_Window *window = SDL_GetWindowFromID(windowID); |
2075 SDL_Renderer *renderer; | |
2076 int i; | |
0 | 2077 |
2753 | 2078 if (!window) { |
2079 return; | |
2080 } | |
2081 renderer = window->renderer; | |
2082 if (!renderer) { | |
2083 return; | |
2084 } | |
2085 /* Free existing textures for this renderer */ | |
2086 for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) { | |
2087 SDL_Texture *texture; | |
2088 SDL_Texture *prev = NULL; | |
2089 SDL_Texture *next; | |
2090 for (texture = SDL_CurrentDisplay.textures[i]; texture; | |
2091 texture = next) { | |
2092 next = texture->next; | |
2093 if (texture->renderer == renderer) { | |
2094 if (prev) { | |
2095 prev->next = next; | |
2096 } else { | |
2097 SDL_CurrentDisplay.textures[i] = next; | |
2098 } | |
2099 renderer->DestroyTexture(renderer, texture); | |
2100 SDL_free(texture); | |
2101 } else { | |
2102 prev = texture; | |
2103 } | |
2104 } | |
2105 } | |
0 | 2106 |
2753 | 2107 /* Free the renderer instance */ |
2108 renderer->DestroyRenderer(renderer); | |
0 | 2109 |
2753 | 2110 /* Clear references */ |
2111 window->renderer = NULL; | |
2112 if (SDL_CurrentDisplay.current_renderer == renderer) { | |
2113 SDL_CurrentDisplay.current_renderer = NULL; | |
2114 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2115 } |
0 | 2116 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2117 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2118 SDL_VideoQuit(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2119 { |
2753 | 2120 int i, j; |
0 | 2121 |
2753 | 2122 if (!_this) { |
2123 return; | |
2124 } | |
2125 /* Halt event processing before doing anything else */ | |
2126 SDL_StopEventLoop(); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2127 |
2753 | 2128 /* Clean up the system video */ |
2129 for (i = _this->num_displays; i--;) { | |
2130 SDL_VideoDisplay *display = &_this->displays[i]; | |
2131 for (j = display->num_windows; j--;) { | |
2132 SDL_DestroyWindow(display->windows[i].id); | |
2133 } | |
2134 if (display->windows) { | |
2135 SDL_free(display->windows); | |
2136 display->windows = NULL; | |
2137 } | |
2138 display->num_windows = 0; | |
2139 if (display->render_drivers) { | |
2140 SDL_free(display->render_drivers); | |
2141 display->render_drivers = NULL; | |
2142 } | |
2143 display->num_render_drivers = 0; | |
2144 } | |
2145 _this->VideoQuit(_this); | |
0 | 2146 |
2753 | 2147 for (i = _this->num_displays; i--;) { |
2148 SDL_VideoDisplay *display = &_this->displays[i]; | |
2149 for (j = display->num_display_modes; j--;) { | |
2150 if (display->display_modes[j].driverdata) { | |
2151 SDL_free(display->display_modes[j].driverdata); | |
2152 display->display_modes[j].driverdata = NULL; | |
2153 } | |
2154 } | |
2155 if (display->display_modes) { | |
2156 SDL_free(display->display_modes); | |
2157 display->display_modes = NULL; | |
2158 } | |
2159 if (display->desktop_mode.driverdata) { | |
2160 SDL_free(display->desktop_mode.driverdata); | |
2161 display->desktop_mode.driverdata = NULL; | |
2162 } | |
2163 if (display->palette) { | |
2164 SDL_FreePalette(display->palette); | |
2165 display->palette = NULL; | |
2166 } | |
2167 if (display->gamma) { | |
2168 SDL_free(display->gamma); | |
2169 display->gamma = NULL; | |
2170 } | |
2171 if (display->driverdata) { | |
2172 SDL_free(display->driverdata); | |
2173 display->driverdata = NULL; | |
2174 } | |
2175 } | |
2176 if (_this->displays) { | |
2177 SDL_free(_this->displays); | |
2178 _this->displays = NULL; | |
2179 } | |
2180 _this->free(_this); | |
2181 _this = NULL; | |
0 | 2182 } |
2183 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2184 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2185 SDL_GL_LoadLibrary(const char *path) |
0 | 2186 { |
2753 | 2187 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2188 |
2753 | 2189 if (!_this) { |
2190 SDL_UninitializedVideo(); | |
2191 return -1; | |
2192 } | |
2193 if (_this->GL_LoadLibrary) { | |
2194 retval = _this->GL_LoadLibrary(_this, path); | |
2195 } else { | |
2196 SDL_SetError("No dynamic GL support in video driver"); | |
2197 retval = -1; | |
2198 } | |
2199 return (retval); | |
0 | 2200 } |
2201 | |
2753 | 2202 void * |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2203 SDL_GL_GetProcAddress(const char *proc) |
0 | 2204 { |
2753 | 2205 void *func; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2206 |
2753 | 2207 if (!_this) { |
2208 SDL_UninitializedVideo(); | |
2209 return NULL; | |
2210 } | |
2211 func = NULL; | |
2212 if (_this->GL_GetProcAddress) { | |
2213 if (_this->gl_config.driver_loaded) { | |
2214 func = _this->GL_GetProcAddress(_this, proc); | |
2215 } else { | |
2216 SDL_SetError("No GL driver has been loaded"); | |
2217 } | |
2218 } else { | |
2219 SDL_SetError("No dynamic GL support in video driver"); | |
2220 } | |
2221 return func; | |
0 | 2222 } |
2223 | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2224 SDL_bool |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2225 SDL_GL_ExtensionSupported(const char *extension) |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2226 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2227 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2228 const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); |
2229 const char *extensions; | |
2230 const char *start; | |
2231 const char *where, *terminator; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2232 |
2753 | 2233 /* Extension names should not have spaces. */ |
2234 where = SDL_strchr(extension, ' '); | |
2235 if (where || *extension == '\0') { | |
2236 return SDL_FALSE; | |
2237 } | |
2238 /* See if there's an environment variable override */ | |
2239 start = SDL_getenv(extension); | |
2240 if (start && *start == '0') { | |
2241 return SDL_FALSE; | |
2242 } | |
2243 /* Lookup the available extensions */ | |
2244 glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); | |
2245 if (glGetStringFunc) { | |
2246 extensions = (const char *) glGetStringFunc(GL_EXTENSIONS); | |
2247 } else { | |
2248 extensions = NULL; | |
2249 } | |
2250 if (!extensions) { | |
2251 return SDL_FALSE; | |
2252 } | |
2253 /* | |
2254 * It takes a bit of care to be fool-proof about parsing the OpenGL | |
2255 * extensions string. Don't be fooled by sub-strings, etc. | |
2256 */ | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2257 |
2753 | 2258 start = extensions; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2259 |
2753 | 2260 for (;;) { |
2261 where = SDL_strstr(start, extension); | |
2262 if (!where) | |
2263 break; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2264 |
2753 | 2265 terminator = where + SDL_strlen(extension); |
2266 if (where == start || *(where - 1) == ' ') | |
2267 if (*terminator == ' ' || *terminator == '\0') | |
2268 return SDL_TRUE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2269 |
2753 | 2270 start = terminator; |
2271 } | |
2272 return SDL_FALSE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2273 #else |
2753 | 2274 return SDL_FALSE; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2275 #endif |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2276 } |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2277 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2278 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2279 SDL_GL_SetAttribute(SDL_GLattr attr, int value) |
0 | 2280 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2281 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2282 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2283 |
2753 | 2284 if (!_this) { |
2285 SDL_UninitializedVideo(); | |
2286 return -1; | |
2287 } | |
2288 retval = 0; | |
2289 switch (attr) { | |
2290 case SDL_GL_RED_SIZE: | |
2291 _this->gl_config.red_size = value; | |
2292 break; | |
2293 case SDL_GL_GREEN_SIZE: | |
2294 _this->gl_config.green_size = value; | |
2295 break; | |
2296 case SDL_GL_BLUE_SIZE: | |
2297 _this->gl_config.blue_size = value; | |
2298 break; | |
2299 case SDL_GL_ALPHA_SIZE: | |
2300 _this->gl_config.alpha_size = value; | |
2301 break; | |
2302 case SDL_GL_DOUBLEBUFFER: | |
2303 _this->gl_config.double_buffer = value; | |
2304 break; | |
2305 case SDL_GL_BUFFER_SIZE: | |
2306 _this->gl_config.buffer_size = value; | |
2307 break; | |
2308 case SDL_GL_DEPTH_SIZE: | |
2309 _this->gl_config.depth_size = value; | |
2310 break; | |
2311 case SDL_GL_STENCIL_SIZE: | |
2312 _this->gl_config.stencil_size = value; | |
2313 break; | |
2314 case SDL_GL_ACCUM_RED_SIZE: | |
2315 _this->gl_config.accum_red_size = value; | |
2316 break; | |
2317 case SDL_GL_ACCUM_GREEN_SIZE: | |
2318 _this->gl_config.accum_green_size = value; | |
2319 break; | |
2320 case SDL_GL_ACCUM_BLUE_SIZE: | |
2321 _this->gl_config.accum_blue_size = value; | |
2322 break; | |
2323 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2324 _this->gl_config.accum_alpha_size = value; | |
2325 break; | |
2326 case SDL_GL_STEREO: | |
2327 _this->gl_config.stereo = value; | |
2328 break; | |
2329 case SDL_GL_MULTISAMPLEBUFFERS: | |
2330 _this->gl_config.multisamplebuffers = value; | |
2331 break; | |
2332 case SDL_GL_MULTISAMPLESAMPLES: | |
2333 _this->gl_config.multisamplesamples = value; | |
2334 break; | |
2335 case SDL_GL_ACCELERATED_VISUAL: | |
2336 _this->gl_config.accelerated = value; | |
2337 break; | |
2338 case SDL_GL_RETAINED_BACKING: | |
2339 _this->gl_config.retained_backing = value; | |
2340 break; | |
2341 default: | |
2342 SDL_SetError("Unknown OpenGL attribute"); | |
2343 retval = -1; | |
2344 break; | |
2345 } | |
2346 return retval; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2347 #else |
2753 | 2348 SDL_Unsupported(); |
2349 return -1; | |
2350 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 2351 } |
2352 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2353 int |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2354 SDL_GL_GetAttribute(SDL_GLattr attr, int *value) |
0 | 2355 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2356 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2357 void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); |
2358 GLenum attrib = 0; | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2359 |
2753 | 2360 glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); |
2361 if (!glGetIntegervFunc) { | |
2362 return -1; | |
2363 } | |
2364 switch (attr) { | |
2365 case SDL_GL_RETAINED_BACKING: | |
2366 *value = _this->gl_config.retained_backing; | |
2367 return 0; | |
2368 case SDL_GL_RED_SIZE: | |
2369 attrib = GL_RED_BITS; | |
2370 break; | |
2371 case SDL_GL_BLUE_SIZE: | |
2372 attrib = GL_BLUE_BITS; | |
2373 break; | |
2374 case SDL_GL_GREEN_SIZE: | |
2375 attrib = GL_GREEN_BITS; | |
2376 break; | |
2377 case SDL_GL_ALPHA_SIZE: | |
2378 attrib = GL_ALPHA_BITS; | |
2379 break; | |
2380 case SDL_GL_DOUBLEBUFFER: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2381 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2382 attrib = GL_DOUBLEBUFFER; |
2383 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2384 #else |
2753 | 2385 /* |
2386 * I believe double buffering is the only option in OpenGL ES | |
2387 * -- in any case, GL_DOUBLEBUFFER doesn't exist | |
2388 */ | |
2389 *value = 1; | |
2390 return 0; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2391 #endif |
2753 | 2392 case SDL_GL_DEPTH_SIZE: |
2393 attrib = GL_DEPTH_BITS; | |
2394 break; | |
2395 case SDL_GL_STENCIL_SIZE: | |
2396 attrib = GL_STENCIL_BITS; | |
2397 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2398 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2399 case SDL_GL_ACCUM_RED_SIZE: |
2400 attrib = GL_ACCUM_RED_BITS; | |
2401 break; | |
2402 case SDL_GL_ACCUM_GREEN_SIZE: | |
2403 attrib = GL_ACCUM_GREEN_BITS; | |
2404 break; | |
2405 case SDL_GL_ACCUM_BLUE_SIZE: | |
2406 attrib = GL_ACCUM_BLUE_BITS; | |
2407 break; | |
2408 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2409 attrib = GL_ACCUM_ALPHA_BITS; | |
2410 break; | |
2411 case SDL_GL_STEREO: | |
2412 attrib = GL_STEREO; | |
2413 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2414 #else |
2753 | 2415 case SDL_GL_ACCUM_RED_SIZE: |
2416 case SDL_GL_ACCUM_GREEN_SIZE: | |
2417 case SDL_GL_ACCUM_BLUE_SIZE: | |
2418 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2419 case SDL_GL_STEREO: | |
2420 /* none of these are supported in OpenGL ES */ | |
2421 *value = 0; | |
2422 return 0; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2423 #endif |
2753 | 2424 case SDL_GL_MULTISAMPLEBUFFERS: |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2425 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2426 attrib = GL_SAMPLE_BUFFERS_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2427 #else |
2753 | 2428 attrib = GL_SAMPLE_BUFFERS; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2429 #endif |
2753 | 2430 break; |
2431 case SDL_GL_MULTISAMPLESAMPLES: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2432 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2433 attrib = GL_SAMPLES_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2434 #else |
2753 | 2435 attrib = GL_SAMPLES; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2436 #endif |
2753 | 2437 break; |
2438 case SDL_GL_BUFFER_SIZE: | |
2439 { | |
2440 GLint bits = 0; | |
2441 GLint component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2442 |
2753 | 2443 /* |
2444 * there doesn't seem to be a single flag in OpenGL | |
2445 * for this! | |
2446 */ | |
2447 glGetIntegervFunc(GL_RED_BITS, &component); | |
2448 bits += component; | |
2449 glGetIntegervFunc(GL_GREEN_BITS, &component); | |
2450 bits += component; | |
2451 glGetIntegervFunc(GL_BLUE_BITS, &component); | |
2452 bits += component; | |
2453 glGetIntegervFunc(GL_ALPHA_BITS, &component); | |
2454 bits += component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2455 |
2753 | 2456 *value = bits; |
2457 return 0; | |
2458 } | |
2459 case SDL_GL_ACCELERATED_VISUAL: | |
2460 { | |
2461 /* FIXME: How do we get this information? */ | |
2462 *value = (_this->gl_config.accelerated != 0); | |
2463 return 0; | |
2464 } | |
2465 default: | |
2466 SDL_SetError("Unknown OpenGL attribute"); | |
2467 return -1; | |
2468 } | |
0 | 2469 |
2753 | 2470 glGetIntegervFunc(attrib, (GLint *) value); |
2471 return 0; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2472 #else |
2753 | 2473 SDL_Unsupported(); |
2474 return -1; | |
2475 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 2476 } |
2477 | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2478 SDL_GLContext |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2479 SDL_GL_CreateContext(SDL_WindowID windowID) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2480 { |
2753 | 2481 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2482 |
2753 | 2483 if (!window) { |
2484 return NULL; | |
2485 } | |
2486 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
2487 SDL_SetError("The specified window isn't an OpenGL window"); | |
2488 return NULL; | |
2489 } | |
2490 return _this->GL_CreateContext(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2491 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2492 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2493 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2494 SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2495 { |
2753 | 2496 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2497 |
2753 | 2498 if (window && !(window->flags & SDL_WINDOW_OPENGL)) { |
2499 SDL_SetError("The specified window isn't an OpenGL window"); | |
2500 return -1; | |
2501 } | |
2502 if (!context) { | |
2503 window = NULL; | |
2504 } | |
2505 return _this->GL_MakeCurrent(_this, window, context); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2506 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2507 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2508 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2509 SDL_GL_SetSwapInterval(int interval) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2510 { |
2753 | 2511 if (!_this) { |
2512 SDL_UninitializedVideo(); | |
2513 return -1; | |
2514 } | |
2515 if (_this->GL_SetSwapInterval) { | |
2516 return _this->GL_SetSwapInterval(_this, interval); | |
2517 } else { | |
2518 SDL_SetError("Setting the swap interval is not supported"); | |
2519 return -1; | |
2520 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2521 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2522 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2523 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2524 SDL_GL_GetSwapInterval(void) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2525 { |
2753 | 2526 if (!_this) { |
2527 SDL_UninitializedVideo(); | |
2528 return -1; | |
2529 } | |
2530 if (_this->GL_GetSwapInterval) { | |
2531 return _this->GL_GetSwapInterval(_this); | |
2532 } else { | |
2533 SDL_SetError("Getting the swap interval is not supported"); | |
2534 return -1; | |
2535 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2536 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2537 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2538 void |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2539 SDL_GL_SwapWindow(SDL_WindowID windowID) |
0 | 2540 { |
2753 | 2541 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2542 |
2753 | 2543 if (!window) { |
2544 return; | |
2545 } | |
2546 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
2547 SDL_SetError("The specified window isn't an OpenGL window"); | |
2548 return; | |
2549 } | |
2550 _this->GL_SwapWindow(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2551 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2552 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2553 void |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2554 SDL_GL_DeleteContext(SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2555 { |
2753 | 2556 if (!_this || !context) { |
2557 return; | |
2558 } | |
2559 _this->GL_MakeCurrent(_this, NULL, NULL); | |
2560 _this->GL_DeleteContext(_this, context); | |
0 | 2561 } |
2562 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2563 #if 0 // FIXME |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2564 /* |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2565 * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2566 * & 2 for alpha channel. |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2567 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2568 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2569 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) |
0 | 2570 { |
2753 | 2571 int x, y; |
2572 Uint32 colorkey; | |
0 | 2573 #define SET_MASKBIT(icon, x, y, mask) \ |
2574 mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) | |
2575 | |
2753 | 2576 colorkey = icon->format->colorkey; |
2577 switch (icon->format->BytesPerPixel) { | |
2578 case 1: | |
2579 { | |
2580 Uint8 *pixels; | |
2581 for (y = 0; y < icon->h; ++y) { | |
2582 pixels = (Uint8 *) icon->pixels + y * icon->pitch; | |
2583 for (x = 0; x < icon->w; ++x) { | |
2584 if (*pixels++ == colorkey) { | |
2585 SET_MASKBIT(icon, x, y, mask); | |
2586 } | |
2587 } | |
2588 } | |
2589 } | |
2590 break; | |
0 | 2591 |
2753 | 2592 case 2: |
2593 { | |
2594 Uint16 *pixels; | |
2595 for (y = 0; y < icon->h; ++y) { | |
2596 pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2; | |
2597 for (x = 0; x < icon->w; ++x) { | |
2598 if ((flags & 1) && *pixels == colorkey) { | |
2599 SET_MASKBIT(icon, x, y, mask); | |
2600 } else if ((flags & 2) | |
2601 && (*pixels & icon->format->Amask) == 0) { | |
2602 SET_MASKBIT(icon, x, y, mask); | |
2603 } | |
2604 pixels++; | |
2605 } | |
2606 } | |
2607 } | |
2608 break; | |
0 | 2609 |
2753 | 2610 case 4: |
2611 { | |
2612 Uint32 *pixels; | |
2613 for (y = 0; y < icon->h; ++y) { | |
2614 pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4; | |
2615 for (x = 0; x < icon->w; ++x) { | |
2616 if ((flags & 1) && *pixels == colorkey) { | |
2617 SET_MASKBIT(icon, x, y, mask); | |
2618 } else if ((flags & 2) | |
2619 && (*pixels & icon->format->Amask) == 0) { | |
2620 SET_MASKBIT(icon, x, y, mask); | |
2621 } | |
2622 pixels++; | |
2623 } | |
2624 } | |
2625 } | |
2626 break; | |
2627 } | |
0 | 2628 } |
2629 | |
2630 /* | |
2631 * Sets the window manager icon for the display window. | |
2632 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2633 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2634 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) |
0 | 2635 { |
2753 | 2636 if (icon && _this->SetIcon) { |
2637 /* Generate a mask if necessary, and create the icon! */ | |
2638 if (mask == NULL) { | |
2639 int mask_len = icon->h * (icon->w + 7) / 8; | |
2640 int flags = 0; | |
2641 mask = (Uint8 *) SDL_malloc(mask_len); | |
2642 if (mask == NULL) { | |
2643 return; | |
2644 } | |
2645 SDL_memset(mask, ~0, mask_len); | |
2646 if (icon->flags & SDL_SRCCOLORKEY) | |
2647 flags |= 1; | |
2648 if (icon->flags & SDL_SRCALPHA) | |
2649 flags |= 2; | |
2650 if (flags) { | |
2651 CreateMaskFromColorKeyOrAlpha(icon, mask, flags); | |
2652 } | |
2653 _this->SetIcon(_this, icon, mask); | |
2654 SDL_free(mask); | |
2655 } else { | |
2656 _this->SetIcon(_this, icon, mask); | |
2657 } | |
2658 } | |
0 | 2659 } |
2660 #endif | |
2661 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2662 SDL_bool |
2753 | 2663 SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info) |
0 | 2664 { |
2753 | 2665 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 2666 |
2753 | 2667 if (!window || !_this->GetWindowWMInfo) { |
2668 return SDL_FALSE; | |
2669 } | |
2670 return (_this->GetWindowWMInfo(_this, window, info)); | |
0 | 2671 } |
2672 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2673 /* vi: set ts=4 sw=4 expandtab: */ |