Mercurial > sdl-ios-xcode
annotate src/video/SDL_video.c @ 2849:523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Just query the window size when we care about it. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 07 Dec 2008 21:53:28 +0000 |
parents | e841aa93e6be |
children | 99210400e8b9 |
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 } | |
2849
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1049 SDL_OnWindowResized(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
|
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 |
c121d94672cb
SDL 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 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
|
1053 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
|
1054 { |
2753 | 1055 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
|
1056 |
2753 | 1057 if (!window) { |
2849
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1058 if (w) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1059 *w = window->w; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1060 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1061 if (h) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1062 *h = window->h; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1063 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1064 } else { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1065 if (w) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1066 *w = 0; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1067 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1068 if (h) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1069 *h = 0; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1070 } |
2753 | 1071 } |
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
|
1072 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1073 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1074 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
|
1075 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
|
1076 { |
2753 | 1077 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
|
1078 |
2753 | 1079 if (!window || (window->flags & SDL_WINDOW_SHOWN)) { |
1080 return; | |
1081 } | |
1082 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
|
1083 |
2753 | 1084 if (_this->ShowWindow) { |
1085 _this->ShowWindow(_this, window); | |
1086 } | |
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
|
1087 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1088 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1089 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
|
1090 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
|
1091 { |
2753 | 1092 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
|
1093 |
2753 | 1094 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1095 return; | |
1096 } | |
1097 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
|
1098 |
2753 | 1099 if (_this->HideWindow) { |
1100 _this->HideWindow(_this, window); | |
1101 } | |
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
|
1102 } |
0 | 1103 |
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
|
1104 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
|
1105 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
|
1106 { |
2753 | 1107 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
|
1108 |
2753 | 1109 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1110 return; | |
1111 } | |
1112 if (_this->RaiseWindow) { | |
1113 _this->RaiseWindow(_this, window); | |
1114 } | |
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
|
1115 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1116 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1117 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
|
1118 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
|
1119 { |
2753 | 1120 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
|
1121 |
2753 | 1122 if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) { |
1123 return; | |
1124 } | |
1125 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
|
1126 |
2753 | 1127 if (_this->MaximizeWindow) { |
1128 _this->MaximizeWindow(_this, window); | |
1129 } | |
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
|
1130 } |
0 | 1131 |
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
|
1132 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
|
1133 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
|
1134 { |
2753 | 1135 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
|
1136 |
2753 | 1137 if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) { |
1138 return; | |
1139 } | |
1140 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
|
1141 |
2753 | 1142 if (_this->MinimizeWindow) { |
1143 _this->MinimizeWindow(_this, window); | |
1144 } | |
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
|
1145 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1146 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1147 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
|
1148 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
|
1149 { |
2753 | 1150 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
|
1151 |
2753 | 1152 if (!window |
1153 || (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { | |
1154 return; | |
1155 } | |
1156 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
|
1157 |
2753 | 1158 if (_this->RestoreWindow) { |
1159 _this->RestoreWindow(_this, window); | |
1160 } | |
0 | 1161 } |
1162 | |
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
|
1163 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
|
1164 SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen) |
0 | 1165 { |
2753 | 1166 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
|
1167 |
2753 | 1168 if (!window) { |
1169 return -1; | |
1170 } | |
1171 if (fullscreen) { | |
1172 fullscreen = SDL_WINDOW_FULLSCREEN; | |
1173 } | |
1174 if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) { | |
1175 return 0; | |
1176 } | |
1177 if (fullscreen) { | |
1178 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
|
1179 |
2753 | 1180 if (FULLSCREEN_VISIBLE(window)) { |
1181 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
|
1182 |
2753 | 1183 /* Hide any other fullscreen windows */ |
1184 int i; | |
1185 for (i = 0; i < display->num_windows; ++i) { | |
1186 SDL_Window *other = &display->windows[i]; | |
1187 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { | |
1188 SDL_MinimizeWindow(other->id); | |
1189 } | |
1190 } | |
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
|
1191 |
2753 | 1192 SDL_SetDisplayMode(&display->fullscreen_mode); |
1193 } | |
1194 } else { | |
1195 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
|
1196 |
2753 | 1197 if (FULLSCREEN_VISIBLE(window)) { |
1198 SDL_SetDisplayMode(NULL); | |
1199 } | |
1200 } | |
1201 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
|
1202 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1203 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1204 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
|
1205 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
|
1206 { |
2753 | 1207 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 1208 |
2753 | 1209 if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { |
1210 return; | |
1211 } | |
1212 if (mode) { | |
1213 window->flags |= SDL_WINDOW_INPUT_GRABBED; | |
1214 } else { | |
1215 window->flags &= ~SDL_WINDOW_INPUT_GRABBED; | |
1216 } | |
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
|
1217 |
2753 | 1218 if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) { |
1219 _this->SetWindowGrab(_this, window); | |
1220 } | |
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
|
1221 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1222 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1223 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
|
1224 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
|
1225 { |
2753 | 1226 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
|
1227 |
2753 | 1228 if (!window) { |
1229 return 0; | |
1230 } | |
1231 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
|
1232 } |
0 | 1233 |
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
|
1234 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
|
1235 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
|
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 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1238 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1239 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
|
1240 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
|
1241 { |
0 | 1242 } |
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
|
1243 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1244 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
|
1245 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
|
1246 { |
2753 | 1247 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
|
1248 |
2753 | 1249 if (renderer && renderer->DisplayModeChanged) { |
1250 renderer->DisplayModeChanged(renderer); | |
1251 } | |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1252 } |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1253 |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1254 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
|
1255 SDL_OnWindowFocusGained(SDL_Window * window) |
0 | 1256 { |
2753 | 1257 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
|
1258 |
2753 | 1259 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1260 SDL_SetDisplayMode(&display->fullscreen_mode); | |
1261 } | |
1262 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1263 _this->SetDisplayGammaRamp(_this, display->gamma); | |
1264 } | |
1265 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { | |
1266 _this->SetWindowGrab(_this, window); | |
1267 } | |
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
|
1268 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1269 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1270 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
|
1271 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
|
1272 { |
2753 | 1273 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
0 | 1274 |
2753 | 1275 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1276 SDL_MinimizeWindow(window->id); | |
1277 SDL_SetDisplayMode(NULL); | |
1278 } | |
1279 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1280 _this->SetDisplayGammaRamp(_this, display->saved_gamma); | |
1281 } | |
1282 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { | |
1283 _this->SetWindowGrab(_this, window); | |
1284 } | |
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 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1286 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1287 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
|
1288 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
|
1289 { |
2753 | 1290 SDL_VideoDisplay *display; |
1291 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
|
1292 |
2753 | 1293 if (!_this) { |
1294 return 0; | |
1295 } | |
1296 display = &SDL_CurrentDisplay; | |
1297 for (i = 0; i < display->num_windows; ++i) { | |
1298 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
|
1299 |
2753 | 1300 if (window->flags & SDL_WINDOW_INPUT_FOCUS) { |
1301 return window->id; | |
1302 } | |
1303 } | |
1304 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
|
1305 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1306 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1307 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
|
1308 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
|
1309 { |
2753 | 1310 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
|
1311 |
2753 | 1312 if (!_this) { |
1313 return; | |
1314 } | |
1315 /* Restore video mode, etc. */ | |
1316 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); | |
0 | 1317 |
2753 | 1318 for (i = 0; i < _this->num_displays; ++i) { |
1319 SDL_VideoDisplay *display = &_this->displays[i]; | |
1320 for (j = 0; j < display->num_windows; ++j) { | |
1321 SDL_Window *window = &display->windows[j]; | |
1322 if (window->id != windowID) { | |
1323 continue; | |
1324 } | |
1325 if (window->title) { | |
1326 SDL_free(window->title); | |
1327 window->title = NULL; | |
1328 } | |
1329 if (window->renderer) { | |
1330 SDL_DestroyRenderer(window->id); | |
1331 window->renderer = NULL; | |
1332 } | |
1333 if (_this->DestroyWindow) { | |
1334 _this->DestroyWindow(_this, window); | |
1335 } | |
1336 if (j != display->num_windows - 1) { | |
1337 SDL_memcpy(&display->windows[i], | |
1338 &display->windows[i + 1], | |
1339 (display->num_windows - i - 1) * sizeof(*window)); | |
1340 } | |
1341 --display->num_windows; | |
1342 return; | |
1343 } | |
1344 } | |
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 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1346 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1347 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
|
1348 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
|
1349 { |
2753 | 1350 SDL_VideoDisplay *display; |
1351 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
|
1352 |
2753 | 1353 if (displayIndex >= _this->num_displays) { |
1354 return; | |
1355 } | |
1356 display = &_this->displays[displayIndex]; | |
2119
9341a884a4d9
Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents:
2075
diff
changeset
|
1357 |
2753 | 1358 render_drivers = |
1359 SDL_realloc(display->render_drivers, | |
1360 (display->num_render_drivers + | |
1361 1) * sizeof(*render_drivers)); | |
1362 if (render_drivers) { | |
1363 render_drivers[display->num_render_drivers] = *driver; | |
1364 display->render_drivers = render_drivers; | |
1365 display->num_render_drivers++; | |
1366 } | |
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
|
1367 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1368 |
c121d94672cb
SDL 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 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1370 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
|
1371 { |
2753 | 1372 if (_this) { |
1373 return SDL_CurrentDisplay.num_render_drivers; | |
1374 } | |
1375 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
|
1376 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1377 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1378 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1379 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
|
1380 { |
2753 | 1381 if (!_this) { |
1382 SDL_UninitializedVideo(); | |
1383 return -1; | |
1384 } | |
1385 if (index < 0 || index >= SDL_GetNumRenderDrivers()) { | |
1386 SDL_SetError("index must be in the range of 0 - %d", | |
1387 SDL_GetNumRenderDrivers() - 1); | |
1388 return -1; | |
1389 } | |
1390 *info = SDL_CurrentDisplay.render_drivers[index].info; | |
1391 return 0; | |
0 | 1392 } |
1393 | |
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
|
1394 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
|
1395 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) |
0 | 1396 { |
2753 | 1397 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
|
1398 |
2753 | 1399 if (!window) { |
1400 return 0; | |
1401 } | |
1402 if (index < 0) { | |
1403 const char *override = SDL_getenv("SDL_VIDEO_RENDERER"); | |
1404 int n = SDL_GetNumRenderDrivers(); | |
1405 for (index = 0; index < n; ++index) { | |
1406 SDL_RenderDriver *driver = | |
1407 &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
|
1408 |
2753 | 1409 if (override) { |
1410 if (SDL_strcasecmp(override, driver->info.name) == 0) { | |
1411 break; | |
1412 } | |
1413 } else { | |
1414 if ((driver->info.flags & flags) == flags) { | |
1415 break; | |
1416 } | |
1417 } | |
1418 } | |
1419 if (index == n) { | |
1420 SDL_SetError("Couldn't find matching render driver"); | |
1421 return -1; | |
1422 } | |
1423 } | |
1424 if (index >= SDL_GetNumRenderDrivers()) { | |
1425 SDL_SetError("index must be -1 or in the range of 0 - %d", | |
1426 SDL_GetNumRenderDrivers() - 1); | |
1427 return -1; | |
1428 } | |
1429 /* Free any existing renderer */ | |
1430 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
|
1431 |
2753 | 1432 /* Create a new renderer instance */ |
1433 window->renderer = SDL_CurrentDisplay.render_drivers[index] | |
1434 .CreateRenderer(window, flags); | |
1435 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
|
1436 |
2753 | 1437 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
|
1438 } |
0 | 1439 |
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
|
1440 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
|
1441 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
|
1442 { |
2753 | 1443 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1444 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
|
1445 |
2753 | 1446 if (!window || !window->renderer) { |
1447 return -1; | |
1448 } | |
1449 renderer = window->renderer; | |
1450 if (renderer && renderer->ActivateRenderer) { | |
1451 if (renderer->ActivateRenderer(renderer) < 0) { | |
1452 return -1; | |
1453 } | |
1454 } | |
1455 SDL_CurrentDisplay.current_renderer = renderer; | |
1456 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
|
1457 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1458 |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1459 int |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1460 SDL_GetRendererInfo(SDL_RendererInfo * info) |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1461 { |
2753 | 1462 if (!_this) { |
1463 SDL_UninitializedVideo(); | |
1464 return -1; | |
1465 } | |
1466 if (!SDL_CurrentDisplay.current_renderer) { | |
1467 SDL_SetError("There is no current renderer"); | |
1468 return -1; | |
1469 } | |
1470 *info = SDL_CurrentDisplay.current_renderer->info; | |
1471 return 0; | |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1472 } |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1473 |
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
|
1474 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
|
1475 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
|
1476 { |
2753 | 1477 int hash; |
1478 SDL_Renderer *renderer; | |
1479 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
|
1480 |
2753 | 1481 if (!_this) { |
1482 SDL_UninitializedVideo(); | |
1483 return 0; | |
1484 } | |
1485 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1486 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1487 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1488 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1489 if (!renderer->CreateTexture) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1490 SDL_Unsupported(); |
2753 | 1491 return 0; |
1492 } | |
1493 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); | |
1494 if (!texture) { | |
1495 SDL_OutOfMemory(); | |
1496 return 0; | |
1497 } | |
1498 texture->id = _this->next_object_id++; | |
1499 texture->format = format; | |
1500 texture->access = access; | |
1501 texture->w = w; | |
1502 texture->h = h; | |
1503 texture->r = 255; | |
1504 texture->g = 255; | |
1505 texture->b = 255; | |
1506 texture->a = 255; | |
1507 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
|
1508 |
2753 | 1509 if (renderer->CreateTexture(renderer, texture) < 0) { |
1510 if (renderer->DestroyTexture) { | |
1511 renderer->DestroyTexture(renderer, texture); | |
1512 } | |
1513 SDL_free(texture); | |
1514 return 0; | |
1515 } | |
1516 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1517 texture->next = SDL_CurrentDisplay.textures[hash]; | |
1518 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
|
1519 |
2753 | 1520 return texture->id; |
0 | 1521 } |
1522 | |
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
|
1523 SDL_TextureID |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1524 SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) |
0 | 1525 { |
2753 | 1526 SDL_TextureID textureID; |
1527 SDL_PixelFormat *fmt; | |
1528 int bpp; | |
1529 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
|
1530 |
2753 | 1531 if (!surface) { |
1532 SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); | |
1533 return 0; | |
1534 } | |
1535 fmt = surface->format; | |
0 | 1536 |
2753 | 1537 if (format) { |
1538 if (!SDL_PixelFormatEnumToMasks | |
1539 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { | |
1540 SDL_SetError("Unknown pixel format"); | |
1541 return 0; | |
1542 } | |
1543 } else { | |
1544 if (surface->format->Amask | |
1545 || !(surface->map->info.flags & | |
1546 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) { | |
1547 bpp = fmt->BitsPerPixel; | |
1548 Rmask = fmt->Rmask; | |
1549 Gmask = fmt->Gmask; | |
1550 Bmask = fmt->Bmask; | |
1551 Amask = fmt->Amask; | |
1552 } else { | |
1553 /* Need a format with alpha */ | |
1554 bpp = 32; | |
1555 Rmask = 0x00FF0000; | |
1556 Gmask = 0x0000FF00; | |
1557 Bmask = 0x000000FF; | |
1558 Amask = 0xFF000000; | |
1559 } | |
1560 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); | |
1561 if (!format) { | |
1562 SDL_SetError("Unknown pixel format"); | |
1563 return 0; | |
1564 } | |
1565 } | |
0 | 1566 |
2753 | 1567 textureID = |
1568 SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, | |
1569 surface->h); | |
1570 if (!textureID) { | |
1571 return 0; | |
1572 } | |
1573 if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask | |
1574 && Bmask == fmt->Bmask && Amask == fmt->Amask) { | |
1575 if (SDL_MUSTLOCK(surface)) { | |
1576 if (SDL_LockSurface(surface) < 0) { | |
1577 SDL_DestroyTexture(textureID); | |
1578 return 0; | |
1579 } | |
1580 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1581 surface->pitch); | |
1582 SDL_UnlockSurface(surface); | |
1583 } else { | |
1584 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1585 surface->pitch); | |
1586 } | |
1587 } else { | |
1588 SDL_PixelFormat *dst_fmt; | |
1589 SDL_Surface *dst = NULL; | |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1590 |
2753 | 1591 /* Set up a destination surface for the texture update */ |
1592 dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); | |
1593 if (dst_fmt) { | |
1594 if (SDL_ISPIXELFORMAT_INDEXED(format)) { | |
1595 dst_fmt->palette = | |
1596 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); | |
1597 if (dst_fmt->palette) { | |
1598 /* | |
1599 * FIXME: Should we try to copy | |
1600 * fmt->palette? | |
1601 */ | |
1602 SDL_DitherColors(dst_fmt->palette->colors, | |
1603 SDL_BITSPERPIXEL(format)); | |
1604 } | |
1605 } | |
1606 dst = SDL_ConvertSurface(surface, dst_fmt, 0); | |
1607 if (dst) { | |
1608 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); | |
1609 SDL_FreeSurface(dst); | |
1610 } | |
1611 if (dst_fmt->palette) { | |
1612 SDL_FreePalette(dst_fmt->palette); | |
1613 } | |
1614 SDL_FreeFormat(dst_fmt); | |
1615 } | |
1616 if (!dst) { | |
1617 SDL_DestroyTexture(textureID); | |
1618 return 0; | |
1619 } | |
1620 } | |
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
|
1621 |
2753 | 1622 if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { |
1623 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, | |
1624 fmt->palette->ncolors); | |
1625 } | |
1626 return textureID; | |
0 | 1627 } |
1628 | |
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
|
1629 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
|
1630 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
|
1631 { |
2753 | 1632 int hash; |
1633 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
|
1634 |
2753 | 1635 if (!_this) { |
1636 return NULL; | |
1637 } | |
1638 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1639 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
1640 texture = texture->next) { | |
1641 if (texture->id == textureID) { | |
1642 return texture; | |
1643 } | |
1644 } | |
1645 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
|
1646 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1647 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1648 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
|
1649 SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access, |
2753 | 1650 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
|
1651 { |
2753 | 1652 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
|
1653 |
2753 | 1654 if (!texture) { |
1655 return -1; | |
1656 } | |
1657 if (format) { | |
1658 *format = texture->format; | |
1659 } | |
1660 if (access) { | |
1661 *access = texture->access; | |
1662 } | |
1663 if (w) { | |
1664 *w = texture->w; | |
1665 } | |
1666 if (h) { | |
1667 *h = texture->h; | |
1668 } | |
1669 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
|
1670 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1671 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1672 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
|
1673 SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch) |
0 | 1674 { |
2753 | 1675 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1676 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
|
1677 |
2753 | 1678 if (!texture) { |
1679 return -1; | |
1680 } | |
1681 renderer = texture->renderer; | |
1682 if (!renderer->QueryTexturePixels) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1683 SDL_Unsupported(); |
2753 | 1684 return -1; |
1685 } | |
1686 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
|
1687 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1688 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1689 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
|
1690 SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, |
2753 | 1691 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
|
1692 { |
2753 | 1693 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1694 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
|
1695 |
2753 | 1696 if (!texture) { |
1697 return -1; | |
1698 } | |
1699 renderer = texture->renderer; | |
1700 if (!renderer->SetTexturePalette) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1701 SDL_Unsupported(); |
2753 | 1702 return -1; |
1703 } | |
1704 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, | |
1705 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
|
1706 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1707 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1708 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
|
1709 SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, |
2753 | 1710 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
|
1711 { |
2753 | 1712 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1713 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
|
1714 |
2753 | 1715 if (!texture) { |
1716 return -1; | |
1717 } | |
1718 renderer = texture->renderer; | |
1719 if (!renderer->GetTexturePalette) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1720 SDL_Unsupported(); |
2753 | 1721 return -1; |
1722 } | |
1723 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, | |
1724 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
|
1725 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1726 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1727 int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1728 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
|
1729 { |
2753 | 1730 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1731 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1732 |
2753 | 1733 if (!texture) { |
1734 return -1; | |
1735 } | |
1736 renderer = texture->renderer; | |
1737 if (!renderer->SetTextureColorMod) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1738 SDL_Unsupported(); |
2753 | 1739 return -1; |
1740 } | |
1741 if (r < 255 || g < 255 || b < 255) { | |
1742 texture->modMode |= SDL_TEXTUREMODULATE_COLOR; | |
1743 } else { | |
1744 texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; | |
1745 } | |
1746 texture->r = r; | |
1747 texture->g = g; | |
1748 texture->b = b; | |
1749 return renderer->SetTextureColorMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1750 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1751 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1752 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1753 SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g, |
2753 | 1754 Uint8 * b) |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1755 { |
2753 | 1756 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1757 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1758 |
2753 | 1759 if (!texture) { |
1760 return -1; | |
1761 } | |
1762 renderer = texture->renderer; | |
1763 if (r) { | |
1764 *r = texture->r; | |
1765 } | |
1766 if (g) { | |
1767 *g = texture->g; | |
1768 } | |
1769 if (b) { | |
1770 *b = texture->b; | |
1771 } | |
1772 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1773 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1774 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1775 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1776 SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1777 { |
2753 | 1778 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1779 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1780 |
2753 | 1781 if (!texture) { |
1782 return -1; | |
1783 } | |
1784 renderer = texture->renderer; | |
1785 if (!renderer->SetTextureAlphaMod) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1786 SDL_Unsupported(); |
2753 | 1787 return -1; |
1788 } | |
1789 if (alpha < 255) { | |
1790 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; | |
1791 } else { | |
1792 texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; | |
1793 } | |
1794 texture->a = alpha; | |
1795 return renderer->SetTextureAlphaMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1796 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1797 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1798 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1799 SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1800 { |
2753 | 1801 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1802 |
2753 | 1803 if (!texture) { |
1804 return -1; | |
1805 } | |
1806 if (alpha) { | |
1807 *alpha = texture->a; | |
1808 } | |
1809 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1810 } |
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 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1813 SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1814 { |
2753 | 1815 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1816 SDL_Renderer *renderer; | |
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 renderer = texture->renderer; | |
1822 if (!renderer->SetTextureBlendMode) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1823 SDL_Unsupported(); |
2753 | 1824 return -1; |
1825 } | |
1826 texture->blendMode = blendMode; | |
1827 return renderer->SetTextureBlendMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1828 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1829 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1830 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1831 SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1832 { |
2753 | 1833 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1834 |
2753 | 1835 if (!texture) { |
1836 return -1; | |
1837 } | |
1838 if (blendMode) { | |
1839 *blendMode = texture->blendMode; | |
1840 } | |
1841 return 0; | |
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_SetTextureScaleMode(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); |
1848 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1849 |
2753 | 1850 if (!texture) { |
1851 return -1; | |
1852 } | |
1853 renderer = texture->renderer; | |
1854 if (!renderer->SetTextureScaleMode) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1855 SDL_Unsupported(); |
2753 | 1856 return -1; |
1857 } | |
1858 texture->scaleMode = scaleMode; | |
1859 return renderer->SetTextureScaleMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1860 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1861 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1862 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1863 SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1864 { |
2753 | 1865 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1866 |
2753 | 1867 if (!texture) { |
1868 return -1; | |
1869 } | |
1870 if (scaleMode) { | |
1871 *scaleMode = texture->scaleMode; | |
1872 } | |
1873 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1874 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1875 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1876 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
|
1877 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, |
2753 | 1878 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
|
1879 { |
2753 | 1880 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1881 SDL_Renderer *renderer; | |
1882 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
|
1883 |
2753 | 1884 if (!texture) { |
1885 return -1; | |
1886 } | |
1887 renderer = texture->renderer; | |
1888 if (!renderer->UpdateTexture) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1889 SDL_Unsupported(); |
2753 | 1890 return -1; |
1891 } | |
1892 if (!rect) { | |
1893 full_rect.x = 0; | |
1894 full_rect.y = 0; | |
1895 full_rect.w = texture->w; | |
1896 full_rect.h = texture->h; | |
1897 rect = &full_rect; | |
1898 } | |
1899 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
|
1900 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1901 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1902 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
|
1903 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, |
2753 | 1904 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
|
1905 { |
2753 | 1906 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1907 SDL_Renderer *renderer; | |
1908 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
|
1909 |
2753 | 1910 if (!texture) { |
1911 return -1; | |
1912 } | |
1913 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
1914 SDL_SetError("SDL_LockTexture(): texture must be streaming"); | |
1915 return -1; | |
1916 } | |
1917 renderer = texture->renderer; | |
1918 if (!renderer->LockTexture) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1919 SDL_Unsupported(); |
2753 | 1920 return -1; |
1921 } | |
1922 if (!rect) { | |
1923 full_rect.x = 0; | |
1924 full_rect.y = 0; | |
1925 full_rect.w = texture->w; | |
1926 full_rect.h = texture->h; | |
1927 rect = &full_rect; | |
1928 } | |
1929 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels, | |
1930 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
|
1931 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 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
|
1934 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
|
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->UnlockTexture) { | |
1947 return; | |
1948 } | |
1949 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
|
1950 } |
0 | 1951 |
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
|
1952 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
|
1953 SDL_DirtyTexture(SDL_TextureID textureID, int numrects, |
2753 | 1954 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
|
1955 { |
2753 | 1956 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1957 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
|
1958 |
2753 | 1959 if (!texture) { |
1960 return; | |
1961 } | |
1962 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
1963 return; | |
1964 } | |
1965 renderer = texture->renderer; | |
1966 if (!renderer->DirtyTexture) { | |
1967 return; | |
1968 } | |
1969 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
|
1970 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1971 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1972 int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
1973 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
|
1974 { |
2753 | 1975 SDL_Renderer *renderer; |
1976 SDL_Window *window; | |
1977 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
|
1978 |
2753 | 1979 if (!_this) { |
1980 SDL_UninitializedVideo(); | |
1981 return -1; | |
1982 } | |
1983 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1984 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1985 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1986 } |
2814 | 1987 if (!renderer->RenderFill) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1988 SDL_Unsupported(); |
2753 | 1989 return -1; |
1990 } | |
1991 window = SDL_GetWindowFromID(renderer->window); | |
1992 real_rect.x = 0; | |
1993 real_rect.y = 0; | |
1994 real_rect.w = window->w; | |
1995 real_rect.h = window->h; | |
1996 if (rect) { | |
1997 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
1998 return 0; | |
1999 } | |
2000 } | |
2001 return renderer->RenderFill(renderer, r, g, b, a, &real_rect); | |
0 | 2002 } |
2003 | |
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
|
2004 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
|
2005 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, |
2753 | 2006 const SDL_Rect * dstrect) |
0 | 2007 { |
2753 | 2008 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2009 SDL_Renderer *renderer; | |
2010 SDL_Window *window; | |
2011 SDL_Rect real_srcrect; | |
2012 SDL_Rect real_dstrect; | |
0 | 2013 |
2753 | 2014 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { |
2015 return -1; | |
2016 } | |
2017 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2018 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2019 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2020 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2021 if (!renderer->RenderCopy) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2022 SDL_Unsupported(); |
2753 | 2023 return -1; |
2024 } | |
2025 window = SDL_GetWindowFromID(renderer->window); | |
2026 if (srcrect) { | |
2027 real_srcrect = *srcrect; | |
2028 } else { | |
2029 real_srcrect.x = 0; | |
2030 real_srcrect.y = 0; | |
2031 real_srcrect.w = texture->w; | |
2032 real_srcrect.h = texture->h; | |
2033 } | |
2034 if (dstrect) { | |
2035 real_dstrect = *dstrect; | |
2036 } else { | |
2037 real_dstrect.x = 0; | |
2038 real_dstrect.y = 0; | |
2039 real_dstrect.w = window->w; | |
2040 real_dstrect.h = window->h; | |
2041 } | |
0 | 2042 |
2753 | 2043 return renderer->RenderCopy(renderer, texture, &real_srcrect, |
2044 &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
|
2045 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2046 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2047 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
|
2048 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
|
2049 { |
2753 | 2050 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
|
2051 |
2753 | 2052 if (!_this) { |
2053 SDL_UninitializedVideo(); | |
2054 return; | |
2055 } | |
2056 renderer = SDL_CurrentDisplay.current_renderer; | |
2057 if (!renderer || !renderer->RenderPresent) { | |
2058 return; | |
2059 } | |
2060 renderer->RenderPresent(renderer); | |
0 | 2061 } |
2062 | |
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
|
2063 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
|
2064 SDL_DestroyTexture(SDL_TextureID textureID) |
0 | 2065 { |
2753 | 2066 int hash; |
2067 SDL_Texture *prev, *texture; | |
2068 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
|
2069 |
2753 | 2070 if (!_this) { |
2071 SDL_UninitializedVideo(); | |
2072 return; | |
2073 } | |
2074 /* Look up the texture in the hash table */ | |
2075 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
2076 prev = NULL; | |
2077 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
2078 prev = texture, texture = texture->next) { | |
2079 if (texture->id == textureID) { | |
2080 break; | |
2081 } | |
2082 } | |
2083 if (!texture) { | |
2084 return; | |
2085 } | |
2086 /* Unlink the texture from the list */ | |
2087 if (prev) { | |
2088 prev->next = texture->next; | |
2089 } else { | |
2090 SDL_CurrentDisplay.textures[hash] = texture->next; | |
2091 } | |
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
|
2092 |
2753 | 2093 /* Free the texture */ |
2094 renderer = texture->renderer; | |
2095 renderer->DestroyTexture(renderer, texture); | |
2096 SDL_free(texture); | |
0 | 2097 } |
2098 | |
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
|
2099 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
|
2100 SDL_DestroyRenderer(SDL_WindowID windowID) |
0 | 2101 { |
2753 | 2102 SDL_Window *window = SDL_GetWindowFromID(windowID); |
2103 SDL_Renderer *renderer; | |
2104 int i; | |
0 | 2105 |
2753 | 2106 if (!window) { |
2107 return; | |
2108 } | |
2109 renderer = window->renderer; | |
2110 if (!renderer) { | |
2111 return; | |
2112 } | |
2113 /* Free existing textures for this renderer */ | |
2114 for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) { | |
2115 SDL_Texture *texture; | |
2116 SDL_Texture *prev = NULL; | |
2117 SDL_Texture *next; | |
2118 for (texture = SDL_CurrentDisplay.textures[i]; texture; | |
2119 texture = next) { | |
2120 next = texture->next; | |
2121 if (texture->renderer == renderer) { | |
2122 if (prev) { | |
2123 prev->next = next; | |
2124 } else { | |
2125 SDL_CurrentDisplay.textures[i] = next; | |
2126 } | |
2127 renderer->DestroyTexture(renderer, texture); | |
2128 SDL_free(texture); | |
2129 } else { | |
2130 prev = texture; | |
2131 } | |
2132 } | |
2133 } | |
0 | 2134 |
2753 | 2135 /* Free the renderer instance */ |
2136 renderer->DestroyRenderer(renderer); | |
0 | 2137 |
2753 | 2138 /* Clear references */ |
2139 window->renderer = NULL; | |
2140 if (SDL_CurrentDisplay.current_renderer == renderer) { | |
2141 SDL_CurrentDisplay.current_renderer = NULL; | |
2142 } | |
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
|
2143 } |
0 | 2144 |
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
|
2145 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
|
2146 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
|
2147 { |
2753 | 2148 int i, j; |
0 | 2149 |
2753 | 2150 if (!_this) { |
2151 return; | |
2152 } | |
2153 /* Halt event processing before doing anything else */ | |
2154 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
|
2155 |
2753 | 2156 /* Clean up the system video */ |
2157 for (i = _this->num_displays; i--;) { | |
2158 SDL_VideoDisplay *display = &_this->displays[i]; | |
2159 for (j = display->num_windows; j--;) { | |
2160 SDL_DestroyWindow(display->windows[i].id); | |
2161 } | |
2162 if (display->windows) { | |
2163 SDL_free(display->windows); | |
2164 display->windows = NULL; | |
2165 } | |
2166 display->num_windows = 0; | |
2167 if (display->render_drivers) { | |
2168 SDL_free(display->render_drivers); | |
2169 display->render_drivers = NULL; | |
2170 } | |
2171 display->num_render_drivers = 0; | |
2172 } | |
2173 _this->VideoQuit(_this); | |
0 | 2174 |
2753 | 2175 for (i = _this->num_displays; i--;) { |
2176 SDL_VideoDisplay *display = &_this->displays[i]; | |
2177 for (j = display->num_display_modes; j--;) { | |
2178 if (display->display_modes[j].driverdata) { | |
2179 SDL_free(display->display_modes[j].driverdata); | |
2180 display->display_modes[j].driverdata = NULL; | |
2181 } | |
2182 } | |
2183 if (display->display_modes) { | |
2184 SDL_free(display->display_modes); | |
2185 display->display_modes = NULL; | |
2186 } | |
2187 if (display->desktop_mode.driverdata) { | |
2188 SDL_free(display->desktop_mode.driverdata); | |
2189 display->desktop_mode.driverdata = NULL; | |
2190 } | |
2191 if (display->palette) { | |
2192 SDL_FreePalette(display->palette); | |
2193 display->palette = NULL; | |
2194 } | |
2195 if (display->gamma) { | |
2196 SDL_free(display->gamma); | |
2197 display->gamma = NULL; | |
2198 } | |
2199 if (display->driverdata) { | |
2200 SDL_free(display->driverdata); | |
2201 display->driverdata = NULL; | |
2202 } | |
2203 } | |
2204 if (_this->displays) { | |
2205 SDL_free(_this->displays); | |
2206 _this->displays = NULL; | |
2207 } | |
2208 _this->free(_this); | |
2209 _this = NULL; | |
0 | 2210 } |
2211 | |
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
|
2212 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
|
2213 SDL_GL_LoadLibrary(const char *path) |
0 | 2214 { |
2753 | 2215 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2216 |
2753 | 2217 if (!_this) { |
2218 SDL_UninitializedVideo(); | |
2219 return -1; | |
2220 } | |
2221 if (_this->GL_LoadLibrary) { | |
2222 retval = _this->GL_LoadLibrary(_this, path); | |
2223 } else { | |
2224 SDL_SetError("No dynamic GL support in video driver"); | |
2225 retval = -1; | |
2226 } | |
2227 return (retval); | |
0 | 2228 } |
2229 | |
2753 | 2230 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
|
2231 SDL_GL_GetProcAddress(const char *proc) |
0 | 2232 { |
2753 | 2233 void *func; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2234 |
2753 | 2235 if (!_this) { |
2236 SDL_UninitializedVideo(); | |
2237 return NULL; | |
2238 } | |
2239 func = NULL; | |
2240 if (_this->GL_GetProcAddress) { | |
2241 if (_this->gl_config.driver_loaded) { | |
2242 func = _this->GL_GetProcAddress(_this, proc); | |
2243 } else { | |
2244 SDL_SetError("No GL driver has been loaded"); | |
2245 } | |
2246 } else { | |
2247 SDL_SetError("No dynamic GL support in video driver"); | |
2248 } | |
2249 return func; | |
0 | 2250 } |
2251 | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2252 SDL_bool |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2253 SDL_GL_ExtensionSupported(const char *extension) |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2254 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2255 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2256 const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); |
2257 const char *extensions; | |
2258 const char *start; | |
2259 const char *where, *terminator; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2260 |
2753 | 2261 /* Extension names should not have spaces. */ |
2262 where = SDL_strchr(extension, ' '); | |
2263 if (where || *extension == '\0') { | |
2264 return SDL_FALSE; | |
2265 } | |
2266 /* See if there's an environment variable override */ | |
2267 start = SDL_getenv(extension); | |
2268 if (start && *start == '0') { | |
2269 return SDL_FALSE; | |
2270 } | |
2271 /* Lookup the available extensions */ | |
2272 glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); | |
2273 if (glGetStringFunc) { | |
2274 extensions = (const char *) glGetStringFunc(GL_EXTENSIONS); | |
2275 } else { | |
2276 extensions = NULL; | |
2277 } | |
2278 if (!extensions) { | |
2279 return SDL_FALSE; | |
2280 } | |
2281 /* | |
2282 * It takes a bit of care to be fool-proof about parsing the OpenGL | |
2283 * extensions string. Don't be fooled by sub-strings, etc. | |
2284 */ | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2285 |
2753 | 2286 start = extensions; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2287 |
2753 | 2288 for (;;) { |
2289 where = SDL_strstr(start, extension); | |
2290 if (!where) | |
2291 break; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2292 |
2753 | 2293 terminator = where + SDL_strlen(extension); |
2294 if (where == start || *(where - 1) == ' ') | |
2295 if (*terminator == ' ' || *terminator == '\0') | |
2296 return SDL_TRUE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2297 |
2753 | 2298 start = terminator; |
2299 } | |
2300 return SDL_FALSE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2301 #else |
2753 | 2302 return SDL_FALSE; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2303 #endif |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2304 } |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2305 |
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
|
2306 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
|
2307 SDL_GL_SetAttribute(SDL_GLattr attr, int value) |
0 | 2308 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2309 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2310 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2311 |
2753 | 2312 if (!_this) { |
2313 SDL_UninitializedVideo(); | |
2314 return -1; | |
2315 } | |
2316 retval = 0; | |
2317 switch (attr) { | |
2318 case SDL_GL_RED_SIZE: | |
2319 _this->gl_config.red_size = value; | |
2320 break; | |
2321 case SDL_GL_GREEN_SIZE: | |
2322 _this->gl_config.green_size = value; | |
2323 break; | |
2324 case SDL_GL_BLUE_SIZE: | |
2325 _this->gl_config.blue_size = value; | |
2326 break; | |
2327 case SDL_GL_ALPHA_SIZE: | |
2328 _this->gl_config.alpha_size = value; | |
2329 break; | |
2330 case SDL_GL_DOUBLEBUFFER: | |
2331 _this->gl_config.double_buffer = value; | |
2332 break; | |
2333 case SDL_GL_BUFFER_SIZE: | |
2334 _this->gl_config.buffer_size = value; | |
2335 break; | |
2336 case SDL_GL_DEPTH_SIZE: | |
2337 _this->gl_config.depth_size = value; | |
2338 break; | |
2339 case SDL_GL_STENCIL_SIZE: | |
2340 _this->gl_config.stencil_size = value; | |
2341 break; | |
2342 case SDL_GL_ACCUM_RED_SIZE: | |
2343 _this->gl_config.accum_red_size = value; | |
2344 break; | |
2345 case SDL_GL_ACCUM_GREEN_SIZE: | |
2346 _this->gl_config.accum_green_size = value; | |
2347 break; | |
2348 case SDL_GL_ACCUM_BLUE_SIZE: | |
2349 _this->gl_config.accum_blue_size = value; | |
2350 break; | |
2351 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2352 _this->gl_config.accum_alpha_size = value; | |
2353 break; | |
2354 case SDL_GL_STEREO: | |
2355 _this->gl_config.stereo = value; | |
2356 break; | |
2357 case SDL_GL_MULTISAMPLEBUFFERS: | |
2358 _this->gl_config.multisamplebuffers = value; | |
2359 break; | |
2360 case SDL_GL_MULTISAMPLESAMPLES: | |
2361 _this->gl_config.multisamplesamples = value; | |
2362 break; | |
2363 case SDL_GL_ACCELERATED_VISUAL: | |
2364 _this->gl_config.accelerated = value; | |
2365 break; | |
2366 case SDL_GL_RETAINED_BACKING: | |
2367 _this->gl_config.retained_backing = value; | |
2368 break; | |
2369 default: | |
2370 SDL_SetError("Unknown OpenGL attribute"); | |
2371 retval = -1; | |
2372 break; | |
2373 } | |
2374 return retval; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2375 #else |
2753 | 2376 SDL_Unsupported(); |
2377 return -1; | |
2378 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 2379 } |
2380 | |
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
|
2381 int |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2382 SDL_GL_GetAttribute(SDL_GLattr attr, int *value) |
0 | 2383 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2384 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2385 void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); |
2386 GLenum attrib = 0; | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2387 |
2753 | 2388 glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); |
2389 if (!glGetIntegervFunc) { | |
2390 return -1; | |
2391 } | |
2392 switch (attr) { | |
2393 case SDL_GL_RETAINED_BACKING: | |
2394 *value = _this->gl_config.retained_backing; | |
2395 return 0; | |
2396 case SDL_GL_RED_SIZE: | |
2397 attrib = GL_RED_BITS; | |
2398 break; | |
2399 case SDL_GL_BLUE_SIZE: | |
2400 attrib = GL_BLUE_BITS; | |
2401 break; | |
2402 case SDL_GL_GREEN_SIZE: | |
2403 attrib = GL_GREEN_BITS; | |
2404 break; | |
2405 case SDL_GL_ALPHA_SIZE: | |
2406 attrib = GL_ALPHA_BITS; | |
2407 break; | |
2408 case SDL_GL_DOUBLEBUFFER: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2409 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2410 attrib = GL_DOUBLEBUFFER; |
2411 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2412 #else |
2753 | 2413 /* |
2414 * I believe double buffering is the only option in OpenGL ES | |
2415 * -- in any case, GL_DOUBLEBUFFER doesn't exist | |
2416 */ | |
2417 *value = 1; | |
2418 return 0; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2419 #endif |
2753 | 2420 case SDL_GL_DEPTH_SIZE: |
2421 attrib = GL_DEPTH_BITS; | |
2422 break; | |
2423 case SDL_GL_STENCIL_SIZE: | |
2424 attrib = GL_STENCIL_BITS; | |
2425 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2426 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2427 case SDL_GL_ACCUM_RED_SIZE: |
2428 attrib = GL_ACCUM_RED_BITS; | |
2429 break; | |
2430 case SDL_GL_ACCUM_GREEN_SIZE: | |
2431 attrib = GL_ACCUM_GREEN_BITS; | |
2432 break; | |
2433 case SDL_GL_ACCUM_BLUE_SIZE: | |
2434 attrib = GL_ACCUM_BLUE_BITS; | |
2435 break; | |
2436 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2437 attrib = GL_ACCUM_ALPHA_BITS; | |
2438 break; | |
2439 case SDL_GL_STEREO: | |
2440 attrib = GL_STEREO; | |
2441 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2442 #else |
2753 | 2443 case SDL_GL_ACCUM_RED_SIZE: |
2444 case SDL_GL_ACCUM_GREEN_SIZE: | |
2445 case SDL_GL_ACCUM_BLUE_SIZE: | |
2446 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2447 case SDL_GL_STEREO: | |
2448 /* none of these are supported in OpenGL ES */ | |
2449 *value = 0; | |
2450 return 0; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2451 #endif |
2753 | 2452 case SDL_GL_MULTISAMPLEBUFFERS: |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2453 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2454 attrib = GL_SAMPLE_BUFFERS_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2455 #else |
2753 | 2456 attrib = GL_SAMPLE_BUFFERS; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2457 #endif |
2753 | 2458 break; |
2459 case SDL_GL_MULTISAMPLESAMPLES: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2460 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2461 attrib = GL_SAMPLES_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2462 #else |
2753 | 2463 attrib = GL_SAMPLES; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2464 #endif |
2753 | 2465 break; |
2466 case SDL_GL_BUFFER_SIZE: | |
2467 { | |
2468 GLint bits = 0; | |
2469 GLint component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2470 |
2753 | 2471 /* |
2472 * there doesn't seem to be a single flag in OpenGL | |
2473 * for this! | |
2474 */ | |
2475 glGetIntegervFunc(GL_RED_BITS, &component); | |
2476 bits += component; | |
2477 glGetIntegervFunc(GL_GREEN_BITS, &component); | |
2478 bits += component; | |
2479 glGetIntegervFunc(GL_BLUE_BITS, &component); | |
2480 bits += component; | |
2481 glGetIntegervFunc(GL_ALPHA_BITS, &component); | |
2482 bits += component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2483 |
2753 | 2484 *value = bits; |
2485 return 0; | |
2486 } | |
2487 case SDL_GL_ACCELERATED_VISUAL: | |
2488 { | |
2489 /* FIXME: How do we get this information? */ | |
2490 *value = (_this->gl_config.accelerated != 0); | |
2491 return 0; | |
2492 } | |
2493 default: | |
2494 SDL_SetError("Unknown OpenGL attribute"); | |
2495 return -1; | |
2496 } | |
0 | 2497 |
2753 | 2498 glGetIntegervFunc(attrib, (GLint *) value); |
2499 return 0; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2500 #else |
2753 | 2501 SDL_Unsupported(); |
2502 return -1; | |
2503 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 2504 } |
2505 | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2506 SDL_GLContext |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2507 SDL_GL_CreateContext(SDL_WindowID windowID) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2508 { |
2753 | 2509 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2510 |
2753 | 2511 if (!window) { |
2512 return NULL; | |
2513 } | |
2514 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
2515 SDL_SetError("The specified window isn't an OpenGL window"); | |
2516 return NULL; | |
2517 } | |
2518 return _this->GL_CreateContext(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2519 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2520 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2521 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2522 SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2523 { |
2753 | 2524 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2525 |
2753 | 2526 if (window && !(window->flags & SDL_WINDOW_OPENGL)) { |
2527 SDL_SetError("The specified window isn't an OpenGL window"); | |
2528 return -1; | |
2529 } | |
2530 if (!context) { | |
2531 window = NULL; | |
2532 } | |
2533 return _this->GL_MakeCurrent(_this, window, context); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2534 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2535 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2536 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2537 SDL_GL_SetSwapInterval(int interval) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2538 { |
2753 | 2539 if (!_this) { |
2540 SDL_UninitializedVideo(); | |
2541 return -1; | |
2542 } | |
2543 if (_this->GL_SetSwapInterval) { | |
2544 return _this->GL_SetSwapInterval(_this, interval); | |
2545 } else { | |
2546 SDL_SetError("Setting the swap interval is not supported"); | |
2547 return -1; | |
2548 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2549 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2550 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2551 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2552 SDL_GL_GetSwapInterval(void) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2553 { |
2753 | 2554 if (!_this) { |
2555 SDL_UninitializedVideo(); | |
2556 return -1; | |
2557 } | |
2558 if (_this->GL_GetSwapInterval) { | |
2559 return _this->GL_GetSwapInterval(_this); | |
2560 } else { | |
2561 SDL_SetError("Getting the swap interval is not supported"); | |
2562 return -1; | |
2563 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2564 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2565 |
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
|
2566 void |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2567 SDL_GL_SwapWindow(SDL_WindowID windowID) |
0 | 2568 { |
2753 | 2569 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2570 |
2753 | 2571 if (!window) { |
2572 return; | |
2573 } | |
2574 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
2575 SDL_SetError("The specified window isn't an OpenGL window"); | |
2576 return; | |
2577 } | |
2578 _this->GL_SwapWindow(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2579 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2580 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2581 void |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2582 SDL_GL_DeleteContext(SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2583 { |
2753 | 2584 if (!_this || !context) { |
2585 return; | |
2586 } | |
2587 _this->GL_MakeCurrent(_this, NULL, NULL); | |
2588 _this->GL_DeleteContext(_this, context); | |
0 | 2589 } |
2590 | |
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
|
2591 #if 0 // FIXME |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2592 /* |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2593 * 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
|
2594 * & 2 for alpha channel. |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
2595 */ |
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
|
2596 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
|
2597 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) |
0 | 2598 { |
2753 | 2599 int x, y; |
2600 Uint32 colorkey; | |
0 | 2601 #define SET_MASKBIT(icon, x, y, mask) \ |
2602 mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) | |
2603 | |
2753 | 2604 colorkey = icon->format->colorkey; |
2605 switch (icon->format->BytesPerPixel) { | |
2606 case 1: | |
2607 { | |
2608 Uint8 *pixels; | |
2609 for (y = 0; y < icon->h; ++y) { | |
2610 pixels = (Uint8 *) icon->pixels + y * icon->pitch; | |
2611 for (x = 0; x < icon->w; ++x) { | |
2612 if (*pixels++ == colorkey) { | |
2613 SET_MASKBIT(icon, x, y, mask); | |
2614 } | |
2615 } | |
2616 } | |
2617 } | |
2618 break; | |
0 | 2619 |
2753 | 2620 case 2: |
2621 { | |
2622 Uint16 *pixels; | |
2623 for (y = 0; y < icon->h; ++y) { | |
2624 pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2; | |
2625 for (x = 0; x < icon->w; ++x) { | |
2626 if ((flags & 1) && *pixels == colorkey) { | |
2627 SET_MASKBIT(icon, x, y, mask); | |
2628 } else if ((flags & 2) | |
2629 && (*pixels & icon->format->Amask) == 0) { | |
2630 SET_MASKBIT(icon, x, y, mask); | |
2631 } | |
2632 pixels++; | |
2633 } | |
2634 } | |
2635 } | |
2636 break; | |
0 | 2637 |
2753 | 2638 case 4: |
2639 { | |
2640 Uint32 *pixels; | |
2641 for (y = 0; y < icon->h; ++y) { | |
2642 pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4; | |
2643 for (x = 0; x < icon->w; ++x) { | |
2644 if ((flags & 1) && *pixels == colorkey) { | |
2645 SET_MASKBIT(icon, x, y, mask); | |
2646 } else if ((flags & 2) | |
2647 && (*pixels & icon->format->Amask) == 0) { | |
2648 SET_MASKBIT(icon, x, y, mask); | |
2649 } | |
2650 pixels++; | |
2651 } | |
2652 } | |
2653 } | |
2654 break; | |
2655 } | |
0 | 2656 } |
2657 | |
2658 /* | |
2659 * Sets the window manager icon for the display window. | |
2660 */ | |
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
|
2661 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
|
2662 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) |
0 | 2663 { |
2753 | 2664 if (icon && _this->SetIcon) { |
2665 /* Generate a mask if necessary, and create the icon! */ | |
2666 if (mask == NULL) { | |
2667 int mask_len = icon->h * (icon->w + 7) / 8; | |
2668 int flags = 0; | |
2669 mask = (Uint8 *) SDL_malloc(mask_len); | |
2670 if (mask == NULL) { | |
2671 return; | |
2672 } | |
2673 SDL_memset(mask, ~0, mask_len); | |
2674 if (icon->flags & SDL_SRCCOLORKEY) | |
2675 flags |= 1; | |
2676 if (icon->flags & SDL_SRCALPHA) | |
2677 flags |= 2; | |
2678 if (flags) { | |
2679 CreateMaskFromColorKeyOrAlpha(icon, mask, flags); | |
2680 } | |
2681 _this->SetIcon(_this, icon, mask); | |
2682 SDL_free(mask); | |
2683 } else { | |
2684 _this->SetIcon(_this, icon, mask); | |
2685 } | |
2686 } | |
0 | 2687 } |
2688 #endif | |
2689 | |
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
|
2690 SDL_bool |
2753 | 2691 SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info) |
0 | 2692 { |
2753 | 2693 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 2694 |
2753 | 2695 if (!window || !_this->GetWindowWMInfo) { |
2696 return SDL_FALSE; | |
2697 } | |
2698 return (_this->GetWindowWMInfo(_this, window, info)); | |
0 | 2699 } |
2700 | |
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
|
2701 /* vi: set ts=4 sw=4 expandtab: */ |