Mercurial > sdl-ios-xcode
annotate src/video/SDL_video.c @ 3257:94fb40a4a9a7
Merged Martin's code changes from Google Summer of Code 2009
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 07 Sep 2009 04:51:29 +0000 |
parents | 413672b09bb3 |
children | 82ce350be859 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
2859 | 3 Copyright (C) 1997-2009 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 | |
2999
b2025ca5d7a5
Fixed missing include for SDL_INIT_EVENTTHREAD
Sam Lantinga <slouken@libsdl.org>
parents:
2984
diff
changeset
|
26 #include "SDL.h" |
2984
0b160c970b7e
Fixed some dependency issues with SDL_revision.h
Sam Lantinga <slouken@libsdl.org>
parents:
2967
diff
changeset
|
27 #include "SDL_video.h" |
0 | 28 #include "SDL_sysvideo.h" |
29 #include "SDL_blit.h" | |
30 #include "SDL_pixels_c.h" | |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
31 #include "SDL_renderer_gl.h" |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
32 #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
|
33 #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
|
34 #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
|
35 #include "../events/SDL_events_c.h" |
0 | 36 |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
37 #if SDL_VIDEO_OPENGL_ES |
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
38 #include "SDL_opengles.h" |
2753 | 39 #endif /* SDL_VIDEO_OPENGL_ES */ |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
40 |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
41 #if SDL_VIDEO_OPENGL |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
42 #include "SDL_opengl.h" |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
43 |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
44 /* On Windows, windows.h defines CreateWindow */ |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
45 #ifdef CreateWindow |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
46 #undef CreateWindow |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
47 #endif |
2753 | 48 #endif /* SDL_VIDEO_OPENGL */ |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
49 |
0 | 50 /* Available video drivers */ |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
51 static VideoBootStrap *bootstrap[] = { |
1931
103c6fec2a60
The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
1930
diff
changeset
|
52 #if SDL_VIDEO_DRIVER_COCOA |
2753 | 53 &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
|
54 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
55 #if SDL_VIDEO_DRIVER_X11 |
2753 | 56 &X11_bootstrap, |
0 | 57 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
58 #if SDL_VIDEO_DRIVER_NANOX |
2753 | 59 &NX_bootstrap, |
30
57bf11a5efd7
Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
19
diff
changeset
|
60 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
61 #if SDL_VIDEO_DRIVER_IPOD |
2753 | 62 &iPod_bootstrap, |
1140
af8b0f9ac2f4
iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1133
diff
changeset
|
63 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
64 #if SDL_VIDEO_DRIVER_WSCONS |
2753 | 65 &WSCONS_bootstrap, |
1187 | 66 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
67 #if SDL_VIDEO_DRIVER_FBCON |
2753 | 68 &FBCON_bootstrap, |
0 | 69 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
70 #if SDL_VIDEO_DRIVER_DIRECTFB |
2753 | 71 &DirectFB_bootstrap, |
167
cb384ef627f6
Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents:
125
diff
changeset
|
72 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
73 #if SDL_VIDEO_DRIVER_PS2GS |
2753 | 74 &PS2GS_bootstrap, |
0 | 75 #endif |
3257
94fb40a4a9a7
Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3196
diff
changeset
|
76 #if SDL_VIDEO_DRIVER_PS3 |
94fb40a4a9a7
Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3196
diff
changeset
|
77 &PS3_bootstrap, |
94fb40a4a9a7
Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
3196
diff
changeset
|
78 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
79 #if SDL_VIDEO_DRIVER_VGL |
2753 | 80 &VGL_bootstrap, |
75
b0ae59d0f3ee
Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
58
diff
changeset
|
81 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
82 #if SDL_VIDEO_DRIVER_SVGALIB |
2753 | 83 &SVGALIB_bootstrap, |
0 | 84 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
85 #if SDL_VIDEO_DRIVER_GAPI |
2753 | 86 &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
|
87 #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
|
88 #if SDL_VIDEO_DRIVER_WIN32 |
2753 | 89 &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
|
90 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
91 #if SDL_VIDEO_DRIVER_BWINDOW |
2753 | 92 &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
|
93 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
94 #if SDL_VIDEO_DRIVER_PHOTON |
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3058
diff
changeset
|
95 &photon_bootstrap, |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3058
diff
changeset
|
96 #endif |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3058
diff
changeset
|
97 #if SDL_VIDEO_DRIVER_QNXGF |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3058
diff
changeset
|
98 &qnxgf_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
99 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
100 #if SDL_VIDEO_DRIVER_EPOC |
2753 | 101 &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
|
102 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
103 #if SDL_VIDEO_DRIVER_XBIOS |
2753 | 104 &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
|
105 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
106 #if SDL_VIDEO_DRIVER_GEM |
2753 | 107 &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
|
108 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
109 #if SDL_VIDEO_DRIVER_DC |
2753 | 110 &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
|
111 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
112 #if SDL_VIDEO_DRIVER_RISCOS |
2753 | 113 &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
|
114 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
115 #if SDL_VIDEO_DRIVER_OS2FS |
2753 | 116 &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
|
117 #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
|
118 #if SDL_VIDEO_DRIVER_NDS |
2753 | 119 &NDS_bootstrap, |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2702
diff
changeset
|
120 #endif |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
121 #if SDL_VIDEO_DRIVER_UIKIT |
2753 | 122 &UIKIT_bootstrap, |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
123 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
124 #if SDL_VIDEO_DRIVER_DUMMY |
2753 | 125 &DUMMY_bootstrap, |
610
95433459fbd2
Date: Mon, 14 Apr 2003 22:08:27 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
580
diff
changeset
|
126 #endif |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
127 #if SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
128 &PND_bootstrap, |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
129 #endif |
2753 | 130 NULL |
0 | 131 }; |
173
83018110dce8
Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents:
167
diff
changeset
|
132 |
1895
c121d94672cb
SDL 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 static SDL_VideoDevice *_this = NULL; |
0 | 134 |
135 /* Various local functions */ | |
2876 | 136 static void SDL_UpdateWindowGrab(SDL_Window * 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
|
137 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
138 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
|
139 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
|
140 { |
2753 | 141 SDL_DisplayMode a = *(const SDL_DisplayMode *) A; |
142 SDL_DisplayMode b = *(const SDL_DisplayMode *) B; | |
0 | 143 |
2753 | 144 if (a.w != b.w) { |
145 return b.w - a.w; | |
146 } | |
147 if (a.h != b.h) { | |
148 return b.h - a.h; | |
149 } | |
150 if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) { | |
151 return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format); | |
152 } | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
153 if (SDL_PIXELLAYOUT(a.format) != SDL_PIXELLAYOUT(b.format)) { |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
154 return SDL_PIXELLAYOUT(b.format) - SDL_PIXELLAYOUT(a.format); |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
155 } |
2753 | 156 if (a.refresh_rate != b.refresh_rate) { |
157 return b.refresh_rate - a.refresh_rate; | |
158 } | |
159 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
|
160 } |
0 | 161 |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
162 static void |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
163 SDL_UninitializedVideo() |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
164 { |
2753 | 165 SDL_SetError("Video subsystem has not been initialized"); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
166 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
167 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
168 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
|
169 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
|
170 { |
2753 | 171 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
|
172 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
173 |
2753 | 174 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
|
175 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
|
176 { |
2753 | 177 if (index >= 0 && index < SDL_GetNumVideoDrivers()) { |
178 return bootstrap[index]->name; | |
179 } | |
180 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
|
181 } |
0 | 182 |
183 /* | |
184 * Initialize the video and event subsystems -- determine native pixel format | |
185 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
186 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
|
187 SDL_VideoInit(const char *driver_name, Uint32 flags) |
0 | 188 { |
2753 | 189 SDL_VideoDevice *video; |
190 int index; | |
191 int i; | |
0 | 192 |
2753 | 193 /* 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
|
194 #if defined(MUST_THREAD_EVENTS) |
2753 | 195 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
|
196 #elif defined(CANT_THREAD_EVENTS) |
2753 | 197 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { |
198 SDL_SetError("OS doesn't support threaded events"); | |
199 return -1; | |
200 } | |
1190 | 201 #endif |
229
4d24d5a660a8
Fix a crash if an OpenGL video mode can't be set.
Sam Lantinga <slouken@libsdl.org>
parents:
216
diff
changeset
|
202 |
2753 | 203 /* Start the event loop */ |
204 if (SDL_StartEventLoop(flags) < 0) { | |
205 return -1; | |
206 } | |
207 /* Check to make sure we don't overwrite '_this' */ | |
208 if (_this != NULL) { | |
209 SDL_VideoQuit(); | |
210 } | |
211 /* Select the proper video driver */ | |
212 index = 0; | |
213 video = NULL; | |
214 if (driver_name == NULL) { | |
215 driver_name = SDL_getenv("SDL_VIDEODRIVER"); | |
216 } | |
217 if (driver_name != NULL) { | |
218 for (i = 0; bootstrap[i]; ++i) { | |
219 if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { | |
220 if (bootstrap[i]->available()) { | |
221 video = bootstrap[i]->create(index); | |
222 } | |
223 break; | |
224 } | |
225 } | |
226 } else { | |
227 for (i = 0; bootstrap[i]; ++i) { | |
228 if (bootstrap[i]->available()) { | |
229 video = bootstrap[i]->create(index); | |
230 if (video != NULL) { | |
231 break; | |
232 } | |
233 } | |
234 } | |
235 } | |
236 if (video == NULL) { | |
237 if (driver_name) { | |
238 SDL_SetError("%s not available", driver_name); | |
239 } else { | |
240 SDL_SetError("No available video device"); | |
241 } | |
242 return -1; | |
243 } | |
244 _this = video; | |
245 _this->name = bootstrap[i]->name; | |
246 _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
|
247 |
0 | 248 |
2753 | 249 /* Set some very sane GL defaults */ |
250 _this->gl_config.driver_loaded = 0; | |
251 _this->gl_config.dll_handle = NULL; | |
252 _this->gl_config.red_size = 3; | |
253 _this->gl_config.green_size = 3; | |
254 _this->gl_config.blue_size = 2; | |
255 _this->gl_config.alpha_size = 0; | |
256 _this->gl_config.buffer_size = 0; | |
257 _this->gl_config.depth_size = 16; | |
258 _this->gl_config.stencil_size = 0; | |
259 _this->gl_config.double_buffer = 1; | |
260 _this->gl_config.accum_red_size = 0; | |
261 _this->gl_config.accum_green_size = 0; | |
262 _this->gl_config.accum_blue_size = 0; | |
263 _this->gl_config.accum_alpha_size = 0; | |
264 _this->gl_config.stereo = 0; | |
265 _this->gl_config.multisamplebuffers = 0; | |
266 _this->gl_config.multisamplesamples = 0; | |
267 _this->gl_config.retained_backing = 1; | |
268 _this->gl_config.accelerated = -1; /* not known, don't set */ | |
3100
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
269 _this->gl_config.major_version = 2; |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
270 _this->gl_config.minor_version = 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
|
271 |
2753 | 272 /* Initialize the video subsystem */ |
273 if (_this->VideoInit(_this) < 0) { | |
274 SDL_VideoQuit(); | |
275 return -1; | |
276 } | |
277 /* Make sure some displays were added */ | |
278 if (_this->num_displays == 0) { | |
279 SDL_SetError("The video driver did not add any displays"); | |
280 SDL_VideoQuit(); | |
281 return (-1); | |
282 } | |
283 /* The software renderer is always available */ | |
284 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
|
285 #if SDL_VIDEO_RENDER_OGL |
2753 | 286 SDL_AddRenderDriver(i, &GL_RenderDriver); |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
287 #endif |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
288 |
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
289 #if SDL_VIDEO_RENDER_OGL_ES |
2753 | 290 SDL_AddRenderDriver(i, &GL_ES_RenderDriver); |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
291 #endif |
2753 | 292 if (_this->displays[i].num_render_drivers > 0) { |
293 SDL_AddRenderDriver(i, &SW_RenderDriver); | |
294 } | |
295 } | |
0 | 296 |
2753 | 297 /* We're ready to go! */ |
298 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
|
299 } |
c121d94672cb
SDL 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 |
2753 | 301 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
|
302 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
|
303 { |
2753 | 304 if (!_this) { |
305 SDL_UninitializedVideo(); | |
306 return NULL; | |
307 } | |
308 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
|
309 } |
0 | 310 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
311 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
|
312 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
|
313 { |
2753 | 314 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
|
315 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
317 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
318 SDL_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
|
319 { |
2753 | 320 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
|
321 |
2753 | 322 SDL_zero(display); |
323 if (desktop_mode) { | |
324 display.desktop_mode = *desktop_mode; | |
325 } | |
326 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
|
327 |
2753 | 328 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
|
329 } |
0 | 330 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
331 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
|
332 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
|
333 { |
2753 | 334 SDL_VideoDisplay *displays; |
335 int index = -1; | |
0 | 336 |
2753 | 337 displays = |
338 SDL_realloc(_this->displays, | |
339 (_this->num_displays + 1) * sizeof(*displays)); | |
340 if (displays) { | |
341 index = _this->num_displays++; | |
342 displays[index] = *display; | |
343 displays[index].device = _this; | |
344 _this->displays = displays; | |
345 } else { | |
346 SDL_OutOfMemory(); | |
347 } | |
348 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
|
349 } |
0 | 350 |
1895
c121d94672cb
SDL 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 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
|
352 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
|
353 { |
2753 | 354 if (!_this) { |
355 SDL_UninitializedVideo(); | |
356 return 0; | |
357 } | |
358 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
|
359 } |
0 | 360 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
361 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
|
362 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
|
363 { |
2753 | 364 if (!_this) { |
365 SDL_UninitializedVideo(); | |
366 return (-1); | |
367 } | |
368 if (index < 0 || index >= _this->num_displays) { | |
369 SDL_SetError("index must be in the range 0 - %d", | |
370 _this->num_displays - 1); | |
371 return -1; | |
372 } | |
373 _this->current_display = index; | |
374 return 0; | |
1963
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
375 } |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
376 |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
377 int |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
378 SDL_GetCurrentVideoDisplay(void) |
2590b68531ef
Added SDL_GetCurrentVideoDisplay()
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset
|
379 { |
2753 | 380 if (!_this) { |
381 SDL_UninitializedVideo(); | |
382 return (-1); | |
383 } | |
384 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
|
385 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
386 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
387 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
|
388 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
|
389 { |
2753 | 390 SDL_VideoDisplay *display = &_this->displays[displayIndex]; |
391 SDL_DisplayMode *modes; | |
392 int i, nmodes; | |
910
4ab6d1fd028f
Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
883
diff
changeset
|
393 |
2753 | 394 /* Make sure we don't already have the mode in the list */ |
395 modes = display->display_modes; | |
396 nmodes = display->num_display_modes; | |
397 for (i = nmodes; i--;) { | |
398 if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) { | |
399 return SDL_FALSE; | |
400 } | |
401 } | |
910
4ab6d1fd028f
Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
883
diff
changeset
|
402 |
2753 | 403 /* Go ahead and add the new mode */ |
404 if (nmodes == display->max_display_modes) { | |
405 modes = | |
406 SDL_realloc(modes, | |
407 (display->max_display_modes + 32) * sizeof(*modes)); | |
408 if (!modes) { | |
409 return SDL_FALSE; | |
410 } | |
411 display->display_modes = modes; | |
412 display->max_display_modes += 32; | |
413 } | |
414 modes[nmodes] = *mode; | |
415 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
|
416 |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
417 /* Re-sort video modes */ |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
418 SDL_qsort(display->display_modes, display->num_display_modes, |
3186 | 419 sizeof(SDL_DisplayMode), cmpmodes); |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
420 |
2753 | 421 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
|
422 } |
0 | 423 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
424 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
|
425 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
|
426 { |
2753 | 427 if (_this) { |
428 SDL_VideoDisplay *display = &SDL_CurrentDisplay; | |
429 if (!display->num_display_modes && _this->GetDisplayModes) { | |
430 _this->GetDisplayModes(_this); | |
431 SDL_qsort(display->display_modes, display->num_display_modes, | |
432 sizeof(SDL_DisplayMode), cmpmodes); | |
433 } | |
434 return display->num_display_modes; | |
435 } | |
436 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
|
437 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
438 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
439 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
440 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
|
441 { |
2753 | 442 if (index < 0 || index >= SDL_GetNumDisplayModes()) { |
443 SDL_SetError("index must be in the range of 0 - %d", | |
444 SDL_GetNumDisplayModes() - 1); | |
445 return -1; | |
446 } | |
447 if (mode) { | |
448 *mode = SDL_CurrentDisplay.display_modes[index]; | |
449 } | |
450 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
|
451 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
452 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
453 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
454 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
|
455 { |
2753 | 456 if (!_this) { |
457 SDL_UninitializedVideo(); | |
458 return -1; | |
459 } | |
460 if (mode) { | |
461 *mode = SDL_CurrentDisplay.desktop_mode; | |
462 } | |
463 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
|
464 } |
0 | 465 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
466 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
467 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
|
468 { |
2753 | 469 if (!_this) { |
470 SDL_UninitializedVideo(); | |
471 return -1; | |
472 } | |
473 if (mode) { | |
474 *mode = SDL_CurrentDisplay.current_mode; | |
475 } | |
476 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
|
477 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
478 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
479 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
|
480 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, |
2753 | 481 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
|
482 { |
2753 | 483 Uint32 target_format; |
484 int target_refresh_rate; | |
485 int i; | |
486 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
|
487 |
2753 | 488 if (!_this || !mode || !closest) { |
489 return NULL; | |
490 } | |
491 /* Default to the desktop format */ | |
492 if (mode->format) { | |
493 target_format = mode->format; | |
494 } else { | |
495 target_format = SDL_CurrentDisplay.desktop_mode.format; | |
496 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
497 |
2753 | 498 /* Default to the desktop refresh rate */ |
499 if (mode->refresh_rate) { | |
500 target_refresh_rate = mode->refresh_rate; | |
501 } else { | |
502 target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate; | |
503 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
504 |
2753 | 505 match = NULL; |
506 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { | |
507 current = &SDL_CurrentDisplay.display_modes[i]; | |
0 | 508 |
2789
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
509 if (current->w && (current->w < mode->w)) { |
2753 | 510 /* Out of sorted modes large enough here */ |
511 break; | |
512 } | |
2789
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
513 if (current->h && (current->h < mode->h)) { |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
514 if (current->w && (current->w == mode->w)) { |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
515 /* Out of sorted modes large enough here */ |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
516 break; |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
517 } |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
518 /* Wider, but not tall enough, due to a different |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
519 aspect ratio. This mode must be skipped, but closer |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
520 modes may still follow. */ |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
521 continue; |
985001797115
Fixed bug #605, per Martin's suggestion
Sam Lantinga <slouken@libsdl.org>
parents:
2787
diff
changeset
|
522 } |
2753 | 523 if (!match || current->w < match->w || current->h < match->h) { |
524 match = current; | |
525 continue; | |
526 } | |
527 if (current->format != match->format) { | |
528 /* Sorted highest depth to lowest */ | |
529 if (current->format == target_format || | |
530 (SDL_BITSPERPIXEL(current->format) >= | |
531 SDL_BITSPERPIXEL(target_format) | |
532 && SDL_PIXELTYPE(current->format) == | |
533 SDL_PIXELTYPE(target_format))) { | |
534 match = current; | |
535 } | |
536 continue; | |
537 } | |
538 if (current->refresh_rate != match->refresh_rate) { | |
539 /* Sorted highest refresh to lowest */ | |
540 if (current->refresh_rate >= target_refresh_rate) { | |
541 match = current; | |
542 } | |
543 } | |
544 } | |
545 if (match) { | |
546 if (match->format) { | |
547 closest->format = match->format; | |
548 } else { | |
549 closest->format = mode->format; | |
550 } | |
551 if (match->w && match->h) { | |
552 closest->w = match->w; | |
553 closest->h = match->h; | |
554 } else { | |
555 closest->w = mode->w; | |
556 closest->h = mode->h; | |
557 } | |
558 if (match->refresh_rate) { | |
559 closest->refresh_rate = match->refresh_rate; | |
560 } else { | |
561 closest->refresh_rate = mode->refresh_rate; | |
562 } | |
563 closest->driverdata = match->driverdata; | |
0 | 564 |
2753 | 565 /* |
566 * Pick some reasonable defaults if the app and driver don't | |
567 * care | |
568 */ | |
569 if (!closest->format) { | |
570 closest->format = SDL_PIXELFORMAT_RGB888; | |
571 } | |
572 if (!closest->w) { | |
573 closest->w = 640; | |
574 } | |
575 if (!closest->h) { | |
576 closest->h = 480; | |
577 } | |
578 return closest; | |
579 } | |
580 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
|
581 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
582 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
583 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
|
584 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
|
585 { |
2753 | 586 SDL_VideoDisplay *display; |
587 SDL_DisplayMode display_mode; | |
588 SDL_DisplayMode current_mode; | |
589 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
|
590 |
2753 | 591 if (!_this) { |
592 SDL_UninitializedVideo(); | |
593 return -1; | |
594 } | |
595 display = &SDL_CurrentDisplay; | |
596 if (!mode) { | |
597 mode = &display->desktop_mode; | |
598 } | |
599 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
|
600 |
2753 | 601 /* Default to the current mode */ |
602 if (!display_mode.format) { | |
603 display_mode.format = display->current_mode.format; | |
604 } | |
605 if (!display_mode.w) { | |
606 display_mode.w = display->current_mode.w; | |
607 } | |
608 if (!display_mode.h) { | |
609 display_mode.h = display->current_mode.h; | |
610 } | |
611 if (!display_mode.refresh_rate) { | |
612 display_mode.refresh_rate = display->current_mode.refresh_rate; | |
613 } | |
614 /* Get a good video mode, the closest one possible */ | |
615 if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) { | |
616 SDL_SetError("No video mode large enough for %dx%d", | |
617 display_mode.w, display_mode.h); | |
618 return -1; | |
619 } | |
620 /* See if there's anything left to do */ | |
621 SDL_GetCurrentDisplayMode(¤t_mode); | |
622 if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) { | |
623 return 0; | |
624 } | |
625 /* Actually change the display mode */ | |
626 if (_this->SetDisplayMode(_this, &display_mode) < 0) { | |
627 return -1; | |
628 } | |
629 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
|
630 |
2753 | 631 /* Set up a palette, if necessary */ |
632 if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) { | |
633 ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format)); | |
634 } else { | |
635 ncolors = 0; | |
636 } | |
637 if ((!ncolors && display->palette) || (ncolors && !display->palette) | |
638 || (ncolors && ncolors != display->palette->ncolors)) { | |
639 if (display->palette) { | |
640 SDL_FreePalette(display->palette); | |
641 display->palette = NULL; | |
642 } | |
643 if (ncolors) { | |
644 display->palette = SDL_AllocPalette(ncolors); | |
645 if (!display->palette) { | |
646 return -1; | |
647 } | |
648 SDL_DitherColors(display->palette->colors, | |
649 SDL_BITSPERPIXEL(display_mode.format)); | |
650 } | |
651 } | |
652 /* Move any fullscreen windows into position */ | |
653 for (i = 0; i < display->num_windows; ++i) { | |
654 SDL_Window *window = &display->windows[i]; | |
655 if (FULLSCREEN_VISIBLE(window)) { | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
656 SDL_SetWindowPosition(window->id, window->x, window->y); |
2753 | 657 } |
658 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
659 |
2753 | 660 return 0; |
0 | 661 } |
662 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
663 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
|
664 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
|
665 { |
2753 | 666 SDL_VideoDisplay *display; |
667 SDL_DisplayMode fullscreen_mode; | |
668 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
|
669 |
2753 | 670 if (!_this) { |
671 SDL_UninitializedVideo(); | |
672 return -1; | |
673 } | |
674 display = &SDL_CurrentDisplay; | |
675 if (!mode) { | |
676 mode = &display->desktop_mode; | |
677 } | |
2869
2fe507a2ef7d
Whoops, the X11 driver doesn't support fullscreen modes (yet)
Sam Lantinga <slouken@libsdl.org>
parents:
2860
diff
changeset
|
678 if (!SDL_GetClosestDisplayMode(mode, &fullscreen_mode)) { |
2fe507a2ef7d
Whoops, the X11 driver doesn't support fullscreen modes (yet)
Sam Lantinga <slouken@libsdl.org>
parents:
2860
diff
changeset
|
679 SDL_SetError("Couldn't find display mode match"); |
2fe507a2ef7d
Whoops, the X11 driver doesn't support fullscreen modes (yet)
Sam Lantinga <slouken@libsdl.org>
parents:
2860
diff
changeset
|
680 return -1; |
2fe507a2ef7d
Whoops, the X11 driver doesn't support fullscreen modes (yet)
Sam Lantinga <slouken@libsdl.org>
parents:
2860
diff
changeset
|
681 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3091
diff
changeset
|
682 |
2753 | 683 if (SDL_memcmp |
684 (&fullscreen_mode, &display->fullscreen_mode, | |
685 sizeof(fullscreen_mode)) == 0) { | |
686 /* Nothing to do... */ | |
687 return 0; | |
688 } | |
689 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
|
690 |
2753 | 691 /* Actually set the mode if we have a fullscreen window visible */ |
692 for (i = 0; i < display->num_windows; ++i) { | |
693 SDL_Window *window = &display->windows[i]; | |
694 if (FULLSCREEN_VISIBLE(window)) { | |
695 if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) { | |
696 return -1; | |
697 } | |
698 } | |
699 if (window->flags & SDL_WINDOW_FULLSCREEN) { | |
700 SDL_OnWindowResized(window); | |
701 } | |
702 } | |
703 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
|
704 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
705 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
706 int |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
707 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
|
708 { |
2753 | 709 if (!_this) { |
710 SDL_UninitializedVideo(); | |
711 return -1; | |
712 } | |
713 if (mode) { | |
714 *mode = SDL_CurrentDisplay.fullscreen_mode; | |
715 } | |
716 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
|
717 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 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
|
720 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) |
0 | 721 { |
2753 | 722 SDL_Palette *palette; |
723 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
|
724 |
2753 | 725 if (!_this) { |
726 SDL_UninitializedVideo(); | |
727 return -1; | |
728 } | |
729 palette = SDL_CurrentDisplay.palette; | |
730 if (!palette) { | |
731 SDL_SetError("Display mode does not have a palette"); | |
732 return -1; | |
733 } | |
734 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
|
735 |
2753 | 736 if (_this->SetDisplayPalette) { |
737 if (_this->SetDisplayPalette(_this, palette) < 0) { | |
738 status = -1; | |
739 } | |
740 } | |
741 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
|
742 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
743 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
744 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
|
745 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
|
746 { |
2753 | 747 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
|
748 |
2753 | 749 if (!_this) { |
750 SDL_UninitializedVideo(); | |
751 return -1; | |
752 } | |
753 palette = SDL_CurrentDisplay.palette; | |
754 if (!palette->ncolors) { | |
755 SDL_SetError("Display mode does not have a palette"); | |
756 return -1; | |
757 } | |
758 if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) { | |
759 SDL_SetError("Palette indices are out of range"); | |
760 return -1; | |
761 } | |
762 SDL_memcpy(colors, &palette->colors[firstcolor], | |
763 ncolors * sizeof(*colors)); | |
764 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
|
765 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
766 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
767 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
|
768 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
|
769 { |
2753 | 770 const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | |
771 SDL_WINDOW_OPENGL | | |
772 SDL_WINDOW_BORDERLESS | | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
773 SDL_WINDOW_RESIZABLE | |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
774 SDL_WINDOW_INPUT_GRABBED); |
2753 | 775 SDL_VideoDisplay *display; |
776 SDL_Window window; | |
777 int num_windows; | |
778 SDL_Window *windows; | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
779 |
2753 | 780 if (!_this) { |
781 SDL_UninitializedVideo(); | |
782 return 0; | |
783 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
784 if (flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
785 if (!_this->GL_CreateContext) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
786 SDL_SetError("No OpenGL support in video driver"); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
787 return 0; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
788 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
789 SDL_GL_LoadLibrary(NULL); |
2753 | 790 } |
791 SDL_zero(window); | |
792 window.id = _this->next_object_id++; | |
793 window.x = x; | |
794 window.y = y; | |
795 window.w = w; | |
796 window.h = h; | |
797 window.flags = (flags & allowed_flags); | |
798 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
|
799 |
2753 | 800 if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) { |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
801 if (flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
802 SDL_GL_UnloadLibrary(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
803 } |
2753 | 804 return 0; |
805 } | |
806 display = &SDL_CurrentDisplay; | |
807 num_windows = display->num_windows; | |
808 windows = | |
809 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); | |
810 if (!windows) { | |
811 if (_this->DestroyWindow) { | |
812 _this->DestroyWindow(_this, &window); | |
813 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
814 if (flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
815 SDL_GL_UnloadLibrary(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
816 } |
2753 | 817 return 0; |
818 } | |
819 windows[num_windows] = window; | |
820 display->windows = windows; | |
821 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
|
822 |
2753 | 823 if (title) { |
824 SDL_SetWindowTitle(window.id, title); | |
825 } | |
826 if (flags & SDL_WINDOW_MAXIMIZED) { | |
827 SDL_MaximizeWindow(window.id); | |
828 } | |
829 if (flags & SDL_WINDOW_MINIMIZED) { | |
830 SDL_MinimizeWindow(window.id); | |
831 } | |
832 if (flags & SDL_WINDOW_SHOWN) { | |
833 SDL_ShowWindow(window.id); | |
834 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
835 SDL_UpdateWindowGrab(&window); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
836 |
2753 | 837 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
|
838 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
839 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
840 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
|
841 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
|
842 { |
2753 | 843 SDL_VideoDisplay *display; |
844 SDL_Window window; | |
845 int num_windows; | |
846 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
|
847 |
2753 | 848 if (!_this) { |
849 SDL_UninitializedVideo(); | |
850 return (0); | |
851 } | |
852 SDL_zero(window); | |
853 window.id = _this->next_object_id++; | |
854 window.display = _this->current_display; | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
855 window.flags = SDL_WINDOW_FOREIGN; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
856 |
2753 | 857 if (!_this->CreateWindowFrom || |
858 _this->CreateWindowFrom(_this, &window, data) < 0) { | |
859 return 0; | |
860 } | |
861 display = &SDL_CurrentDisplay; | |
862 num_windows = display->num_windows; | |
863 windows = | |
864 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); | |
865 if (!windows) { | |
866 if (_this->DestroyWindow) { | |
867 _this->DestroyWindow(_this, &window); | |
868 } | |
869 if (window.title) { | |
870 SDL_free(window.title); | |
871 } | |
872 return 0; | |
873 } | |
874 windows[num_windows] = window; | |
875 display->windows = windows; | |
876 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
|
877 |
2753 | 878 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
|
879 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
880 |
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
|
881 int |
1928
861bc36f0ab3
Fixed crash with multiple windows
Sam Lantinga <slouken@libsdl.org>
parents:
1926
diff
changeset
|
882 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
|
883 { |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
884 const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
885 SDL_WINDOW_OPENGL | |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
886 SDL_WINDOW_BORDERLESS | |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
887 SDL_WINDOW_RESIZABLE | |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
888 SDL_WINDOW_INPUT_GRABBED); |
2753 | 889 char *title = window->title; |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
890 |
2753 | 891 if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) { |
892 SDL_SetError("No OpenGL support in video driver"); | |
893 return -1; | |
894 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
895 if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
896 if (flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
897 SDL_GL_LoadLibrary(NULL); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
898 } else { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
899 SDL_GL_UnloadLibrary(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
900 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
901 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
902 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
903 if (window->flags & SDL_WINDOW_FOREIGN) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
904 /* Can't destroy and re-create foreign windows, hrm */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
905 flags |= SDL_WINDOW_FOREIGN; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
906 } else { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
907 flags &= ~SDL_WINDOW_FOREIGN; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
908 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
909 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
910 if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) { |
2753 | 911 _this->DestroyWindow(_this, window); |
912 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
913 |
2753 | 914 window->title = NULL; |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
915 window->flags = (flags & allowed_flags); |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
916 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
917 if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
918 if (_this->CreateWindow(_this, window) < 0) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
919 if (flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
920 SDL_GL_UnloadLibrary(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
921 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
922 return -1; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
923 } |
2753 | 924 } |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
925 |
2753 | 926 if (title) { |
927 SDL_SetWindowTitle(window->id, title); | |
928 SDL_free(title); | |
929 } | |
930 if (flags & SDL_WINDOW_MAXIMIZED) { | |
931 SDL_MaximizeWindow(window->id); | |
932 } | |
933 if (flags & SDL_WINDOW_MINIMIZED) { | |
934 SDL_MinimizeWindow(window->id); | |
935 } | |
936 if (flags & SDL_WINDOW_SHOWN) { | |
937 SDL_ShowWindow(window->id); | |
938 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
939 SDL_UpdateWindowGrab(window); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
940 |
2753 | 941 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
|
942 } |
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
|
943 |
2753 | 944 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
|
945 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
|
946 { |
2753 | 947 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
|
948 |
2753 | 949 if (!_this) { |
950 SDL_UninitializedVideo(); | |
951 return NULL; | |
952 } | |
953 for (i = 0; i < _this->num_displays; ++i) { | |
954 SDL_VideoDisplay *display = &_this->displays[i]; | |
955 for (j = 0; j < display->num_windows; ++j) { | |
956 SDL_Window *window = &display->windows[j]; | |
957 if (window->id == windowID) { | |
958 return window; | |
959 } | |
960 } | |
961 } | |
962 return NULL; | |
0 | 963 } |
964 | |
1895
c121d94672cb
SDL 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 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
|
966 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
|
967 { |
2753 | 968 if (!_this) { |
969 SDL_UninitializedVideo(); | |
970 return NULL; | |
971 } | |
972 if (!window) { | |
973 return NULL; | |
974 } | |
975 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
|
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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
978 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
|
979 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
|
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 0; | |
985 } | |
986 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
|
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_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
|
991 { |
2753 | 992 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset
|
993 |
2753 | 994 if (!window || title == window->title) { |
995 return; | |
996 } | |
997 if (window->title) { | |
998 SDL_free(window->title); | |
999 } | |
1000 if (title) { | |
1001 window->title = SDL_strdup(title); | |
1002 } else { | |
1003 window->title = NULL; | |
1004 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1005 |
2753 | 1006 if (_this->SetWindowTitle) { |
1007 _this->SetWindowTitle(_this, window); | |
1008 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1009 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1010 |
2753 | 1011 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
|
1012 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
|
1013 { |
2753 | 1014 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
|
1015 |
2753 | 1016 if (!window) { |
1017 return NULL; | |
1018 } | |
1019 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
|
1020 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1021 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1022 void |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1023 SDL_SetWindowIcon(SDL_WindowID windowID, SDL_Surface * icon) |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1024 { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1025 SDL_Window *window = SDL_GetWindowFromID(windowID); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1026 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1027 if (!window) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1028 return; |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1029 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1030 if (_this->SetWindowIcon) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1031 _this->SetWindowIcon(_this, window, icon); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1032 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1033 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1034 |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1035 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
|
1036 SDL_SetWindowData(SDL_WindowID windowID, void *userdata) |
0 | 1037 { |
2753 | 1038 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
|
1039 |
2753 | 1040 if (!window) { |
1041 return; | |
1042 } | |
1043 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
|
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 |
2753 | 1046 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
|
1047 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
|
1048 { |
2753 | 1049 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
|
1050 |
2753 | 1051 if (!window) { |
1052 return NULL; | |
1053 } | |
1054 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
|
1055 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1056 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1057 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
|
1058 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
|
1059 { |
2753 | 1060 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1061 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
0 | 1062 |
2753 | 1063 if (!window) { |
1064 return; | |
1065 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1066 if (x != SDL_WINDOWPOS_UNDEFINED) { |
2753 | 1067 window->x = x; |
1068 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1069 if (y != SDL_WINDOWPOS_UNDEFINED) { |
2753 | 1070 window->y = y; |
1071 } | |
1072 if (_this->SetWindowPosition) { | |
1073 _this->SetWindowPosition(_this, window); | |
1074 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1075 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MOVED, x, y); |
1895
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 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 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
|
1079 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
|
1080 { |
2753 | 1081 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
|
1082 |
2753 | 1083 if (!window) { |
1084 return; | |
1085 } | |
1086 if (x) { | |
1087 *x = window->x; | |
1088 } | |
1089 if (y) { | |
1090 *y = window->y; | |
1091 } | |
1895
c121d94672cb
SDL 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 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1094 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
|
1095 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
|
1096 { |
2753 | 1097 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 1098 |
2753 | 1099 if (!window) { |
1100 return; | |
1101 } | |
1102 window->w = w; | |
1103 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
|
1104 |
2753 | 1105 if (_this->SetWindowSize) { |
1106 _this->SetWindowSize(_this, window); | |
1107 } | |
2849
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1108 SDL_OnWindowResized(window); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1109 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1110 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1111 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
|
1112 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
|
1113 { |
2753 | 1114 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
|
1115 |
2860
6ce28e5287e9
Date: Sun, 07 Dec 2008 13:35:23 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
1116 if (window) { |
2849
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1117 if (w) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1118 *w = window->w; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1119 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1120 if (h) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1121 *h = window->h; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1122 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1123 } else { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1124 if (w) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1125 *w = 0; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1126 } |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1127 if (h) { |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1128 *h = 0; |
523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1129 } |
2753 | 1130 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1131 } |
c121d94672cb
SDL 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 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
|
1134 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
|
1135 { |
2753 | 1136 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
|
1137 |
2753 | 1138 if (!window || (window->flags & SDL_WINDOW_SHOWN)) { |
1139 return; | |
1140 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1141 |
2753 | 1142 if (_this->ShowWindow) { |
1143 _this->ShowWindow(_this, window); | |
1144 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1145 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
|
1146 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1147 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1148 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
|
1149 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
|
1150 { |
2753 | 1151 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
|
1152 |
2753 | 1153 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1154 return; | |
1155 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1156 |
2753 | 1157 if (_this->HideWindow) { |
1158 _this->HideWindow(_this, window); | |
1159 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1160 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
|
1161 } |
0 | 1162 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1163 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
|
1164 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
|
1165 { |
2753 | 1166 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1167 |
2753 | 1168 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { |
1169 return; | |
1170 } | |
1171 if (_this->RaiseWindow) { | |
1172 _this->RaiseWindow(_this, window); | |
1173 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1174 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1175 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1176 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
|
1177 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
|
1178 { |
2753 | 1179 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
|
1180 |
2753 | 1181 if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) { |
1182 return; | |
1183 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1184 |
2753 | 1185 if (_this->MaximizeWindow) { |
1186 _this->MaximizeWindow(_this, window); | |
1187 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1188 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
|
1189 } |
0 | 1190 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1191 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_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
|
1193 { |
2753 | 1194 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
|
1195 |
2753 | 1196 if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) { |
1197 return; | |
1198 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1199 |
2753 | 1200 if (_this->MinimizeWindow) { |
1201 _this->MinimizeWindow(_this, window); | |
1202 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1203 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
|
1204 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1205 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1206 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
|
1207 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
|
1208 { |
2753 | 1209 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
|
1210 |
2753 | 1211 if (!window |
2934
1fcc36adc73d
Fixed logic problem with SDL_RestoreWindow()
Sam Lantinga <slouken@libsdl.org>
parents:
2928
diff
changeset
|
1212 || !(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { |
2753 | 1213 return; |
1214 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1215 |
2753 | 1216 if (_this->RestoreWindow) { |
1217 _this->RestoreWindow(_this, window); | |
1218 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1219 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0); |
0 | 1220 } |
1221 | |
1895
c121d94672cb
SDL 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 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
|
1223 SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen) |
0 | 1224 { |
2753 | 1225 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
|
1226 |
2753 | 1227 if (!window) { |
1228 return -1; | |
1229 } | |
1230 if (fullscreen) { | |
1231 fullscreen = SDL_WINDOW_FULLSCREEN; | |
1232 } | |
1233 if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) { | |
1234 return 0; | |
1235 } | |
1236 if (fullscreen) { | |
1237 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
|
1238 |
2753 | 1239 if (FULLSCREEN_VISIBLE(window)) { |
1240 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
|
1241 |
2753 | 1242 /* Hide any other fullscreen windows */ |
1243 int i; | |
1244 for (i = 0; i < display->num_windows; ++i) { | |
1245 SDL_Window *other = &display->windows[i]; | |
1246 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { | |
1247 SDL_MinimizeWindow(other->id); | |
1248 } | |
1249 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1250 |
2753 | 1251 SDL_SetDisplayMode(&display->fullscreen_mode); |
1252 } | |
1253 } else { | |
1254 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
|
1255 |
2753 | 1256 if (FULLSCREEN_VISIBLE(window)) { |
1257 SDL_SetDisplayMode(NULL); | |
1258 } | |
1259 } | |
1260 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
|
1261 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1262 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1263 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1264 SDL_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
|
1265 { |
2753 | 1266 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 1267 |
2753 | 1268 if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { |
1269 return; | |
1270 } | |
1271 if (mode) { | |
1272 window->flags |= SDL_WINDOW_INPUT_GRABBED; | |
1273 } else { | |
1274 window->flags &= ~SDL_WINDOW_INPUT_GRABBED; | |
1275 } | |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1276 SDL_UpdateWindowGrab(window); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1277 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1278 |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1279 static void |
2876 | 1280 SDL_UpdateWindowGrab(SDL_Window * window) |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1281 { |
2753 | 1282 if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) { |
1283 _this->SetWindowGrab(_this, window); | |
1284 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1285 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1286 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1287 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
|
1288 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
|
1289 { |
2753 | 1290 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
|
1291 |
2753 | 1292 if (!window) { |
1293 return 0; | |
1294 } | |
1295 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
|
1296 } |
0 | 1297 |
1895
c121d94672cb
SDL 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 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
|
1299 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
|
1300 { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1301 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1302 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1303 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1304 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1305 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1306 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
|
1307 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
|
1308 { |
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1309 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1310 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); |
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2869
diff
changeset
|
1311 } |
0 | 1312 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1313 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1314 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
|
1315 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
|
1316 { |
2753 | 1317 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
|
1318 |
2753 | 1319 if (renderer && renderer->DisplayModeChanged) { |
1320 renderer->DisplayModeChanged(renderer); | |
1321 } | |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1322 } |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1323 |
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
1324 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
|
1325 SDL_OnWindowFocusGained(SDL_Window * window) |
0 | 1326 { |
2753 | 1327 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
|
1328 |
2753 | 1329 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1330 SDL_SetDisplayMode(&display->fullscreen_mode); | |
1331 } | |
1332 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1333 _this->SetDisplayGammaRamp(_this, display->gamma); | |
1334 } | |
2876 | 1335 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) |
1336 && _this->SetWindowGrab) { | |
2753 | 1337 _this->SetWindowGrab(_this, window); |
1338 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1339 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1340 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1341 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
|
1342 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
|
1343 { |
2753 | 1344 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
0 | 1345 |
2753 | 1346 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1347 SDL_MinimizeWindow(window->id); | |
1348 SDL_SetDisplayMode(NULL); | |
1349 } | |
1350 if (display->gamma && _this->SetDisplayGammaRamp) { | |
1351 _this->SetDisplayGammaRamp(_this, display->saved_gamma); | |
1352 } | |
2876 | 1353 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) |
1354 && _this->SetWindowGrab) { | |
2753 | 1355 _this->SetWindowGrab(_this, window); |
1356 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1357 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1359 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
|
1360 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
|
1361 { |
2753 | 1362 SDL_VideoDisplay *display; |
1363 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
|
1364 |
2753 | 1365 if (!_this) { |
1366 return 0; | |
1367 } | |
1368 display = &SDL_CurrentDisplay; | |
1369 for (i = 0; i < display->num_windows; ++i) { | |
1370 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
|
1371 |
2753 | 1372 if (window->flags & SDL_WINDOW_INPUT_FOCUS) { |
1373 return window->id; | |
1374 } | |
1375 } | |
1376 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
|
1377 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1378 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1379 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
|
1380 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
|
1381 { |
2753 | 1382 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
|
1383 |
2753 | 1384 if (!_this) { |
1385 return; | |
1386 } | |
1387 /* Restore video mode, etc. */ | |
1388 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); | |
0 | 1389 |
2753 | 1390 for (i = 0; i < _this->num_displays; ++i) { |
1391 SDL_VideoDisplay *display = &_this->displays[i]; | |
1392 for (j = 0; j < display->num_windows; ++j) { | |
1393 SDL_Window *window = &display->windows[j]; | |
1394 if (window->id != windowID) { | |
1395 continue; | |
1396 } | |
1397 if (window->title) { | |
1398 SDL_free(window->title); | |
1399 window->title = NULL; | |
1400 } | |
1401 if (window->renderer) { | |
1402 SDL_DestroyRenderer(window->id); | |
1403 window->renderer = NULL; | |
1404 } | |
1405 if (_this->DestroyWindow) { | |
1406 _this->DestroyWindow(_this, window); | |
1407 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1408 if (window->flags & SDL_WINDOW_OPENGL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1409 SDL_GL_UnloadLibrary(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1410 } |
2753 | 1411 if (j != display->num_windows - 1) { |
1412 SDL_memcpy(&display->windows[i], | |
1413 &display->windows[i + 1], | |
1414 (display->num_windows - i - 1) * sizeof(*window)); | |
1415 } | |
1416 --display->num_windows; | |
1417 return; | |
1418 } | |
1419 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1420 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1421 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1422 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
|
1423 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
|
1424 { |
2753 | 1425 SDL_VideoDisplay *display; |
1426 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
|
1427 |
2753 | 1428 if (displayIndex >= _this->num_displays) { |
1429 return; | |
1430 } | |
1431 display = &_this->displays[displayIndex]; | |
2119
9341a884a4d9
Fixed running on Windows under VMware
Sam Lantinga <slouken@libsdl.org>
parents:
2075
diff
changeset
|
1432 |
2753 | 1433 render_drivers = |
1434 SDL_realloc(display->render_drivers, | |
1435 (display->num_render_drivers + | |
1436 1) * sizeof(*render_drivers)); | |
1437 if (render_drivers) { | |
1438 render_drivers[display->num_render_drivers] = *driver; | |
1439 display->render_drivers = render_drivers; | |
1440 display->num_render_drivers++; | |
1441 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1442 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1443 |
c121d94672cb
SDL 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 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1445 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
|
1446 { |
2753 | 1447 if (_this) { |
1448 return SDL_CurrentDisplay.num_render_drivers; | |
1449 } | |
1450 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
|
1451 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1452 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1453 int |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1454 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
|
1455 { |
2753 | 1456 if (!_this) { |
1457 SDL_UninitializedVideo(); | |
1458 return -1; | |
1459 } | |
1460 if (index < 0 || index >= SDL_GetNumRenderDrivers()) { | |
1461 SDL_SetError("index must be in the range of 0 - %d", | |
1462 SDL_GetNumRenderDrivers() - 1); | |
1463 return -1; | |
1464 } | |
1465 *info = SDL_CurrentDisplay.render_drivers[index].info; | |
1466 return 0; | |
0 | 1467 } |
1468 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1469 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
|
1470 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags) |
0 | 1471 { |
2753 | 1472 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
|
1473 |
2753 | 1474 if (!window) { |
3091
32efcc94b3da
Fixed return value for SDL_CreateRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1475 SDL_SetError("Invalid window ID"); |
32efcc94b3da
Fixed return value for SDL_CreateRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1476 return -1; |
2753 | 1477 } |
1478 if (index < 0) { | |
1479 const char *override = SDL_getenv("SDL_VIDEO_RENDERER"); | |
1480 int n = SDL_GetNumRenderDrivers(); | |
1481 for (index = 0; index < n; ++index) { | |
1482 SDL_RenderDriver *driver = | |
1483 &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
|
1484 |
2753 | 1485 if (override) { |
1486 if (SDL_strcasecmp(override, driver->info.name) == 0) { | |
1487 break; | |
1488 } | |
1489 } else { | |
1490 if ((driver->info.flags & flags) == flags) { | |
1491 break; | |
1492 } | |
1493 } | |
1494 } | |
1495 if (index == n) { | |
1496 SDL_SetError("Couldn't find matching render driver"); | |
1497 return -1; | |
1498 } | |
1499 } | |
1500 if (index >= SDL_GetNumRenderDrivers()) { | |
1501 SDL_SetError("index must be -1 or in the range of 0 - %d", | |
1502 SDL_GetNumRenderDrivers() - 1); | |
1503 return -1; | |
1504 } | |
1505 /* Free any existing renderer */ | |
1506 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
|
1507 |
2753 | 1508 /* Create a new renderer instance */ |
1509 window->renderer = SDL_CurrentDisplay.render_drivers[index] | |
1510 .CreateRenderer(window, flags); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3091
diff
changeset
|
1511 |
3139 | 1512 if (window->renderer == NULL) { |
1513 /* Assuming renderer set its error */ | |
1514 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3091
diff
changeset
|
1515 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3091
diff
changeset
|
1516 |
2753 | 1517 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
|
1518 |
2753 | 1519 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
|
1520 } |
0 | 1521 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1522 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
|
1523 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
|
1524 { |
2753 | 1525 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1526 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
|
1527 |
2753 | 1528 if (!window || !window->renderer) { |
1529 return -1; | |
1530 } | |
1531 renderer = window->renderer; | |
1532 if (renderer && renderer->ActivateRenderer) { | |
1533 if (renderer->ActivateRenderer(renderer) < 0) { | |
1534 return -1; | |
1535 } | |
1536 } | |
1537 SDL_CurrentDisplay.current_renderer = renderer; | |
1538 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
|
1539 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1540 |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1541 int |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1542 SDL_GetRendererInfo(SDL_RendererInfo * info) |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1543 { |
2753 | 1544 if (!_this) { |
1545 SDL_UninitializedVideo(); | |
1546 return -1; | |
1547 } | |
1548 if (!SDL_CurrentDisplay.current_renderer) { | |
1549 SDL_SetError("There is no current renderer"); | |
1550 return -1; | |
1551 } | |
1552 *info = SDL_CurrentDisplay.current_renderer->info; | |
1553 return 0; | |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1554 } |
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
1555 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1556 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
|
1557 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
|
1558 { |
2753 | 1559 int hash; |
1560 SDL_Renderer *renderer; | |
1561 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
|
1562 |
2753 | 1563 if (!_this) { |
1564 SDL_UninitializedVideo(); | |
1565 return 0; | |
1566 } | |
1567 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1568 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1569 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1570 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1571 if (!renderer->CreateTexture) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1572 SDL_Unsupported(); |
2753 | 1573 return 0; |
1574 } | |
1575 texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); | |
1576 if (!texture) { | |
1577 SDL_OutOfMemory(); | |
1578 return 0; | |
1579 } | |
1580 texture->id = _this->next_object_id++; | |
1581 texture->format = format; | |
1582 texture->access = access; | |
1583 texture->w = w; | |
1584 texture->h = h; | |
1585 texture->r = 255; | |
1586 texture->g = 255; | |
1587 texture->b = 255; | |
1588 texture->a = 255; | |
1589 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
|
1590 |
2753 | 1591 if (renderer->CreateTexture(renderer, texture) < 0) { |
1592 if (renderer->DestroyTexture) { | |
1593 renderer->DestroyTexture(renderer, texture); | |
1594 } | |
1595 SDL_free(texture); | |
1596 return 0; | |
1597 } | |
1598 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1599 texture->next = SDL_CurrentDisplay.textures[hash]; | |
1600 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
|
1601 |
2753 | 1602 return texture->id; |
0 | 1603 } |
1604 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1605 SDL_TextureID |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1606 SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) |
0 | 1607 { |
2753 | 1608 SDL_TextureID textureID; |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1609 Uint32 requested_format = format; |
2753 | 1610 SDL_PixelFormat *fmt; |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1611 SDL_Renderer *renderer; |
2753 | 1612 int bpp; |
1613 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
|
1614 |
2753 | 1615 if (!surface) { |
1616 SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); | |
1617 return 0; | |
1618 } | |
1619 fmt = surface->format; | |
0 | 1620 |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1621 renderer = SDL_CurrentDisplay.current_renderer; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1622 if (!renderer) { |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1623 return 0; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1624 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1625 |
2753 | 1626 if (format) { |
1627 if (!SDL_PixelFormatEnumToMasks | |
1628 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { | |
1629 SDL_SetError("Unknown pixel format"); | |
1630 return 0; | |
1631 } | |
1632 } else { | |
1633 if (surface->format->Amask | |
1634 || !(surface->map->info.flags & | |
1635 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) { | |
3196
413672b09bb3
Fixed some compile errors and warnings under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3186
diff
changeset
|
1636 Uint32 it; |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1637 int pfmt; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1638 |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1639 /* Pixel formats, sorted by best first */ |
3186 | 1640 static const Uint32 sdl_pformats[] = { |
1641 SDL_PIXELFORMAT_ARGB8888, | |
1642 SDL_PIXELFORMAT_RGBA8888, | |
1643 SDL_PIXELFORMAT_ABGR8888, | |
1644 SDL_PIXELFORMAT_BGRA8888, | |
1645 SDL_PIXELFORMAT_RGB888, | |
1646 SDL_PIXELFORMAT_BGR888, | |
1647 SDL_PIXELFORMAT_RGB24, | |
1648 SDL_PIXELFORMAT_BGR24, | |
1649 SDL_PIXELFORMAT_RGB565, | |
1650 SDL_PIXELFORMAT_BGR565, | |
1651 SDL_PIXELFORMAT_ARGB1555, | |
1652 SDL_PIXELFORMAT_ABGR1555, | |
1653 SDL_PIXELFORMAT_RGB555, | |
1654 SDL_PIXELFORMAT_BGR555, | |
1655 SDL_PIXELFORMAT_ARGB4444, | |
1656 SDL_PIXELFORMAT_ABGR4444, | |
1657 SDL_PIXELFORMAT_RGB444, | |
1658 SDL_PIXELFORMAT_ARGB2101010, | |
1659 SDL_PIXELFORMAT_INDEX8, | |
1660 SDL_PIXELFORMAT_INDEX4LSB, | |
1661 SDL_PIXELFORMAT_INDEX4MSB, | |
1662 SDL_PIXELFORMAT_RGB332, | |
1663 SDL_PIXELFORMAT_INDEX1LSB, | |
1664 SDL_PIXELFORMAT_INDEX1MSB, | |
1665 SDL_PIXELFORMAT_UNKNOWN | |
1666 }; | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1667 |
2753 | 1668 bpp = fmt->BitsPerPixel; |
1669 Rmask = fmt->Rmask; | |
1670 Gmask = fmt->Gmask; | |
1671 Bmask = fmt->Bmask; | |
1672 Amask = fmt->Amask; | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1673 |
3186 | 1674 format = |
1675 SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1676 if (!format) { |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1677 SDL_SetError("Unknown pixel format"); |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1678 return 0; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1679 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1680 |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1681 /* Search requested format in the supported texture */ |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1682 /* formats by current renderer */ |
3186 | 1683 for (it = 0; it < renderer->info.num_texture_formats; it++) { |
1684 if (renderer->info.texture_formats[it] == format) { | |
1685 break; | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1686 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1687 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1688 |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1689 /* If requested format can't be found, search any best */ |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1690 /* format which renderer provides */ |
3186 | 1691 if (it == renderer->info.num_texture_formats) { |
1692 pfmt = 0; | |
1693 for (;;) { | |
1694 if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) { | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1695 break; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1696 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1697 |
3186 | 1698 for (it = 0; it < renderer->info.num_texture_formats; |
1699 it++) { | |
1700 if (renderer->info.texture_formats[it] == | |
1701 sdl_pformats[pfmt]) { | |
1702 break; | |
1703 } | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1704 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1705 |
3186 | 1706 if (it != renderer->info.num_texture_formats) { |
1707 /* The best format has been found */ | |
1708 break; | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1709 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1710 pfmt++; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1711 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1712 |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1713 /* If any format can't be found, then return an error */ |
3186 | 1714 if (it == renderer->info.num_texture_formats) { |
1715 SDL_SetError | |
1716 ("Any of the supported pixel formats can't be found"); | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1717 return 0; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1718 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1719 |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1720 /* Convert found pixel format back to color masks */ |
3186 | 1721 if (SDL_PixelFormatEnumToMasks |
1722 (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask, | |
1723 &Bmask, &Amask) != SDL_TRUE) { | |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1724 SDL_SetError("Unknown pixel format"); |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1725 return 0; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1726 } |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1727 } |
2753 | 1728 } else { |
1729 /* Need a format with alpha */ | |
3196
413672b09bb3
Fixed some compile errors and warnings under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
3186
diff
changeset
|
1730 Uint32 it; |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1731 int apfmt; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1732 |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1733 /* Pixel formats with alpha, sorted by best first */ |
3169 | 1734 static const Uint32 sdl_alpha_pformats[] = { |
1735 SDL_PIXELFORMAT_ARGB8888, | |
1736 SDL_PIXELFORMAT_RGBA8888, | |
1737 SDL_PIXELFORMAT_ABGR8888, | |
1738 SDL_PIXELFORMAT_BGRA8888, | |
1739 SDL_PIXELFORMAT_ARGB1555, | |
1740 SDL_PIXELFORMAT_ABGR1555, | |
1741 SDL_PIXELFORMAT_ARGB4444, | |
1742 SDL_PIXELFORMAT_ABGR4444, | |
1743 SDL_PIXELFORMAT_ARGB2101010, | |
1744 SDL_PIXELFORMAT_UNKNOWN | |
1745 }; | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1746 |
3178
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1747 if (surface->format->Amask) { |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1748 /* If surface already has alpha, then try an original */ |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1749 /* surface format first */ |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1750 bpp = fmt->BitsPerPixel; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1751 Rmask = fmt->Rmask; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1752 Gmask = fmt->Gmask; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1753 Bmask = fmt->Bmask; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1754 Amask = fmt->Amask; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1755 } else { |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1756 bpp = 32; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1757 Rmask = 0x00FF0000; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1758 Gmask = 0x0000FF00; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1759 Bmask = 0x000000FF; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1760 Amask = 0xFF000000; |
72edc980789b
1. SDL_CreateTextureFromSurface() now tries to find surface's pixel format.
Mike Gorchak <lestat@i.com.ua>
parents:
3169
diff
changeset
|
1761 } |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1762 |
3169 | 1763 format = |
1764 SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1765 if (!format) { |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1766 SDL_SetError("Unknown pixel format"); |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1767 return 0; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1768 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1769 |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1770 /* Search this format in the supported texture formats */ |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1771 /* by current renderer */ |
3169 | 1772 for (it = 0; it < renderer->info.num_texture_formats; it++) { |
1773 if (renderer->info.texture_formats[it] == format) { | |
1774 break; | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1775 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1776 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1777 |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1778 /* If this format can't be found, search any best */ |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1779 /* compatible format with alpha which renderer provides */ |
3169 | 1780 if (it == renderer->info.num_texture_formats) { |
1781 apfmt = 0; | |
1782 for (;;) { | |
1783 if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) { | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1784 break; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1785 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1786 |
3169 | 1787 for (it = 0; it < renderer->info.num_texture_formats; |
1788 it++) { | |
1789 if (renderer->info.texture_formats[it] == | |
1790 sdl_alpha_pformats[apfmt]) { | |
1791 break; | |
1792 } | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1793 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1794 |
3169 | 1795 if (it != renderer->info.num_texture_formats) { |
1796 /* Compatible format has been found */ | |
1797 break; | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1798 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1799 apfmt++; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1800 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1801 |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1802 /* If compatible format can't be found, then return an error */ |
3169 | 1803 if (it == renderer->info.num_texture_formats) { |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1804 SDL_SetError("Compatible pixel format can't be found"); |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1805 return 0; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1806 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1807 |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1808 /* Convert found pixel format back to color masks */ |
3169 | 1809 if (SDL_PixelFormatEnumToMasks |
1810 (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask, | |
1811 &Bmask, &Amask) != SDL_TRUE) { | |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1812 SDL_SetError("Unknown pixel format"); |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1813 return 0; |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1814 } |
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1815 } |
2753 | 1816 } |
3166
3a63a5824557
Best pixel formats with alpha search code has been added to function which converts surface to texture with enabled color keys. Now "testsprite2 --renderer opengl_es" works fine with all pixel formats with alpha. This affects other renderers too.
Mike Gorchak <lestat@i.com.ua>
parents:
3162
diff
changeset
|
1817 |
2753 | 1818 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); |
1819 if (!format) { | |
1820 SDL_SetError("Unknown pixel format"); | |
1821 return 0; | |
1822 } | |
1823 } | |
0 | 1824 |
2753 | 1825 textureID = |
1826 SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, | |
1827 surface->h); | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1828 if (!textureID && !requested_format) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1829 SDL_DisplayMode desktop_mode; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1830 SDL_GetDesktopDisplayMode(&desktop_mode); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1831 format = desktop_mode.format; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1832 textureID = |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1833 SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1834 surface->h); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
1835 } |
2753 | 1836 if (!textureID) { |
1837 return 0; | |
1838 } | |
1839 if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask | |
1840 && Bmask == fmt->Bmask && Amask == fmt->Amask) { | |
1841 if (SDL_MUSTLOCK(surface)) { | |
1842 if (SDL_LockSurface(surface) < 0) { | |
1843 SDL_DestroyTexture(textureID); | |
1844 return 0; | |
1845 } | |
1846 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1847 surface->pitch); | |
1848 SDL_UnlockSurface(surface); | |
1849 } else { | |
1850 SDL_UpdateTexture(textureID, NULL, surface->pixels, | |
1851 surface->pitch); | |
1852 } | |
1853 } else { | |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1854 SDL_PixelFormat dst_fmt; |
2753 | 1855 SDL_Surface *dst = NULL; |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
2130
diff
changeset
|
1856 |
2753 | 1857 /* Set up a destination surface for the texture update */ |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1858 SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1859 if (SDL_ISPIXELFORMAT_INDEXED(format)) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1860 dst_fmt.palette = |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1861 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1862 if (dst_fmt.palette) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1863 /* |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1864 * FIXME: Should we try to copy |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1865 * fmt->palette? |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1866 */ |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1867 SDL_DitherColors(dst_fmt.palette->colors, |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1868 SDL_BITSPERPIXEL(format)); |
2753 | 1869 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1870 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1871 dst = SDL_ConvertSurface(surface, &dst_fmt, 0); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1872 if (dst) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1873 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1874 SDL_FreeSurface(dst); |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1875 } |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1876 if (dst_fmt.palette) { |
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2934
diff
changeset
|
1877 SDL_FreePalette(dst_fmt.palette); |
2753 | 1878 } |
1879 if (!dst) { | |
1880 SDL_DestroyTexture(textureID); | |
1881 return 0; | |
1882 } | |
1883 } | |
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
|
1884 |
3053
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1885 { |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1886 Uint8 r, g, b, a; |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1887 int blendMode; |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1888 int scaleMode; |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1889 |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1890 SDL_GetSurfaceColorMod(surface, &r, &g, &b); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1891 SDL_SetTextureColorMod(textureID, r, g, b); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1892 |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1893 SDL_GetSurfaceAlphaMod(surface, &a); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1894 SDL_SetTextureAlphaMod(textureID, a); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1895 |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1896 SDL_GetSurfaceBlendMode(surface, &blendMode); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1897 SDL_SetTextureBlendMode(textureID, blendMode); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1898 |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1899 SDL_GetSurfaceScaleMode(surface, &scaleMode); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1900 SDL_SetTextureScaleMode(textureID, scaleMode); |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1901 } |
aa34d1180d30
When creating a software texture, synchronize the surface with the texture.
Sam Lantinga <slouken@libsdl.org>
parents:
3029
diff
changeset
|
1902 |
2753 | 1903 if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { |
1904 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, | |
1905 fmt->palette->ncolors); | |
1906 } | |
1907 return textureID; | |
0 | 1908 } |
1909 | |
1895
c121d94672cb
SDL 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 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
|
1911 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
|
1912 { |
2753 | 1913 int hash; |
1914 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
|
1915 |
2753 | 1916 if (!_this) { |
1917 return NULL; | |
1918 } | |
1919 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
1920 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
1921 texture = texture->next) { | |
1922 if (texture->id == textureID) { | |
1923 return texture; | |
1924 } | |
1925 } | |
1926 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
|
1927 } |
c121d94672cb
SDL 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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1929 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
|
1930 SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access, |
2753 | 1931 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
|
1932 { |
2753 | 1933 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
|
1934 |
2753 | 1935 if (!texture) { |
1936 return -1; | |
1937 } | |
1938 if (format) { | |
1939 *format = texture->format; | |
1940 } | |
1941 if (access) { | |
1942 *access = texture->access; | |
1943 } | |
1944 if (w) { | |
1945 *w = texture->w; | |
1946 } | |
1947 if (h) { | |
1948 *h = texture->h; | |
1949 } | |
1950 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
|
1951 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1952 |
c121d94672cb
SDL 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 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
|
1954 SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch) |
0 | 1955 { |
2753 | 1956 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1957 SDL_Renderer *renderer; | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1958 |
2753 | 1959 if (!texture) { |
1960 return -1; | |
1961 } | |
1962 renderer = texture->renderer; | |
1963 if (!renderer->QueryTexturePixels) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1964 SDL_Unsupported(); |
2753 | 1965 return -1; |
1966 } | |
1967 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
|
1968 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1969 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1970 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
|
1971 SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, |
2753 | 1972 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
|
1973 { |
2753 | 1974 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1975 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
|
1976 |
2753 | 1977 if (!texture) { |
1978 return -1; | |
1979 } | |
1980 renderer = texture->renderer; | |
1981 if (!renderer->SetTexturePalette) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
1982 SDL_Unsupported(); |
2753 | 1983 return -1; |
1984 } | |
1985 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, | |
1986 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
|
1987 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1988 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
1989 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
|
1990 SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, |
2753 | 1991 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
|
1992 { |
2753 | 1993 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1994 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
|
1995 |
2753 | 1996 if (!texture) { |
1997 return -1; | |
1998 } | |
1999 renderer = texture->renderer; | |
2000 if (!renderer->GetTexturePalette) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2001 SDL_Unsupported(); |
2753 | 2002 return -1; |
2003 } | |
2004 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, | |
2005 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
|
2006 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2007 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2008 int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2009 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
|
2010 { |
2753 | 2011 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2012 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2013 |
2753 | 2014 if (!texture) { |
2015 return -1; | |
2016 } | |
2017 renderer = texture->renderer; | |
2018 if (!renderer->SetTextureColorMod) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2019 SDL_Unsupported(); |
2753 | 2020 return -1; |
2021 } | |
2022 if (r < 255 || g < 255 || b < 255) { | |
2023 texture->modMode |= SDL_TEXTUREMODULATE_COLOR; | |
2024 } else { | |
2025 texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; | |
2026 } | |
2027 texture->r = r; | |
2028 texture->g = g; | |
2029 texture->b = b; | |
2030 return renderer->SetTextureColorMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2031 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2032 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2033 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2034 SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g, |
2753 | 2035 Uint8 * b) |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2036 { |
2753 | 2037 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2038 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2039 |
2753 | 2040 if (!texture) { |
2041 return -1; | |
2042 } | |
2043 renderer = texture->renderer; | |
2044 if (r) { | |
2045 *r = texture->r; | |
2046 } | |
2047 if (g) { | |
2048 *g = texture->g; | |
2049 } | |
2050 if (b) { | |
2051 *b = texture->b; | |
2052 } | |
2053 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2054 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2055 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2056 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2057 SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2058 { |
2753 | 2059 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2060 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2061 |
2753 | 2062 if (!texture) { |
2063 return -1; | |
2064 } | |
2065 renderer = texture->renderer; | |
2066 if (!renderer->SetTextureAlphaMod) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2067 SDL_Unsupported(); |
2753 | 2068 return -1; |
2069 } | |
2070 if (alpha < 255) { | |
2071 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; | |
2072 } else { | |
2073 texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; | |
2074 } | |
2075 texture->a = alpha; | |
2076 return renderer->SetTextureAlphaMod(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2077 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2078 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2079 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2080 SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2081 { |
2753 | 2082 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2083 |
2753 | 2084 if (!texture) { |
2085 return -1; | |
2086 } | |
2087 if (alpha) { | |
2088 *alpha = texture->a; | |
2089 } | |
2090 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2091 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2092 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2093 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2094 SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2095 { |
2753 | 2096 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2097 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2098 |
2753 | 2099 if (!texture) { |
2100 return -1; | |
2101 } | |
2102 renderer = texture->renderer; | |
2103 if (!renderer->SetTextureBlendMode) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2104 SDL_Unsupported(); |
2753 | 2105 return -1; |
2106 } | |
2107 texture->blendMode = blendMode; | |
2108 return renderer->SetTextureBlendMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2109 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2110 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2111 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2112 SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2113 { |
2753 | 2114 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2115 |
2753 | 2116 if (!texture) { |
2117 return -1; | |
2118 } | |
2119 if (blendMode) { | |
2120 *blendMode = texture->blendMode; | |
2121 } | |
2122 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2123 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2124 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2125 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2126 SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2127 { |
2753 | 2128 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2129 SDL_Renderer *renderer; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2130 |
2753 | 2131 if (!texture) { |
2132 return -1; | |
2133 } | |
2134 renderer = texture->renderer; | |
2135 if (!renderer->SetTextureScaleMode) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2136 SDL_Unsupported(); |
2753 | 2137 return -1; |
2138 } | |
2139 texture->scaleMode = scaleMode; | |
2140 return renderer->SetTextureScaleMode(renderer, texture); | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2141 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2142 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2143 int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2144 SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2145 { |
2753 | 2146 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2147 |
2753 | 2148 if (!texture) { |
2149 return -1; | |
2150 } | |
2151 if (scaleMode) { | |
2152 *scaleMode = texture->scaleMode; | |
2153 } | |
2154 return 0; | |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2155 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2156 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1981
diff
changeset
|
2157 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
|
2158 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect, |
2753 | 2159 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
|
2160 { |
2753 | 2161 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2162 SDL_Renderer *renderer; | |
2163 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
|
2164 |
2753 | 2165 if (!texture) { |
2166 return -1; | |
2167 } | |
2168 renderer = texture->renderer; | |
2169 if (!renderer->UpdateTexture) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2170 SDL_Unsupported(); |
2753 | 2171 return -1; |
2172 } | |
2173 if (!rect) { | |
2174 full_rect.x = 0; | |
2175 full_rect.y = 0; | |
2176 full_rect.w = texture->w; | |
2177 full_rect.h = texture->h; | |
2178 rect = &full_rect; | |
2179 } | |
2180 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
|
2181 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2182 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2183 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
|
2184 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty, |
2753 | 2185 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
|
2186 { |
2753 | 2187 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2188 SDL_Renderer *renderer; | |
2189 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
|
2190 |
2753 | 2191 if (!texture) { |
2192 return -1; | |
2193 } | |
2194 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
2195 SDL_SetError("SDL_LockTexture(): texture must be streaming"); | |
2196 return -1; | |
2197 } | |
2198 renderer = texture->renderer; | |
2199 if (!renderer->LockTexture) { | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2200 SDL_Unsupported(); |
2753 | 2201 return -1; |
2202 } | |
2203 if (!rect) { | |
2204 full_rect.x = 0; | |
2205 full_rect.y = 0; | |
2206 full_rect.w = texture->w; | |
2207 full_rect.h = texture->h; | |
2208 rect = &full_rect; | |
2209 } | |
2210 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels, | |
2211 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
|
2212 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2213 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2214 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
|
2215 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
|
2216 { |
2753 | 2217 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2218 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
|
2219 |
2753 | 2220 if (!texture) { |
2221 return; | |
2222 } | |
2223 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
2224 return; | |
2225 } | |
2226 renderer = texture->renderer; | |
2227 if (!renderer->UnlockTexture) { | |
2228 return; | |
2229 } | |
2230 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
|
2231 } |
0 | 2232 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2233 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
|
2234 SDL_DirtyTexture(SDL_TextureID textureID, int numrects, |
2753 | 2235 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
|
2236 { |
2753 | 2237 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2238 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
|
2239 |
2753 | 2240 if (!texture) { |
2241 return; | |
2242 } | |
2243 if (texture->access != SDL_TEXTUREACCESS_STREAMING) { | |
2244 return; | |
2245 } | |
2246 renderer = texture->renderer; | |
2247 if (!renderer->DirtyTexture) { | |
2248 return; | |
2249 } | |
2250 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
|
2251 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2252 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2253 int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2254 SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2255 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2256 SDL_Renderer *renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2257 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2258 if (!_this) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2259 SDL_UninitializedVideo(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2260 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2261 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2262 renderer = SDL_CurrentDisplay.current_renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2263 if (!renderer) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2264 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2265 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2266 renderer->r = r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2267 renderer->g = g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2268 renderer->b = b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2269 renderer->a = a; |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2270 if (renderer->SetDrawColor) { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2271 return renderer->SetDrawColor(renderer); |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2272 } else { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2273 return 0; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2274 } |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2275 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2276 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2277 int |
2885 | 2278 SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2279 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2280 SDL_Renderer *renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2281 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2282 if (!_this) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2283 SDL_UninitializedVideo(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2284 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2285 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2286 renderer = SDL_CurrentDisplay.current_renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2287 if (!renderer) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2288 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2289 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2290 if (r) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2291 *r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2292 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2293 if (g) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2294 *g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2295 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2296 if (b) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2297 *b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2298 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2299 if (a) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2300 *a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2301 } |
2928
e171ce9bdbad
Fixed missing return value
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
2302 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2303 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2304 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2305 int |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2306 SDL_SetRenderDrawBlendMode(int blendMode) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2307 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2308 SDL_Renderer *renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2309 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2310 if (!_this) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2311 SDL_UninitializedVideo(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2312 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2313 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2314 renderer = SDL_CurrentDisplay.current_renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2315 if (!renderer) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2316 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2317 } |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2318 renderer->blendMode = blendMode; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2319 if (renderer->SetDrawBlendMode) { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2320 return renderer->SetDrawBlendMode(renderer); |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2321 } else { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2918
diff
changeset
|
2322 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2323 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2324 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2325 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2326 int |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2327 SDL_GetRenderDrawBlendMode(int *blendMode) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2328 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2329 SDL_Renderer *renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2330 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2331 if (!_this) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2332 SDL_UninitializedVideo(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2333 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2334 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2335 renderer = SDL_CurrentDisplay.current_renderer; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2336 if (!renderer) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2337 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2338 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2339 *blendMode = renderer->blendMode; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2340 return 0; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2341 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2342 |
2901 | 2343 int |
2344 SDL_RenderPoint(int x, int y) | |
2345 { | |
2346 SDL_Renderer *renderer; | |
2347 SDL_Window *window; | |
2348 | |
2349 if (!_this) { | |
2350 SDL_UninitializedVideo(); | |
2351 return -1; | |
2352 } | |
2353 renderer = SDL_CurrentDisplay.current_renderer; | |
2354 if (!renderer) { | |
2355 return -1; | |
2356 } | |
2357 if (!renderer->RenderPoint) { | |
2358 SDL_Unsupported(); | |
2359 return -1; | |
2360 } | |
2361 window = SDL_GetWindowFromID(renderer->window); | |
2362 if (x < 0 || y < 0 || x >= window->w || y >= window->h) { | |
2363 return 0; | |
2364 } | |
2365 return renderer->RenderPoint(renderer, x, y); | |
2366 } | |
2367 | |
2368 int | |
2369 SDL_RenderLine(int x1, int y1, int x2, int y2) | |
2370 { | |
2371 SDL_Renderer *renderer; | |
2372 SDL_Window *window; | |
2373 SDL_Rect real_rect; | |
2374 | |
2375 if (x1 == x2 && y1 == y2) { | |
2376 return SDL_RenderPoint(x1, y1); | |
2377 } | |
2378 | |
2379 if (!_this) { | |
2380 SDL_UninitializedVideo(); | |
2381 return -1; | |
2382 } | |
2383 renderer = SDL_CurrentDisplay.current_renderer; | |
2384 if (!renderer) { | |
2385 return -1; | |
2386 } | |
2387 if (!renderer->RenderLine) { | |
2388 SDL_Unsupported(); | |
2389 return -1; | |
2390 } | |
2391 window = SDL_GetWindowFromID(renderer->window); | |
2909 | 2392 |
2901 | 2393 real_rect.x = 0; |
2394 real_rect.y = 0; | |
2395 real_rect.w = window->w; | |
2396 real_rect.h = window->h; | |
2910
27d8b12e0e8e
Fixed argument order to the line clipping routine
Sam Lantinga <slouken@libsdl.org>
parents:
2909
diff
changeset
|
2397 if (!SDL_IntersectRectAndLine(&real_rect, &x1, &y1, &x2, &y2)) { |
2909 | 2398 return (0); |
2901 | 2399 } |
2400 return renderer->RenderLine(renderer, x1, y1, x2, y2); | |
2401 } | |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2402 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2403 int |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2404 SDL_RenderFill(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
|
2405 { |
2753 | 2406 SDL_Renderer *renderer; |
2407 SDL_Window *window; | |
2408 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
|
2409 |
2753 | 2410 if (!_this) { |
2411 SDL_UninitializedVideo(); | |
2412 return -1; | |
2413 } | |
2414 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2415 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2416 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2417 } |
2814 | 2418 if (!renderer->RenderFill) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2419 SDL_Unsupported(); |
2753 | 2420 return -1; |
2421 } | |
2422 window = SDL_GetWindowFromID(renderer->window); | |
2908
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2423 |
2753 | 2424 real_rect.x = 0; |
2425 real_rect.y = 0; | |
2426 real_rect.w = window->w; | |
2427 real_rect.h = window->h; | |
2428 if (rect) { | |
2429 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
2430 return 0; | |
2431 } | |
2432 } | |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2433 return renderer->RenderFill(renderer, &real_rect); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2434 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2435 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset
|
2436 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
|
2437 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, |
2753 | 2438 const SDL_Rect * dstrect) |
0 | 2439 { |
2753 | 2440 SDL_Texture *texture = SDL_GetTextureFromID(textureID); |
2441 SDL_Renderer *renderer; | |
2442 SDL_Window *window; | |
2443 SDL_Rect real_srcrect; | |
2444 SDL_Rect real_dstrect; | |
0 | 2445 |
2753 | 2446 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { |
2447 return -1; | |
2448 } | |
2449 renderer = SDL_CurrentDisplay.current_renderer; | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2450 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2451 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2452 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2453 if (!renderer->RenderCopy) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2789
diff
changeset
|
2454 SDL_Unsupported(); |
2753 | 2455 return -1; |
2456 } | |
2457 window = SDL_GetWindowFromID(renderer->window); | |
2908
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2458 |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2459 real_srcrect.x = 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2460 real_srcrect.y = 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2461 real_srcrect.w = texture->w; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2462 real_srcrect.h = texture->h; |
2753 | 2463 if (srcrect) { |
2908
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2464 if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2465 return 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2466 } |
2753 | 2467 } |
2908
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2468 |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2469 real_dstrect.x = 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2470 real_dstrect.y = 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2471 real_dstrect.w = window->w; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2472 real_dstrect.h = window->h; |
2753 | 2473 if (dstrect) { |
2908
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2474 if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) { |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2475 return 0; |
aa6ba38c1714
Added clipping for render copy
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
2476 } |
2912
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2477 /* Clip srcrect by the same amount as dstrect was clipped */ |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2478 if (dstrect->w != real_dstrect.w) { |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2479 int deltax = (real_dstrect.x - dstrect->x); |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2480 int deltaw = (real_dstrect.w - dstrect->w); |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2481 real_srcrect.x += (deltax * dstrect->w) / real_srcrect.w; |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2482 real_srcrect.w += (deltaw * dstrect->w) / real_srcrect.w; |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2483 } |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2484 if (dstrect->h != real_dstrect.h) { |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2485 int deltay = (real_dstrect.y - dstrect->y); |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2486 int deltah = (real_dstrect.h - dstrect->h); |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2487 real_srcrect.y += (deltay * dstrect->h) / real_srcrect.h; |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2488 real_srcrect.h += (deltah * dstrect->h) / real_srcrect.h; |
1d50666ed3d5
Fixed clipping source rect to match destination rect clipping
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
2489 } |
2753 | 2490 } |
0 | 2491 |
2753 | 2492 return renderer->RenderCopy(renderer, texture, &real_srcrect, |
2493 &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
|
2494 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2495 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2496 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
|
2497 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
|
2498 { |
2753 | 2499 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
|
2500 |
2753 | 2501 if (!_this) { |
2502 SDL_UninitializedVideo(); | |
2503 return; | |
2504 } | |
2505 renderer = SDL_CurrentDisplay.current_renderer; | |
2506 if (!renderer || !renderer->RenderPresent) { | |
2507 return; | |
2508 } | |
2509 renderer->RenderPresent(renderer); | |
0 | 2510 } |
2511 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2512 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
|
2513 SDL_DestroyTexture(SDL_TextureID textureID) |
0 | 2514 { |
2753 | 2515 int hash; |
2516 SDL_Texture *prev, *texture; | |
2517 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
|
2518 |
2753 | 2519 if (!_this) { |
2520 SDL_UninitializedVideo(); | |
2521 return; | |
2522 } | |
2523 /* Look up the texture in the hash table */ | |
2524 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures)); | |
2525 prev = NULL; | |
2526 for (texture = SDL_CurrentDisplay.textures[hash]; texture; | |
2527 prev = texture, texture = texture->next) { | |
2528 if (texture->id == textureID) { | |
2529 break; | |
2530 } | |
2531 } | |
2532 if (!texture) { | |
2533 return; | |
2534 } | |
2535 /* Unlink the texture from the list */ | |
2536 if (prev) { | |
2537 prev->next = texture->next; | |
2538 } else { | |
2539 SDL_CurrentDisplay.textures[hash] = texture->next; | |
2540 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2541 |
2753 | 2542 /* Free the texture */ |
2543 renderer = texture->renderer; | |
2544 renderer->DestroyTexture(renderer, texture); | |
2545 SDL_free(texture); | |
0 | 2546 } |
2547 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2548 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
|
2549 SDL_DestroyRenderer(SDL_WindowID windowID) |
0 | 2550 { |
2753 | 2551 SDL_Window *window = SDL_GetWindowFromID(windowID); |
2552 SDL_Renderer *renderer; | |
2553 int i; | |
0 | 2554 |
2753 | 2555 if (!window) { |
2556 return; | |
2557 } | |
2558 renderer = window->renderer; | |
2559 if (!renderer) { | |
2560 return; | |
2561 } | |
2562 /* Free existing textures for this renderer */ | |
2563 for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) { | |
2564 SDL_Texture *texture; | |
2565 SDL_Texture *prev = NULL; | |
2566 SDL_Texture *next; | |
2567 for (texture = SDL_CurrentDisplay.textures[i]; texture; | |
2568 texture = next) { | |
2569 next = texture->next; | |
2570 if (texture->renderer == renderer) { | |
2571 if (prev) { | |
2572 prev->next = next; | |
2573 } else { | |
2574 SDL_CurrentDisplay.textures[i] = next; | |
2575 } | |
2576 renderer->DestroyTexture(renderer, texture); | |
2577 SDL_free(texture); | |
2578 } else { | |
2579 prev = texture; | |
2580 } | |
2581 } | |
2582 } | |
0 | 2583 |
2753 | 2584 /* Free the renderer instance */ |
2585 renderer->DestroyRenderer(renderer); | |
0 | 2586 |
2753 | 2587 /* Clear references */ |
2588 window->renderer = NULL; | |
2589 if (SDL_CurrentDisplay.current_renderer == renderer) { | |
2590 SDL_CurrentDisplay.current_renderer = NULL; | |
2591 } | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2592 } |
0 | 2593 |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2594 SDL_bool |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2595 SDL_IsScreenSaverEnabled() |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2596 { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2597 if (!_this) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2598 return SDL_TRUE; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2599 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2600 return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2601 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2602 |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2603 void |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2604 SDL_EnableScreenSaver() |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2605 { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2606 if (!_this) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2607 return; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2608 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2609 if (!_this->suspend_screensaver) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2610 return; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2611 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2612 _this->suspend_screensaver = SDL_FALSE; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2613 if (_this->SuspendScreenSaver) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2614 _this->SuspendScreenSaver(_this); |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2615 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2616 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2617 |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2618 void |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2619 SDL_DisableScreenSaver() |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2620 { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2621 if (!_this) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2622 return; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2623 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2624 if (_this->suspend_screensaver) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2625 return; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2626 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2627 _this->suspend_screensaver = SDL_TRUE; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2628 if (_this->SuspendScreenSaver) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2629 _this->SuspendScreenSaver(_this); |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2630 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2631 } |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
2999
diff
changeset
|
2632 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2633 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2634 SDL_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
|
2635 { |
2753 | 2636 int i, j; |
0 | 2637 |
2753 | 2638 if (!_this) { |
2639 return; | |
2640 } | |
2641 /* Halt event processing before doing anything else */ | |
2642 SDL_StopEventLoop(); | |
3029
89f8a72e1ee9
Re-enable the screensaver at exit, just in case it's needed...
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
2643 SDL_EnableScreenSaver(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2644 |
2753 | 2645 /* Clean up the system video */ |
2646 for (i = _this->num_displays; i--;) { | |
2647 SDL_VideoDisplay *display = &_this->displays[i]; | |
2648 for (j = display->num_windows; j--;) { | |
2649 SDL_DestroyWindow(display->windows[i].id); | |
2650 } | |
2651 if (display->windows) { | |
2652 SDL_free(display->windows); | |
2653 display->windows = NULL; | |
2654 } | |
2655 display->num_windows = 0; | |
2656 if (display->render_drivers) { | |
2657 SDL_free(display->render_drivers); | |
2658 display->render_drivers = NULL; | |
2659 } | |
2660 display->num_render_drivers = 0; | |
2661 } | |
2662 _this->VideoQuit(_this); | |
0 | 2663 |
2753 | 2664 for (i = _this->num_displays; i--;) { |
2665 SDL_VideoDisplay *display = &_this->displays[i]; | |
2666 for (j = display->num_display_modes; j--;) { | |
2667 if (display->display_modes[j].driverdata) { | |
2668 SDL_free(display->display_modes[j].driverdata); | |
2669 display->display_modes[j].driverdata = NULL; | |
2670 } | |
2671 } | |
2672 if (display->display_modes) { | |
2673 SDL_free(display->display_modes); | |
2674 display->display_modes = NULL; | |
2675 } | |
2676 if (display->desktop_mode.driverdata) { | |
2677 SDL_free(display->desktop_mode.driverdata); | |
2678 display->desktop_mode.driverdata = NULL; | |
2679 } | |
2680 if (display->palette) { | |
2681 SDL_FreePalette(display->palette); | |
2682 display->palette = NULL; | |
2683 } | |
2684 if (display->gamma) { | |
2685 SDL_free(display->gamma); | |
2686 display->gamma = NULL; | |
2687 } | |
2688 if (display->driverdata) { | |
2689 SDL_free(display->driverdata); | |
2690 display->driverdata = NULL; | |
2691 } | |
2692 } | |
2693 if (_this->displays) { | |
2694 SDL_free(_this->displays); | |
2695 _this->displays = NULL; | |
2696 } | |
2697 _this->free(_this); | |
2698 _this = NULL; | |
0 | 2699 } |
2700 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2701 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
|
2702 SDL_GL_LoadLibrary(const char *path) |
0 | 2703 { |
2753 | 2704 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2705 |
2753 | 2706 if (!_this) { |
2707 SDL_UninitializedVideo(); | |
2708 return -1; | |
2709 } | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2710 if (_this->gl_config.driver_loaded) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2711 if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2712 SDL_SetError("OpenGL library already loaded"); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2713 return -1; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2714 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2715 retval = 0; |
2753 | 2716 } else { |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2717 if (!_this->GL_LoadLibrary) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2718 SDL_SetError("No dynamic GL support in video driver"); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2719 return -1; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2720 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2721 retval = _this->GL_LoadLibrary(_this, path); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2722 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2723 if (retval == 0) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2724 ++_this->gl_config.driver_loaded; |
2753 | 2725 } |
2726 return (retval); | |
0 | 2727 } |
2728 | |
2753 | 2729 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
|
2730 SDL_GL_GetProcAddress(const char *proc) |
0 | 2731 { |
2753 | 2732 void *func; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2733 |
2753 | 2734 if (!_this) { |
2735 SDL_UninitializedVideo(); | |
2736 return NULL; | |
2737 } | |
2738 func = NULL; | |
2739 if (_this->GL_GetProcAddress) { | |
2740 if (_this->gl_config.driver_loaded) { | |
2741 func = _this->GL_GetProcAddress(_this, proc); | |
2742 } else { | |
2743 SDL_SetError("No GL driver has been loaded"); | |
2744 } | |
2745 } else { | |
2746 SDL_SetError("No dynamic GL support in video driver"); | |
2747 } | |
2748 return func; | |
0 | 2749 } |
2750 | |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2751 void |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2752 SDL_GL_UnloadLibrary(void) |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2753 { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2754 if (!_this) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2755 SDL_UninitializedVideo(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2756 return; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2757 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2758 if (_this->gl_config.driver_loaded > 0) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2759 if (--_this->gl_config.driver_loaded > 0) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2760 return; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2761 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2762 if (_this->GL_UnloadLibrary) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2763 _this->GL_UnloadLibrary(_this); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2764 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2765 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2766 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3053
diff
changeset
|
2767 |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2768 SDL_bool |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2769 SDL_GL_ExtensionSupported(const char *extension) |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2770 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2771 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2772 const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); |
2773 const char *extensions; | |
2774 const char *start; | |
2775 const char *where, *terminator; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2776 |
2753 | 2777 /* Extension names should not have spaces. */ |
2778 where = SDL_strchr(extension, ' '); | |
2779 if (where || *extension == '\0') { | |
2780 return SDL_FALSE; | |
2781 } | |
2782 /* See if there's an environment variable override */ | |
2783 start = SDL_getenv(extension); | |
2784 if (start && *start == '0') { | |
2785 return SDL_FALSE; | |
2786 } | |
2787 /* Lookup the available extensions */ | |
2788 glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); | |
2789 if (glGetStringFunc) { | |
2790 extensions = (const char *) glGetStringFunc(GL_EXTENSIONS); | |
2791 } else { | |
2792 extensions = NULL; | |
2793 } | |
2794 if (!extensions) { | |
2795 return SDL_FALSE; | |
2796 } | |
2797 /* | |
2798 * It takes a bit of care to be fool-proof about parsing the OpenGL | |
2799 * extensions string. Don't be fooled by sub-strings, etc. | |
2800 */ | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2801 |
2753 | 2802 start = extensions; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2803 |
2753 | 2804 for (;;) { |
2805 where = SDL_strstr(start, extension); | |
2806 if (!where) | |
2807 break; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2808 |
2753 | 2809 terminator = where + SDL_strlen(extension); |
2810 if (where == start || *(where - 1) == ' ') | |
2811 if (*terminator == ' ' || *terminator == '\0') | |
2812 return SDL_TRUE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2813 |
2753 | 2814 start = terminator; |
2815 } | |
2816 return SDL_FALSE; | |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2817 #else |
2753 | 2818 return SDL_FALSE; |
1926
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2819 #endif |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2820 } |
307355678142
Added SDL_GL_ExtensionSupported()
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
2821 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2822 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
|
2823 SDL_GL_SetAttribute(SDL_GLattr attr, int value) |
0 | 2824 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2825 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2826 int retval; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2827 |
2753 | 2828 if (!_this) { |
2829 SDL_UninitializedVideo(); | |
2830 return -1; | |
2831 } | |
2832 retval = 0; | |
2833 switch (attr) { | |
2834 case SDL_GL_RED_SIZE: | |
2835 _this->gl_config.red_size = value; | |
2836 break; | |
2837 case SDL_GL_GREEN_SIZE: | |
2838 _this->gl_config.green_size = value; | |
2839 break; | |
2840 case SDL_GL_BLUE_SIZE: | |
2841 _this->gl_config.blue_size = value; | |
2842 break; | |
2843 case SDL_GL_ALPHA_SIZE: | |
2844 _this->gl_config.alpha_size = value; | |
2845 break; | |
2846 case SDL_GL_DOUBLEBUFFER: | |
2847 _this->gl_config.double_buffer = value; | |
2848 break; | |
2849 case SDL_GL_BUFFER_SIZE: | |
2850 _this->gl_config.buffer_size = value; | |
2851 break; | |
2852 case SDL_GL_DEPTH_SIZE: | |
2853 _this->gl_config.depth_size = value; | |
2854 break; | |
2855 case SDL_GL_STENCIL_SIZE: | |
2856 _this->gl_config.stencil_size = value; | |
2857 break; | |
2858 case SDL_GL_ACCUM_RED_SIZE: | |
2859 _this->gl_config.accum_red_size = value; | |
2860 break; | |
2861 case SDL_GL_ACCUM_GREEN_SIZE: | |
2862 _this->gl_config.accum_green_size = value; | |
2863 break; | |
2864 case SDL_GL_ACCUM_BLUE_SIZE: | |
2865 _this->gl_config.accum_blue_size = value; | |
2866 break; | |
2867 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2868 _this->gl_config.accum_alpha_size = value; | |
2869 break; | |
2870 case SDL_GL_STEREO: | |
2871 _this->gl_config.stereo = value; | |
2872 break; | |
2873 case SDL_GL_MULTISAMPLEBUFFERS: | |
2874 _this->gl_config.multisamplebuffers = value; | |
2875 break; | |
2876 case SDL_GL_MULTISAMPLESAMPLES: | |
2877 _this->gl_config.multisamplesamples = value; | |
2878 break; | |
2879 case SDL_GL_ACCELERATED_VISUAL: | |
2880 _this->gl_config.accelerated = value; | |
2881 break; | |
2882 case SDL_GL_RETAINED_BACKING: | |
2883 _this->gl_config.retained_backing = value; | |
2884 break; | |
3100
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2885 case SDL_GL_CONTEXT_MAJOR_VERSION: |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2886 _this->gl_config.major_version = value; |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2887 break; |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2888 case SDL_GL_CONTEXT_MINOR_VERSION: |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2889 _this->gl_config.minor_version = value; |
7dc982143c06
Date: Sun, 22 Mar 2009 12:52:29 +0000
Sam Lantinga <slouken@libsdl.org>
parents:
3099
diff
changeset
|
2890 break; |
2753 | 2891 default: |
2892 SDL_SetError("Unknown OpenGL attribute"); | |
2893 retval = -1; | |
2894 break; | |
2895 } | |
2896 return retval; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2897 #else |
2753 | 2898 SDL_Unsupported(); |
2899 return -1; | |
2900 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 2901 } |
2902 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
2903 int |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
2904 SDL_GL_GetAttribute(SDL_GLattr attr, int *value) |
0 | 2905 { |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2906 #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES |
2753 | 2907 void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); |
3139 | 2908 GLenum(APIENTRY * glGetErrorFunc) (void); |
2753 | 2909 GLenum attrib = 0; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2910 GLenum error = 0; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
2911 |
2753 | 2912 glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); |
2913 if (!glGetIntegervFunc) { | |
2914 return -1; | |
2915 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2916 |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2917 glGetErrorFunc = SDL_GL_GetProcAddress("glGetError"); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2918 if (!glGetErrorFunc) { |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2919 return -1; |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2920 } |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2921 |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2922 /* Clear value in any case */ |
3139 | 2923 *value = 0; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2924 |
2753 | 2925 switch (attr) { |
2926 case SDL_GL_RETAINED_BACKING: | |
2927 *value = _this->gl_config.retained_backing; | |
2928 return 0; | |
2929 case SDL_GL_RED_SIZE: | |
2930 attrib = GL_RED_BITS; | |
2931 break; | |
2932 case SDL_GL_BLUE_SIZE: | |
2933 attrib = GL_BLUE_BITS; | |
2934 break; | |
2935 case SDL_GL_GREEN_SIZE: | |
2936 attrib = GL_GREEN_BITS; | |
2937 break; | |
2938 case SDL_GL_ALPHA_SIZE: | |
2939 attrib = GL_ALPHA_BITS; | |
2940 break; | |
2941 case SDL_GL_DOUBLEBUFFER: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2942 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2943 attrib = GL_DOUBLEBUFFER; |
2944 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2945 #else |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2946 /* OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER */ |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2947 /* parameter which switches double buffer to single buffer. OpenGL ES */ |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2948 /* SDL driver must set proper value after initialization */ |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
2949 *value = _this->gl_config.double_buffer; |
2753 | 2950 return 0; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2951 #endif |
2753 | 2952 case SDL_GL_DEPTH_SIZE: |
2953 attrib = GL_DEPTH_BITS; | |
2954 break; | |
2955 case SDL_GL_STENCIL_SIZE: | |
2956 attrib = GL_STENCIL_BITS; | |
2957 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2958 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2959 case SDL_GL_ACCUM_RED_SIZE: |
2960 attrib = GL_ACCUM_RED_BITS; | |
2961 break; | |
2962 case SDL_GL_ACCUM_GREEN_SIZE: | |
2963 attrib = GL_ACCUM_GREEN_BITS; | |
2964 break; | |
2965 case SDL_GL_ACCUM_BLUE_SIZE: | |
2966 attrib = GL_ACCUM_BLUE_BITS; | |
2967 break; | |
2968 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2969 attrib = GL_ACCUM_ALPHA_BITS; | |
2970 break; | |
2971 case SDL_GL_STEREO: | |
2972 attrib = GL_STEREO; | |
2973 break; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2974 #else |
2753 | 2975 case SDL_GL_ACCUM_RED_SIZE: |
2976 case SDL_GL_ACCUM_GREEN_SIZE: | |
2977 case SDL_GL_ACCUM_BLUE_SIZE: | |
2978 case SDL_GL_ACCUM_ALPHA_SIZE: | |
2979 case SDL_GL_STEREO: | |
2980 /* none of these are supported in OpenGL ES */ | |
2981 *value = 0; | |
2982 return 0; | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2983 #endif |
2753 | 2984 case SDL_GL_MULTISAMPLEBUFFERS: |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2985 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2986 attrib = GL_SAMPLE_BUFFERS_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2987 #else |
2753 | 2988 attrib = GL_SAMPLE_BUFFERS; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2989 #endif |
2753 | 2990 break; |
2991 case SDL_GL_MULTISAMPLESAMPLES: | |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2992 #ifndef SDL_VIDEO_OPENGL_ES |
2753 | 2993 attrib = GL_SAMPLES_ARB; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2994 #else |
2753 | 2995 attrib = GL_SAMPLES; |
2745
587d2b5fb805
Added support for OpenGL ES renderer
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2744
diff
changeset
|
2996 #endif |
2753 | 2997 break; |
2998 case SDL_GL_BUFFER_SIZE: | |
2999 { | |
3000 GLint bits = 0; | |
3001 GLint component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
3002 |
2753 | 3003 /* |
3004 * there doesn't seem to be a single flag in OpenGL | |
3005 * for this! | |
3006 */ | |
3007 glGetIntegervFunc(GL_RED_BITS, &component); | |
3008 bits += component; | |
3009 glGetIntegervFunc(GL_GREEN_BITS, &component); | |
3010 bits += component; | |
3011 glGetIntegervFunc(GL_BLUE_BITS, &component); | |
3012 bits += component; | |
3013 glGetIntegervFunc(GL_ALPHA_BITS, &component); | |
3014 bits += component; | |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
3015 |
2753 | 3016 *value = bits; |
3017 return 0; | |
3018 } | |
3019 case SDL_GL_ACCELERATED_VISUAL: | |
3020 { | |
3021 /* FIXME: How do we get this information? */ | |
3022 *value = (_this->gl_config.accelerated != 0); | |
3023 return 0; | |
3024 } | |
3025 default: | |
3026 SDL_SetError("Unknown OpenGL attribute"); | |
3027 return -1; | |
3028 } | |
0 | 3029 |
2753 | 3030 glGetIntegervFunc(attrib, (GLint *) value); |
3139 | 3031 error = glGetErrorFunc(); |
3032 if (error != GL_NO_ERROR) { | |
3033 switch (error) { | |
3034 case GL_INVALID_ENUM: | |
3035 { | |
3036 SDL_SetError("OpenGL error: GL_INVALID_ENUM"); | |
3037 } | |
3038 break; | |
3039 case GL_INVALID_VALUE: | |
3040 { | |
3041 SDL_SetError("OpenGL error: GL_INVALID_VALUE"); | |
3042 } | |
3043 break; | |
3044 default: | |
3045 { | |
3046 SDL_SetError("OpenGL error: %08X", error); | |
3047 } | |
3048 break; | |
3049 } | |
3050 return -1; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
3051 } |
2753 | 3052 return 0; |
1936
83946ee0ff1f
Implemented OpenGL support on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
3053 #else |
2753 | 3054 SDL_Unsupported(); |
3055 return -1; | |
3056 #endif /* SDL_VIDEO_OPENGL */ | |
0 | 3057 } |
3058 | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3059 SDL_GLContext |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3060 SDL_GL_CreateContext(SDL_WindowID windowID) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3061 { |
2753 | 3062 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3063 |
2753 | 3064 if (!window) { |
3065 return NULL; | |
3066 } | |
3067 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
3068 SDL_SetError("The specified window isn't an OpenGL window"); | |
3069 return NULL; | |
3070 } | |
3071 return _this->GL_CreateContext(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3072 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3073 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3074 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3075 SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3076 { |
2753 | 3077 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3078 |
2753 | 3079 if (window && !(window->flags & SDL_WINDOW_OPENGL)) { |
3080 SDL_SetError("The specified window isn't an OpenGL window"); | |
3081 return -1; | |
3082 } | |
3083 if (!context) { | |
3084 window = NULL; | |
3085 } | |
3086 return _this->GL_MakeCurrent(_this, window, context); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3087 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3088 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3089 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3090 SDL_GL_SetSwapInterval(int interval) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3091 { |
2753 | 3092 if (!_this) { |
3093 SDL_UninitializedVideo(); | |
3094 return -1; | |
3095 } | |
3096 if (_this->GL_SetSwapInterval) { | |
3097 return _this->GL_SetSwapInterval(_this, interval); | |
3098 } else { | |
3099 SDL_SetError("Setting the swap interval is not supported"); | |
3100 return -1; | |
3101 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3102 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3103 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3104 int |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3105 SDL_GL_GetSwapInterval(void) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3106 { |
2753 | 3107 if (!_this) { |
3108 SDL_UninitializedVideo(); | |
3109 return -1; | |
3110 } | |
3111 if (_this->GL_GetSwapInterval) { | |
3112 return _this->GL_GetSwapInterval(_this); | |
3113 } else { | |
3114 SDL_SetError("Getting the swap interval is not supported"); | |
3115 return -1; | |
3116 } | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3117 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3118 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3119 void |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3120 SDL_GL_SwapWindow(SDL_WindowID windowID) |
0 | 3121 { |
2753 | 3122 SDL_Window *window = SDL_GetWindowFromID(windowID); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3123 |
2753 | 3124 if (!window) { |
3125 return; | |
3126 } | |
3127 if (!(window->flags & SDL_WINDOW_OPENGL)) { | |
3128 SDL_SetError("The specified window isn't an OpenGL window"); | |
3129 return; | |
3130 } | |
3131 _this->GL_SwapWindow(_this, window); | |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3132 } |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3133 |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3134 void |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3135 SDL_GL_DeleteContext(SDL_GLContext context) |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1909
diff
changeset
|
3136 { |
2753 | 3137 if (!_this || !context) { |
3138 return; | |
3139 } | |
3140 _this->GL_MakeCurrent(_this, NULL, NULL); | |
3141 _this->GL_DeleteContext(_this, context); | |
0 | 3142 } |
3143 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3144 #if 0 // FIXME |
2744
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
3145 /* |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
3146 * 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
|
3147 * & 2 for alpha channel. |
1aede15771d0
Ran GNU indent on file
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
2743
diff
changeset
|
3148 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3149 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
|
3150 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) |
0 | 3151 { |
2753 | 3152 int x, y; |
3153 Uint32 colorkey; | |
0 | 3154 #define SET_MASKBIT(icon, x, y, mask) \ |
3155 mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) | |
3156 | |
2753 | 3157 colorkey = icon->format->colorkey; |
3158 switch (icon->format->BytesPerPixel) { | |
3159 case 1: | |
3160 { | |
3161 Uint8 *pixels; | |
3162 for (y = 0; y < icon->h; ++y) { | |
3163 pixels = (Uint8 *) icon->pixels + y * icon->pitch; | |
3164 for (x = 0; x < icon->w; ++x) { | |
3165 if (*pixels++ == colorkey) { | |
3166 SET_MASKBIT(icon, x, y, mask); | |
3167 } | |
3168 } | |
3169 } | |
3170 } | |
3171 break; | |
0 | 3172 |
2753 | 3173 case 2: |
3174 { | |
3175 Uint16 *pixels; | |
3176 for (y = 0; y < icon->h; ++y) { | |
3177 pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2; | |
3178 for (x = 0; x < icon->w; ++x) { | |
3179 if ((flags & 1) && *pixels == colorkey) { | |
3180 SET_MASKBIT(icon, x, y, mask); | |
3181 } else if ((flags & 2) | |
3182 && (*pixels & icon->format->Amask) == 0) { | |
3183 SET_MASKBIT(icon, x, y, mask); | |
3184 } | |
3185 pixels++; | |
3186 } | |
3187 } | |
3188 } | |
3189 break; | |
0 | 3190 |
2753 | 3191 case 4: |
3192 { | |
3193 Uint32 *pixels; | |
3194 for (y = 0; y < icon->h; ++y) { | |
3195 pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4; | |
3196 for (x = 0; x < icon->w; ++x) { | |
3197 if ((flags & 1) && *pixels == colorkey) { | |
3198 SET_MASKBIT(icon, x, y, mask); | |
3199 } else if ((flags & 2) | |
3200 && (*pixels & icon->format->Amask) == 0) { | |
3201 SET_MASKBIT(icon, x, y, mask); | |
3202 } | |
3203 pixels++; | |
3204 } | |
3205 } | |
3206 } | |
3207 break; | |
3208 } | |
0 | 3209 } |
3210 | |
3211 /* | |
3212 * Sets the window manager icon for the display window. | |
3213 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3214 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
|
3215 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) |
0 | 3216 { |
2753 | 3217 if (icon && _this->SetIcon) { |
3218 /* Generate a mask if necessary, and create the icon! */ | |
3219 if (mask == NULL) { | |
3220 int mask_len = icon->h * (icon->w + 7) / 8; | |
3221 int flags = 0; | |
3222 mask = (Uint8 *) SDL_malloc(mask_len); | |
3223 if (mask == NULL) { | |
3224 return; | |
3225 } | |
3226 SDL_memset(mask, ~0, mask_len); | |
3227 if (icon->flags & SDL_SRCCOLORKEY) | |
3228 flags |= 1; | |
3229 if (icon->flags & SDL_SRCALPHA) | |
3230 flags |= 2; | |
3231 if (flags) { | |
3232 CreateMaskFromColorKeyOrAlpha(icon, mask, flags); | |
3233 } | |
3234 _this->SetIcon(_this, icon, mask); | |
3235 SDL_free(mask); | |
3236 } else { | |
3237 _this->SetIcon(_this, icon, mask); | |
3238 } | |
3239 } | |
0 | 3240 } |
3241 #endif | |
3242 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3243 SDL_bool |
2753 | 3244 SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info) |
0 | 3245 { |
2753 | 3246 SDL_Window *window = SDL_GetWindowFromID(windowID); |
0 | 3247 |
2753 | 3248 if (!window || !_this->GetWindowWMInfo) { |
3249 return SDL_FALSE; | |
3250 } | |
3251 return (_this->GetWindowWMInfo(_this, window, info)); | |
0 | 3252 } |
3253 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
3254 /* vi: set ts=4 sw=4 expandtab: */ |