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