annotate src/video/SDL_video.c @ 1734:f7c667ded87d SDL-1.3

The general code handles restoring video mode/gamma/etc. when the window loses focus. Support for changing fullscreen/windowed mode in progress.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 09 Jul 2006 18:09:16 +0000
parents 0b1070f2f94d
children 8dd28c4ef746
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1296
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 /* The high-level video driver subsystem */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include "SDL.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_sysvideo.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_blit.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include "SDL_pixels_c.h"
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
30 #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
31 #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
32 #include "../events/SDL_events_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 /* Available video drivers */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 static VideoBootStrap *bootstrap[] = {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
36 #if SDL_VIDEO_DRIVER_QUARTZ
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
37 &QZ_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
38 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
39 #if SDL_VIDEO_DRIVER_X11
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
40 &X11_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
42 #if SDL_VIDEO_DRIVER_DGA
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
43 &DGA_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
45 #if SDL_VIDEO_DRIVER_NANOX
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
46 &NX_bootstrap,
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents: 19
diff changeset
47 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
48 #if SDL_VIDEO_DRIVER_IPOD
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
49 &iPod_bootstrap,
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1133
diff changeset
50 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
51 #if SDL_VIDEO_DRIVER_QTOPIA
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
52 &Qtopia_bootstrap,
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 541
diff changeset
53 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
54 #if SDL_VIDEO_DRIVER_WSCONS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
55 &WSCONS_bootstrap,
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1141
diff changeset
56 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
57 #if SDL_VIDEO_DRIVER_FBCON
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
58 &FBCON_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
60 #if SDL_VIDEO_DRIVER_DIRECTFB
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
61 &DirectFB_bootstrap,
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents: 125
diff changeset
62 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
63 #if SDL_VIDEO_DRIVER_PS2GS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
64 &PS2GS_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
66 #if SDL_VIDEO_DRIVER_GGI
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
67 &GGI_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
69 #if SDL_VIDEO_DRIVER_VGL
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
70 &VGL_bootstrap,
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents: 58
diff changeset
71 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
72 #if SDL_VIDEO_DRIVER_SVGALIB
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
73 &SVGALIB_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
75 #if SDL_VIDEO_DRIVER_GAPI
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
76 &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
77 #endif
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents: 1707
diff changeset
78 #if SDL_VIDEO_DRIVER_WIN32
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents: 1707
diff changeset
79 &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
80 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
81 #if SDL_VIDEO_DRIVER_BWINDOW
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
82 &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
83 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
84 #if SDL_VIDEO_DRIVER_TOOLBOX
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
85 &TOOLBOX_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
86 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
87 #if SDL_VIDEO_DRIVER_DRAWSPROCKET
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
88 &DSp_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
89 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
90 #if SDL_VIDEO_DRIVER_CYBERGRAPHICS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
91 &CGX_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
92 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
93 #if SDL_VIDEO_DRIVER_PHOTON
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
94 &ph_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
95 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
96 #if SDL_VIDEO_DRIVER_EPOC
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
97 &EPOC_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
98 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
99 #if SDL_VIDEO_DRIVER_XBIOS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
100 &XBIOS_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
101 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
102 #if SDL_VIDEO_DRIVER_GEM
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
103 &GEM_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
104 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
105 #if SDL_VIDEO_DRIVER_PICOGUI
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
106 &PG_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
107 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
108 #if SDL_VIDEO_DRIVER_DC
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
109 &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
110 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
111 #if SDL_VIDEO_DRIVER_RISCOS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
112 &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
113 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
114 #if SDL_VIDEO_DRIVER_OS2FS
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
115 &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
116 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
117 #if SDL_VIDEO_DRIVER_AALIB
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
118 &AALIB_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
120 #if SDL_VIDEO_DRIVER_DUMMY
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
121 &DUMMY_bootstrap,
610
95433459fbd2 Date: Mon, 14 Apr 2003 22:08:27 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 580
diff changeset
122 #endif
1658
e49147870aac glSDL support
Sam Lantinga <slouken@libsdl.org>
parents: 1656
diff changeset
123 #if SDL_VIDEO_DRIVER_GLSDL
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
124 &glSDL_bootstrap,
1658
e49147870aac glSDL support
Sam Lantinga <slouken@libsdl.org>
parents: 1656
diff changeset
125 #endif
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
126 NULL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 };
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
128
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
129 static SDL_VideoDevice *_this = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 /* Various local functions */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
132 int SDL_VideoInit(const char *driver_name, Uint32 flags);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
133 void SDL_VideoQuit(void);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
134
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
135 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
136 cmpmodes(const void *A, const void *B)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
137 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
138 SDL_DisplayMode a = *(const SDL_DisplayMode *) A;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
139 SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
141 if (a.w != b.w) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
142 return b.w - a.w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
143 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
144 if (a.h != b.h) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
145 return b.h - a.h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
146 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
147 if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
148 return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
149 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
150 if (a.refresh_rate != b.refresh_rate) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
151 return b.refresh_rate - a.refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
152 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
153 return 0;
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
154 }
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
155
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
156 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
157 SDL_GetNumVideoDrivers(void)
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
158 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
159 return SDL_arraysize(bootstrap) - 1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
160 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
161
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
162 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
163 SDL_GetVideoDriver(int index)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
164 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
165 if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
166 return bootstrap[index]->name;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
167 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
168 return NULL;
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
169 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 * Initialize the video and event subsystems -- determine native pixel format
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
174 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
175 SDL_VideoInit(const char *driver_name, Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
177 SDL_VideoDevice *video;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
178 int index;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
179 int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
181 /* Toggle the event thread flags, based on OS requirements */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 #if defined(MUST_THREAD_EVENTS)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
183 flags |= SDL_INIT_EVENTTHREAD;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 #elif defined(CANT_THREAD_EVENTS)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
185 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
186 SDL_SetError("OS doesn't support threaded events");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
187 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
188 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
191 /* Start the event loop */
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
192 if (SDL_StartEventLoop(flags) < 0) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
193 return -1;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
194 }
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
195
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
196 /* Check to make sure we don't overwrite '_this' */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
197 if (_this != NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
198 SDL_VideoQuit();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
199 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
200
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
201 /* Select the proper video driver */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
202 index = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
203 video = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
204 if (driver_name != NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
205 for (i = 0; bootstrap[i]; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
206 if (SDL_strncmp(bootstrap[i]->name, driver_name,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
207 SDL_strlen(bootstrap[i]->name)) == 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
208 if (bootstrap[i]->available()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
209 video = bootstrap[i]->create(index);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
210 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
211 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
212 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
213 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
214 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
215 for (i = 0; bootstrap[i]; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
216 if (bootstrap[i]->available()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
217 video = bootstrap[i]->create(index);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
218 if (video != NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
219 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
220 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
221 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
222 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
223 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
224 if (video == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
225 if (driver_name) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
226 SDL_SetError("%s not available", driver_name);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
227 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
228 SDL_SetError("No available video device");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
229 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
230 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
231 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
232 _this = video;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
233 _this->name = bootstrap[i]->name;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
234 _this->next_object_id = 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
236
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
237 /* Set some very sane GL defaults */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
238 _this->gl_config.driver_loaded = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
239 _this->gl_config.dll_handle = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
240 _this->gl_config.red_size = 3;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
241 _this->gl_config.green_size = 3;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
242 _this->gl_config.blue_size = 2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
243 _this->gl_config.alpha_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
244 _this->gl_config.buffer_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
245 _this->gl_config.depth_size = 16;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
246 _this->gl_config.stencil_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
247 _this->gl_config.double_buffer = 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
248 _this->gl_config.accum_red_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
249 _this->gl_config.accum_green_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
250 _this->gl_config.accum_blue_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
251 _this->gl_config.accum_alpha_size = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
252 _this->gl_config.stereo = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
253 _this->gl_config.multisamplebuffers = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
254 _this->gl_config.multisamplesamples = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
255 _this->gl_config.accelerated = -1; /* not known, don't set */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
257 /* Initialize the video subsystem */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
258 if (_this->VideoInit(_this) < 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
259 SDL_VideoQuit();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
260 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
261 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
262
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
263 /* Make sure some displays were added */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
264 if (_this->num_displays == 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
265 SDL_SetError("The video driver did not add any displays");
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
266 SDL_VideoQuit();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
267 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
268 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
269
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
270 /* The software renderer is always available */
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
271 for (i = 0; i < _this->num_displays; ++i) {
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
272 if (_this->displays[i].num_render_drivers > 0) {
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
273 SDL_AddRenderDriver(i, &SDL_SW_RenderDriver);
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
274 }
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
275 }
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
276
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
277 /* We're ready to go! */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
278 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
279 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
281 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
282 SDL_GetCurrentVideoDriver()
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
283 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
284 if (!_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
285 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
286 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
287 return _this->name;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
288 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
289
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
290 SDL_VideoDevice *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
291 SDL_GetVideoDevice()
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
292 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
293 return _this;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
294 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
295
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
296 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
297 SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
298 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
299 SDL_VideoDisplay display;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
300
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
301 SDL_zero(display);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
302 if (desktop_mode) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
303 display.desktop_mode = *desktop_mode;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
304 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
305 display.current_mode = display.desktop_mode;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
306
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
307 return SDL_AddVideoDisplay(&display);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
308 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
309
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
310 int
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
311 SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
312 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
313 SDL_VideoDisplay *displays;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
314 int index = -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
316 displays =
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
317 SDL_realloc(_this->displays,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
318 (_this->num_displays + 1) * sizeof(*displays));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
319 if (displays) {
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
320 index = _this->num_displays++;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
321 displays[index] = *display;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1681
diff changeset
322 displays[index].device = _this;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
323 _this->displays = displays;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
324 } else {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
325 SDL_OutOfMemory();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
326 }
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1676
diff changeset
327 return index;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
328 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
329
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
330 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
331 SDL_GetNumVideoDisplays(void)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
332 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
333 if (!_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
334 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
335 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
336 return _this->num_displays;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
337 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
339 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
340 SDL_SelectVideoDisplay(int index)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
341 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
342 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
343 SDL_SetError("Video subsystem has not been initialized");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
344 return (-1);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
345 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
346 if (index >= 0) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
347 if (index >= _this->num_displays) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
348 SDL_SetError("index must be in the range 0 - %d",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
349 _this->num_displays - 1);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
350 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
351 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
352 _this->current_display = index;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
353 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
354 return _this->current_display;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
355 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
357 SDL_bool
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
358 SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
359 {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
360 SDL_VideoDisplay *display = &_this->displays[displayIndex];
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
361 SDL_DisplayMode *modes;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
362 int i, nmodes;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
364 /* Make sure we don't already have the mode in the list */
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
365 modes = display->display_modes;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
366 nmodes = display->num_display_modes;
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
367 for (i = nmodes; i--;) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
368 if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) {
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
369 return SDL_FALSE;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
370 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
371 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
372
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
373 /* Go ahead and add the new mode */
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
374 if (nmodes == display->max_display_modes) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
375 modes =
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
376 SDL_realloc(modes,
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
377 (display->max_display_modes + 32) * sizeof(*modes));
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
378 if (!modes) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
379 return SDL_FALSE;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
380 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
381 display->display_modes = modes;
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
382 display->max_display_modes += 32;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
383 }
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
384 modes[nmodes] = *mode;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
385 display->num_display_modes++;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
386
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
387 return SDL_TRUE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
388 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
389
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
390 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
391 SDL_GetNumDisplayModes()
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
393 if (_this) {
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
394 SDL_VideoDisplay *display = &SDL_CurrentDisplay;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
395 if (!display->num_display_modes && _this->GetDisplayModes) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
396 _this->GetDisplayModes(_this);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
397 SDL_qsort(display->display_modes, display->num_display_modes,
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
398 sizeof(SDL_DisplayMode), cmpmodes);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
399 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
400 return display->num_display_modes;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
401 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
402 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
404
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
405 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
406 SDL_GetDisplayMode(int index)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
407 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
408 if (index < 0 || index >= SDL_GetNumDisplayModes()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
409 SDL_SetError("index must be in the range of 0 - %d",
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
410 SDL_GetNumDisplayModes() - 1);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
411 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
412 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
413 return &SDL_CurrentDisplay.display_modes[index];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
415
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
416 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
417 SDL_GetDesktopDisplayMode(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
419 if (_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
420 return &SDL_CurrentDisplay.desktop_mode;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
421 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
422 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
423 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
424
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
425 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
426 SDL_GetCurrentDisplayMode(void)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
427 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
428 if (_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
429 return &SDL_CurrentDisplay.current_mode;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
430 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
431 return NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
432 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
433
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
434 SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
435 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
436 SDL_DisplayMode * closest)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
437 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
438 Uint32 target_format;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
439 int target_refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
440 int i;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
441 SDL_DisplayMode *current, *match;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
442
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
443 if (!_this || !mode || !closest) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
444 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
445 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
446
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
447 /* Default to the desktop format */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
448 if (mode->format) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
449 target_format = mode->format;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
450 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
451 target_format = SDL_CurrentDisplay.desktop_mode.format;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
452 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
453
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
454 /* Default to the desktop refresh rate */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
455 if (mode->refresh_rate) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
456 target_refresh_rate = mode->refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
457 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
458 target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
459 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
460
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
461 match = NULL;
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
462 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
463 current = &SDL_CurrentDisplay.display_modes[i];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
465 if ((current->w && current->h) &&
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
466 (current->w < mode->w || current->h < mode->h)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
467 /* Out of sorted modes large enough here */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
468 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
469 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
470 if (!match || current->w < match->w || current->h < match->h) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
471 match = current;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
472 continue;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
473 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
474 if (current->format != match->format) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
475 /* Sorted highest depth to lowest */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
476 if (current->format == target_format ||
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
477 (SDL_BITSPERPIXEL(current->format) >=
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
478 SDL_BITSPERPIXEL(target_format)
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
479 && SDL_PIXELTYPE(current->format) ==
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
480 SDL_PIXELTYPE(target_format))) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
481 match = current;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
482 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
483 continue;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
484 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
485 if (current->refresh_rate != match->refresh_rate) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
486 /* Sorted highest refresh to lowest */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
487 if (current->refresh_rate >= target_refresh_rate) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
488 match = current;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
489 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
490 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
491 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
492 if (match) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
493 if (match->format) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
494 closest->format = match->format;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
495 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
496 closest->format = mode->format;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
497 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
498 if (match->w && match->h) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
499 closest->w = match->w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
500 closest->h = match->h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
501 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
502 closest->w = mode->w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
503 closest->h = mode->h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
504 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
505 if (match->refresh_rate) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
506 closest->refresh_rate = match->refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
507 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
508 closest->refresh_rate = mode->refresh_rate;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
509 }
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
510 closest->driverdata = match->driverdata;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
511
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
512 /* Pick some reasonable defaults if the app and driver don't care */
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
513 if (!closest->format) {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
514 closest->format = SDL_PixelFormat_RGB888;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
515 }
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
516 if (!closest->w) {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
517 closest->w = 640;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
518 }
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
519 if (!closest->h) {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
520 closest->h = 480;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
521 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
522 return closest;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
523 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
524 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
525 }
853
dddfc37e1f65 Don't allow video modes larger than the maximum size
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
526
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
527 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
528 SDL_SetDisplayMode(const SDL_DisplayMode * mode)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
529 {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
530 SDL_VideoDisplay *display;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
531 SDL_DisplayMode display_mode;
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
532 int i, ncolors;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
533
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
534 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
535 SDL_SetError("Video subsystem has not been initialized");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
536 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
537 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
538
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
539 if (!mode) {
1707
57ce47f033a5 Passing NULL to SDL_SetDisplayMode() will set the desktop mode.
Sam Lantinga <slouken@libsdl.org>
parents: 1706
diff changeset
540 mode = SDL_GetDesktopDisplayMode();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
541 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
542 display = &SDL_CurrentDisplay;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
543 display_mode = *mode;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
544
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
545 /* Default to the current mode */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
546 if (!display_mode.format) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
547 display_mode.format = display->current_mode.format;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
548 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
549 if (!display_mode.w) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
550 display_mode.w = display->current_mode.w;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
551 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
552 if (!display_mode.h) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
553 display_mode.h = display->current_mode.h;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
554 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
555 if (!display_mode.refresh_rate) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
556 display_mode.refresh_rate = display->current_mode.refresh_rate;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
557 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
558
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
559 /* Get a good video mode, the closest one possible */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
560 if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
561 SDL_SetError("No video mode large enough for %dx%d",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
562 display_mode.w, display_mode.h);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
563 return -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
564 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
565
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
566 /* See if there's anything left to do */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
567 if (SDL_memcmp
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
568 (&display_mode, SDL_GetCurrentDisplayMode(),
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
569 sizeof(display_mode)) == 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
570 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
571 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
572
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
573 /* Actually change the display mode */
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
574 if (_this->SetDisplayMode(_this, &display_mode) < 0) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
575 return -1;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
576 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
577 display->current_mode = display_mode;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
578
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
579 /* Set up a palette, if necessary */
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
580 if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
581 ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
582 } else {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
583 ncolors = 0;
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
584 }
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
585 if ((!ncolors && display->palette) || (ncolors && !display->palette)
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
586 || (ncolors && ncolors != display->palette->ncolors)) {
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
587 if (display->palette) {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
588 SDL_FreePalette(display->palette);
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
589 display->palette = NULL;
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
590 }
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
591 if (ncolors) {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
592 display->palette = SDL_AllocPalette(ncolors);
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
593 if (!display->palette) {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
594 return -1;
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
595 }
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
596 SDL_DitherColors(display->palette->colors,
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
597 SDL_BITSPERPIXEL(display_mode.format));
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
598 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
599 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
600
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
601 /* Move any fullscreen windows into position */
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
602 for (i = 0; i < display->num_windows; ++i) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
603 SDL_Window *window = &display->windows[i];
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
604 if (FULLSCREEN_VISIBLE(window)) {
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
605 SDL_SetWindowPosition(window->id,
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
606 ((display_mode.w - window->w) / 2),
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
607 ((display_mode.h - window->h) / 2));
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
608 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
609 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
610
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
611 return 0;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
612 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
613
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
614 int
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
615 SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
616 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
617 SDL_VideoDisplay *display;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
618 int i;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
619
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
620 if (!_this) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
621 SDL_SetError("Video subsystem has not been initialized");
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
622 return -1;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
623 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
624
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
625 display = &SDL_CurrentDisplay;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
626 if (mode) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
627 SDL_GetClosestDisplayMode(mode, &display->desired_mode);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
628 display->fullscreen_mode = &display->desired_mode;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
629 } else {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
630 display->fullscreen_mode = NULL;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
631 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
632
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
633 /* Actually set the mode if we have a fullscreen window visible */
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
634 for (i = 0; i < display->num_windows; ++i) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
635 SDL_Window *window = &display->windows[i];
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
636 if (FULLSCREEN_VISIBLE(window)) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
637 return SDL_SetDisplayMode(display->fullscreen_mode);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
638 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
639 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
640 return 0;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
641 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
642
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
643 const SDL_DisplayMode *
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
644 SDL_GetFullscreenDisplayMode(void)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
645 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
646 if (_this) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
647 return SDL_CurrentDisplay.fullscreen_mode;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
648 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
649 return NULL;
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
650 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
651
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
652 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
653 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
654 {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
655 SDL_Palette *palette;
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
656 int status = 0;
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
657
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
658 if (!_this) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
659 SDL_SetError("Video subsystem has not been initialized");
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
660 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
661 }
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
662 palette = SDL_CurrentDisplay.palette;
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
663 if (!palette) {
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
664 SDL_SetError("Display mode does not have a palette");
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
665 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
666 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
667
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
668 status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
669
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
670 if (_this->SetDisplayPalette) {
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
671 if (_this->SetDisplayPalette(_this, palette) < 0) {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
672 status = -1;
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
673 }
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
674 }
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
675 return status;
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
676 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
677
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
678 int
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
679 SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
680 {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
681 SDL_Palette *palette;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
682
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
683 if (!_this) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
684 SDL_SetError("Video subsystem has not been initialized");
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
685 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
686 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
687
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
688 palette = SDL_CurrentDisplay.palette;
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
689 if (!palette->ncolors) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
690 SDL_SetError("Display mode does not have a palette");
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
691 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
692 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
693
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
694 if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
695 SDL_SetError("Palette indices are out of range");
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
696 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
697 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
698
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
699 SDL_memcpy(colors, &palette->colors[firstcolor],
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
700 ncolors * sizeof(*colors));
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
701 return 0;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
702 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
703
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
704 SDL_WindowID
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
705 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
706 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
707 const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
1719
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
708 SDL_WINDOW_OPENGL |
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
709 SDL_WINDOW_SHOWN |
1719
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
710 SDL_WINDOW_BORDERLESS |
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
711 SDL_WINDOW_RESIZABLE |
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
712 SDL_WINDOW_MAXIMIZED |
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
713 SDL_WINDOW_MINIMIZED |
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
714 SDL_WINDOW_INPUT_GRABBED);
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
715 SDL_VideoDisplay *display;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
716 SDL_Window window;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
717 int num_windows;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
718 SDL_Window *windows;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
719
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
720 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
721 SDL_SetError("Video subsystem has not been initialized");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
722 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
723 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
724
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
725 SDL_zero(window);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
726 window.id = _this->next_object_id++;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
727 window.title = title ? SDL_strdup(title) : NULL;
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
728 window.x = x;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
729 window.y = y;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
730 window.w = w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
731 window.h = h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
732 window.flags = (flags & allowed_flags);
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
733 window.display = _this->current_display;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
734
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
735 if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
736 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
737 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
738 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
739 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
740 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
741
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
742 display = &SDL_CurrentDisplay;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
743 num_windows = display->num_windows;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
744 windows =
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
745 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
746 if (!windows) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
747 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
748 _this->DestroyWindow(_this, &window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
749 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
750 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
751 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
752 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
753 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
754 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
755 windows[num_windows] = window;
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
756 display->windows = windows;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
757 display->num_windows++;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
758
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
759 if (FULLSCREEN_VISIBLE(&window)) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
760 /* Hide any other fullscreen windows */
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
761 int i;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
762 for (i = 0; i < display->num_windows; ++i) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
763 SDL_Window *other = &display->windows[i];
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
764 if (other->id != window.id && FULLSCREEN_VISIBLE(other)) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
765 SDL_MinimizeWindow(other->id);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
766 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
767 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
768 SDL_SetDisplayMode(display->fullscreen_mode);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
769 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
770
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
771 return window.id;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
772 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
773
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
774 SDL_WindowID
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
775 SDL_CreateWindowFrom(const void *data)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
776 {
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
777 SDL_VideoDisplay *display;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
778 SDL_Window window;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
779 int num_windows;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
780 SDL_Window *windows;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
781
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
782 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
783 SDL_SetError("Video subsystem has not been initialized");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
784 return (0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
785 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
786
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
787 SDL_zero(window);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
788 window.id = _this->next_object_id++;
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
789 window.display = _this->current_display;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
790
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
791 if (!_this->CreateWindowFrom ||
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
792 _this->CreateWindowFrom(_this, &window, data) < 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
793 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
794 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
795
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
796 display = &SDL_CurrentDisplay;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
797 num_windows = display->num_windows;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
798 windows =
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
799 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
800 if (!windows) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
801 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
802 _this->DestroyWindow(_this, &window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
803 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
804 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
805 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
806 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
807 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
808 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
809 windows[num_windows] = window;
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
810 display->windows = windows;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
811 display->num_windows++;
430
60effdbf14ee Make sure width and height passed to SDL_GetVideoMode() are sane.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
812
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
813 return window.id;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
814 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
815
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
816 SDL_Window *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
817 SDL_GetWindowFromID(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
818 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
819 int i, j;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
820
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
821 if (!_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
822 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
823 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
824
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
825 for (i = 0; i < _this->num_displays; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
826 SDL_VideoDisplay *display = &_this->displays[i];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
827 for (j = 0; j < display->num_windows; ++j) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
828 SDL_Window *window = &display->windows[j];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
829 if (window->id == windowID) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
830 return window;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
831 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
832 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
833 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
834 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
835 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
836
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
837 SDL_VideoDisplay *
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
838 SDL_GetDisplayFromWindow(SDL_Window * window)
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
839 {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
840 if (!_this) {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
841 return NULL;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
842 }
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
843 return &_this->displays[window->display];
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
844 }
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
845
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
846 Uint32
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
847 SDL_GetWindowFlags(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
848 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
849 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
850
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
851 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
852 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
853 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
854 return window->flags;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
855 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
856
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
857 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
858 SDL_SetWindowTitle(SDL_WindowID windowID, const char *title)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
859 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
860 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
861
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
862 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
863 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
864 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
865 if (window->title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
866 SDL_free(window->title);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
867 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
868 window->title = SDL_strdup(title);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
869
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
870 if (_this->SetWindowTitle) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
871 _this->SetWindowTitle(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
872 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
873 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
874
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
875 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
876 SDL_GetWindowTitle(SDL_WindowID windowID)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
877 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
878 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
879
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
880 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
881 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
882 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
883 return window->title;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
884 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
885
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
886 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
887 SDL_SetWindowData(SDL_WindowID windowID, void *userdata)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
888 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
889 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
890
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
891 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
892 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
893 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
894 window->userdata = userdata;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
895 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
896
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
897 void *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
898 SDL_GetWindowData(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
899 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
900 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
901
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
902 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
903 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
904 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
905 return window->userdata;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
906 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
907
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
908 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
909 SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
910 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
911 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
912
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
913 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
914 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
915 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
916
1719
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
917 if (x != SDL_WINDOWPOS_UNDEFINED) {
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
918 window->x = x;
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
919 }
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
920 if (y != SDL_WINDOWPOS_UNDEFINED) {
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
921 window->y = y;
5b9f50c957ed You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
922 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
923
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
924 if (_this->SetWindowPosition) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
925 _this->SetWindowPosition(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
926 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
927 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
928
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
929 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
930 SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
931 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
932 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
933
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
934 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
935 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
936 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
937 if (x) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
938 *x = window->x;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
939 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
940 if (y) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
941 *y = window->y;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
942 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
943 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
944
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
945 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
946 SDL_SetWindowSize(SDL_WindowID windowID, int w, int h)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
947 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
948 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
949
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
950 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
951 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
952 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
953
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
954 window->w = w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
955 window->h = h;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
956
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
957 if (_this->SetWindowSize) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
958 _this->SetWindowSize(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
959 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
960 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
961
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
962 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
963 SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
964 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
965 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
966
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
967 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
968 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
969 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
970 if (w) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
971 *w = window->w;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
972 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
973 if (h) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
974 *h = window->h;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
975 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
976 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
977
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
978 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
979 SDL_ShowWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
980 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
981 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
982
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
983 if (!window || (window->flags & SDL_WINDOW_SHOWN)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
984 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
985 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
986
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
987 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_SHOWN, 0, 0);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
988
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
989 if (_this->ShowWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
990 _this->ShowWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
991 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
992 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
993
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
994 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
995 SDL_HideWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
996 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
997 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
998
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
999 if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1000 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1001 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1002
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1003 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_HIDDEN, 0, 0);
910
4ab6d1fd028f Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 883
diff changeset
1004
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1005 if (_this->HideWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1006 _this->HideWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1007 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1008 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1009
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1010 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1011 SDL_RaiseWindow(SDL_WindowID windowID)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1012 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1013 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1014
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1015 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1016 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1017 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1018
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1019 if (_this->RaiseWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1020 _this->RaiseWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1021 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1022 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1023
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1024 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1025 SDL_MaximizeWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1026 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1027 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1028
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1029 if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1030 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1031 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1032
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1033 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1034
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1035 if (_this->MaximizeWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1036 _this->MaximizeWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1037 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1038 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1039
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1040 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1041 SDL_MinimizeWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1042 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1043 SDL_Window *window = SDL_GetWindowFromID(windowID);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1044
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1045 if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1046 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1047 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1048
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1049 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1050
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1051 if (_this->MinimizeWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1052 _this->MinimizeWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1053 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1054 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1055
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1056 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1057 SDL_RestoreWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1058 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1059 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1060
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1061 if (!window
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1062 || (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1063 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1064 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1065
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1066 SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1067
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1068 if (_this->RestoreWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1069 _this->RestoreWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1070 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1071 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1072
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1073 int
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1074 SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen)
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1075 {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1076 SDL_Window *window = SDL_GetWindowFromID(windowID);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1077
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1078 if (!window) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1079 return -1;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1080 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1081
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1082 if (fullscreen) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1083 fullscreen = SDL_WINDOW_FULLSCREEN;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1084 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1085 if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1086 return 0;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1087 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1088
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1089 if (fullscreen) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1090 window->flags |= SDL_WINDOW_FULLSCREEN;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1091
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1092 if (FULLSCREEN_VISIBLE(window)) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1093 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1094
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1095 /* Hide any other fullscreen windows */
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1096 int i;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1097 for (i = 0; i < display->num_windows; ++i) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1098 SDL_Window *other = &display->windows[i];
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1099 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1100 SDL_MinimizeWindow(other->id);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1101 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1102 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1103
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1104 SDL_SetDisplayMode(display->fullscreen_mode);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1105 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1106 } else {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1107 window->flags &= ~SDL_WINDOW_FULLSCREEN;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1108
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1109 if (FULLSCREEN_VISIBLE(window)) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1110 SDL_SetDisplayMode(NULL);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1111 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1112 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1113 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1114
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1115 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1116 SDL_SetWindowGrab(SDL_WindowID windowID, int mode)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1117 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1118 SDL_Window *window = SDL_GetWindowFromID(windowID);
14
c3e9d4a623c1 Fixed stuck keys when changing the video mode
Sam Lantinga <slouken@lokigames.com>
parents: 11
diff changeset
1119
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1120 if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1121 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1122 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1123
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1124 if (mode) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1125 window->flags |= SDL_WINDOW_INPUT_GRABBED;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1126 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1127 window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1128 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1129
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1130 if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1131 _this->SetWindowGrab(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1132 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1133 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1134
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1135 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1136 SDL_GetWindowGrab(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1137 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1138 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1139
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1140 if (!window) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1141 return 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1142 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1143
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1144 return ((window->flags & SDL_WINDOW_INPUT_GRABBED) != 0);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1145 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1146
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1147 void
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1148 SDL_OnWindowShown(SDL_Window * window)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1149 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1150 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1151
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1152 void
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1153 SDL_OnWindowHidden(SDL_Window * window)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1154 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1155 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1156
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1157 void
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1158 SDL_OnWindowFocusGained(SDL_Window * window)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1159 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1160 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1161
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1162 if (window->flags & SDL_WINDOW_FULLSCREEN) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1163 SDL_SetDisplayMode(display->fullscreen_mode);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1164 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1165 if (display->gamma && _this->SetDisplayGammaRamp) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1166 _this->SetDisplayGammaRamp(_this, display->gamma);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1167 }
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1168 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1169 _this->SetWindowGrab(_this, window);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1170 }
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1171 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1172
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1173 void
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1174 SDL_OnWindowFocusLost(SDL_Window * window)
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1175 {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1176 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1177
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1178 if (window->flags & SDL_WINDOW_FULLSCREEN) {
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1179 SDL_MinimizeWindow(window->id);
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1180 SDL_SetDisplayMode(NULL);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1181 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1182 if (display->gamma && _this->SetDisplayGammaRamp) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1183 _this->SetDisplayGammaRamp(_this, display->saved_gamma);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1184 }
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1185 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1186 _this->SetWindowGrab(_this, window);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1187 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1188 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1189
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1190 SDL_WindowID
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1191 SDL_GetFocusWindow(void)
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1192 {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1193 SDL_VideoDisplay *display;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1194 int i;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1195
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1196 if (!_this) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1197 return 0;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1198 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1199
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1200 display = &SDL_CurrentDisplay;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1201 for (i = 0; i < display->num_windows; ++i) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1202 SDL_Window *window = &display->windows[i];
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1203
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1204 if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1205 return window->id;
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1206 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1207 }
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1208 return 0;
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1209 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1210
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
1211 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1212 SDL_DestroyWindow(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1213 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1214 int i, j;
229
4d24d5a660a8 Fix a crash if an OpenGL video mode can't be set.
Sam Lantinga <slouken@libsdl.org>
parents: 216
diff changeset
1215
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1216 if (!_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1217 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1218 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1219
1734
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1220 /* Restore video mode, etc. */
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1221 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
f7c667ded87d The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents: 1733
diff changeset
1222
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1223 for (i = 0; i < _this->num_displays; ++i) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1224 SDL_VideoDisplay *display = &_this->displays[i];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1225 for (j = 0; j < display->num_windows; ++j) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1226 SDL_Window *window = &display->windows[j];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1227 if (window->id != windowID) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1228 continue;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1229 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1230 if (window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1231 SDL_DestroyRenderer(window->id);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1232 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1233 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1234 _this->DestroyWindow(_this, window);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1235 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1236 if (window->title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1237 SDL_free(window->title);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1238 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1239 if (j != display->num_windows - 1) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1240 SDL_memcpy(&display->windows[i],
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1241 &display->windows[i + 1],
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1242 (display->num_windows - i - 1) * sizeof(*window));
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1243 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1244 --display->num_windows;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1245 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1246 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1247 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1248 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1249
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1250 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1251 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1252 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1253 SDL_VideoDisplay *display = &_this->displays[displayIndex];
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1254 SDL_RenderDriver *render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1255
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1256 render_drivers =
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1257 SDL_realloc(display->render_drivers,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1258 (display->num_render_drivers +
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1259 1) * sizeof(*render_drivers));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1260 if (render_drivers) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1261 render_drivers[display->num_render_drivers] = *driver;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1262 display->render_drivers = render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1263 display->num_render_drivers++;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1264 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1265 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1266
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1267 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1268 SDL_GetNumRenderers(void)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1269 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1270 if (_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1271 return SDL_CurrentDisplay.num_render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1272 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1273 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1274 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1275
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1276 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1277 SDL_GetRendererInfo(int index, SDL_RendererInfo * info)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1278 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1279 if (index < 0 || index >= SDL_GetNumRenderers()) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1280 SDL_SetError("index must be in the range of 0 - %d",
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1281 SDL_GetNumRenderers() - 1);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1282 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1283 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1284 *info = SDL_CurrentDisplay.render_drivers[index].info;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1285 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1286 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1287
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1288 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1289 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1290 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1291 SDL_Window *window = SDL_GetWindowFromID(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1292
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1293 if (!window) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1294 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1295 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1296
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1297 if (index < 0) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1298 int n = SDL_GetNumRenderers();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1299 for (index = 0; index < n; ++index) {
1680
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1300 SDL_RenderDriver *driver =
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1301 &SDL_CurrentDisplay.render_drivers[index];
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1302
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1303 /* Skip minimal drivers in automatic scans */
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1304 if (!(flags & SDL_Renderer_Minimal)
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1305 && (driver->info.flags & SDL_Renderer_Minimal)) {
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1306 continue;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1307 }
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1308 if ((driver->info.flags & flags) == flags) {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1309 break;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1310 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1311 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1312 if (index == n) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1313 SDL_SetError("Couldn't find matching render driver");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1314 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1315 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1316 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1317
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1318 if (index >= SDL_GetNumRenderers()) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1319 SDL_SetError("index must be -1 or in the range of 0 - %d",
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1320 SDL_GetNumRenderers() - 1);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1321 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1322 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1323
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1324 /* Free any existing renderer */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1325 SDL_DestroyRenderer(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1326
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1327 /* Create a new renderer instance */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1328 window->renderer =
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1329 SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1330 flags);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1331 if (!window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1332 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1333 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1334 SDL_CurrentDisplay.current_renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1335
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1336 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1337 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1338
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1339 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1340 SDL_SelectRenderer(SDL_WindowID windowID)
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1341 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1342 SDL_Window *window = SDL_GetWindowFromID(windowID);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1343
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1344 if (!window || !window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1345 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1346 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1347 SDL_CurrentDisplay.current_renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1348 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1349 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1350
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1351 SDL_TextureID
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1352 SDL_CreateTexture(Uint32 format, int access, int w, int h)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1353 {
1680
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1354 int hash;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1355 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1356 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1357
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1358 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1359 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1360 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1361
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1362 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1363 if (!renderer || !renderer->CreateTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1364 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1365 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1366
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1367 texture = (SDL_Texture *) SDL_malloc(sizeof(*texture));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1368 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1369 SDL_OutOfMemory();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1370 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1371 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1372
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1373 SDL_zerop(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1374 texture->id = _this->next_object_id++;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1375 texture->format = format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1376 texture->access = access;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1377 texture->w = w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1378 texture->h = h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1379 texture->renderer = renderer;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1380
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1381 if (renderer->CreateTexture(renderer, texture) < 0) {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1382 SDL_free(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1383 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1384 }
1680
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1385
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1386 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1387 texture->next = SDL_CurrentDisplay.textures[hash];
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1388 SDL_CurrentDisplay.textures[hash] = texture;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1389
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1390 return texture->id;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1391 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1392
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1393 SDL_TextureID
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1394 SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1395 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1396 SDL_TextureID textureID;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1397 Uint32 surface_flags = surface->flags;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1398 SDL_PixelFormat *fmt = surface->format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1399 Uint8 alpha;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1400 SDL_Rect bounds;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1401 SDL_Surface dst;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1402 int bpp;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1403 Uint32 Rmask, Gmask, Bmask, Amask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1404
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1405 if (!surface) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1406 SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1407 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1408 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1409
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1410 if (format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1411 if (!SDL_PixelFormatEnumToMasks
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1412 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1413 SDL_SetError("Unknown pixel format");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1414 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1415 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1416 } else {
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1417 if (fmt->Amask || !(surface_flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA))) {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1418 bpp = fmt->BitsPerPixel;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1419 Rmask = fmt->Rmask;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1420 Gmask = fmt->Gmask;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1421 Bmask = fmt->Bmask;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1422 Amask = fmt->Amask;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1423 } else {
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1424 /* Need a format with alpha */
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1425 bpp = 32;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1426 Rmask = 0x00FF0000;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1427 Gmask = 0x0000FF00;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1428 Bmask = 0x000000FF;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1429 Amask = 0xFF000000;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1430 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1431 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1432 if (!format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1433 SDL_SetError("Unknown pixel format");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1434 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1435 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1436 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1437
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1438 textureID = SDL_CreateTexture(format, access, surface->w, surface->h);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1439 if (!textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1440 return 0;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1441 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1442
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1443 /* Set up a destination surface for the texture update */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1444 SDL_zero(dst);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1445 dst.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1446 if (!dst.format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1447 SDL_DestroyTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1448 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1449 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1450 dst.w = surface->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1451 dst.h = surface->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1452 if (SDL_LockTexture(textureID, NULL, 1, &dst.pixels, &dst.pitch) == 0) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1453 dst.flags |= SDL_PREALLOC;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1454 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1455 dst.pitch = SDL_CalculatePitch(&dst);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1456 dst.pixels = SDL_malloc(dst.h * dst.pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1457 if (!dst.pixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1458 SDL_DestroyTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1459 SDL_FreeFormat(dst.format);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1460 SDL_OutOfMemory();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1461 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1462 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1463 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1464
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1465 /* Copy the palette if any */
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1466 if (SDL_ISPIXELFORMAT_INDEXED(format)) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1467 if (fmt->palette) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1468 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1469 fmt->palette->ncolors);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1470 SDL_SetSurfacePalette(&dst, fmt->palette);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1471 } else {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1472 dst.format->palette =
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1473 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1474 if (!dst.format->palette) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1475 SDL_DestroyTexture(textureID);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1476 SDL_FreeFormat(dst.format);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1477 return 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1478 }
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1479 SDL_DitherColors(dst.format->palette->colors,
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1480 SDL_BITSPERPIXEL(format));
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1481 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1482 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1483
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1484 /* Make the texture transparent if the surface has colorkey */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1485 if (surface_flags & SDL_SRCCOLORKEY) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1486 int row;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1487 int length = dst.w * dst.format->BytesPerPixel;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1488 Uint8 *p = (Uint8 *) dst.pixels;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1489 for (row = 0; row < dst.h; ++row) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1490 SDL_memset(p, 0, length);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1491 p += dst.pitch;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1492 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1493 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1494
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1495 /* Copy over the alpha channel */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1496 if (surface_flags & SDL_SRCALPHA) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1497 if (fmt->Amask) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1498 surface->flags &= ~SDL_SRCALPHA;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1499 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1500 /* FIXME: Need to make sure the texture has an alpha channel
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1501 * and copy 'alpha' into the texture alpha channel.
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1502 */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1503 alpha = surface->format->alpha;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1504 SDL_SetAlpha(surface, 0, 0);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1505 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1506 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1507
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1508 /* Copy over the image data */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1509 bounds.x = 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1510 bounds.y = 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1511 bounds.w = surface->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1512 bounds.h = surface->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1513 SDL_LowerBlit(surface, &bounds, &dst, &bounds);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1514
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1515 /* Clean up the original surface */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1516 if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1517 Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1518 if (fmt->Amask) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1519 surface->flags |= SDL_SRCALPHA;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1520 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1521 SDL_SetAlpha(surface, aflags, alpha);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1522 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1523 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1524
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1525 /* Update the texture */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1526 if (dst.flags & SDL_PREALLOC) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1527 SDL_UnlockTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1528 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1529 SDL_UpdateTexture(textureID, NULL, dst.pixels, dst.pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1530 SDL_free(dst.pixels);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1531 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1532 SDL_FreeFormat(dst.format);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1533
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1534 return textureID;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1535 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1536
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1537 static __inline__ SDL_Texture *
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1538 SDL_GetTextureFromID(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1539 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1540 int hash;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1541 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1542
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1543 if (!_this) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1544 return NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1545 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1546
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1547 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1548 for (texture = SDL_CurrentDisplay.textures[hash]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1549 texture = texture->next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1550 if (texture->id == textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1551 return texture;
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
1552 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1553 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1554 return NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1555 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1556
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1557 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1558 SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1559 int *w, int *h)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1560 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1561 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1562
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1563 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1564 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1565 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1566
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1567 if (format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1568 *format = texture->format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1569 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1570 if (access) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1571 *access = texture->access;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1572 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1573 if (w) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1574 *w = texture->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1575 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1576 if (h) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1577 *h = texture->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1578 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1579 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1580 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1581
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1582 int
1678
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1583 SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch)
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1584 {
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1585 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1586 SDL_Renderer *renderer;
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1587
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1588 if (!texture) {
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1589 return -1;
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1590 }
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1591
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1592 renderer = texture->renderer;
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1593 if (!renderer->QueryTexturePixels) {
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1594 return -1;
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1595 }
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1596 return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1597 }
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1598
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
1599 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1600 SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors,
1680
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1601 int firstcolor, int ncolors)
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1602 {
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1603 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1604 SDL_Renderer *renderer;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1605
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1606 if (!texture) {
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1607 return -1;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1608 }
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1609
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1610 renderer = texture->renderer;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1611 if (!renderer->SetTexturePalette) {
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1612 return -1;
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1613 }
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1614 return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1615 ncolors);
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1616 }
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1617
9488fca10677 Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents: 1679
diff changeset
1618 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1619 SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors,
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1620 int firstcolor, int ncolors)
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1621 {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1622 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1623 SDL_Renderer *renderer;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1624
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1625 if (!texture) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1626 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1627 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1628
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1629 renderer = texture->renderer;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1630 if (!renderer->GetTexturePalette) {
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1631 return -1;
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1632 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1633 return renderer->GetTexturePalette(renderer, texture, colors, firstcolor,
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1634 ncolors);
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1635 }
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1636
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1637 int
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1638 SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect,
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1639 const void *pixels, int pitch)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1640 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1641 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1642 SDL_Renderer *renderer;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1643 SDL_Rect full_rect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1644
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1645 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1646 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1647 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1648
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1649 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1650 if (!renderer->UpdateTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1651 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1652 }
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1653
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1654 if (!rect) {
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1655 full_rect.x = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1656 full_rect.y = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1657 full_rect.w = texture->w;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1658 full_rect.h = texture->h;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1659 rect = &full_rect;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1660 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1661
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1662 return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1663 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1664
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1665 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1666 SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty,
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1667 void **pixels, int *pitch)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1668 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1669 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1670 SDL_Renderer *renderer;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1671 SDL_Rect full_rect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1672
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1673 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1674 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1675 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1676
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1677 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1678 if (!renderer->LockTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1679 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1680 }
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1681
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1682 if (!rect) {
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1683 full_rect.x = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1684 full_rect.y = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1685 full_rect.w = texture->w;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1686 full_rect.h = texture->h;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1687 rect = &full_rect;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1688 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1689
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1690 return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1691 pitch);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1692 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1693
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1694 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1695 SDL_UnlockTexture(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1696 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1697 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1698 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1699
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1700 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1701 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1702 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1703
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1704 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1705 if (!renderer->UnlockTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1706 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1707 }
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
1708 renderer->UnlockTexture(renderer, texture);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1709 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1710
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1711 void
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1712 SDL_DirtyTexture(SDL_TextureID textureID, int numrects,
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1713 const SDL_Rect * rects)
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1714 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1715 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1716 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1717
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1718 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1719 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1720 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1721
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1722 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1723 if (!renderer->DirtyTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1724 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1725 }
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1726 renderer->DirtyTexture(renderer, texture, numrects, rects);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1727 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1728
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1729 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1730 SDL_SelectRenderTexture(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1731 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1732 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1733 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1734
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1735 if (!texture || texture->access != SDL_TextureAccess_Render) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1736 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1737 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1738 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1739 if (!renderer->SelectRenderTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1740 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1741 }
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1742 renderer->SelectRenderTexture(renderer, texture);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1743 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1744
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1745 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1746 SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1747 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1748 SDL_Renderer *renderer;
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1749 SDL_Window *window;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1750 SDL_Rect real_rect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1751
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1752 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1753 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1754 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1755
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1756 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1757 if (!renderer || !renderer->RenderFill) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1758 return -1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1759 }
910
4ab6d1fd028f Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 883
diff changeset
1760
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1761 window = SDL_GetWindowFromID(renderer->window);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1762 real_rect.x = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1763 real_rect.y = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1764 real_rect.w = window->w;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1765 real_rect.h = window->h;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1766 if (rect) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1767 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1768 return 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1769 }
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1770 }
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1771 rect = &real_rect;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1772
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
1773 return renderer->RenderFill(renderer, rect, color);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1774 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1775
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1776 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1777 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1778 const SDL_Rect * dstrect, int blendMode, int scaleMode)
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1779 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1780 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1781 SDL_Renderer *renderer;
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1782 SDL_Window *window;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1783 SDL_Rect real_srcrect;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1784 SDL_Rect real_dstrect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1785
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1786 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
1787 return -1;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1788 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1789
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1790 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1791 if (!renderer || !renderer->RenderCopy) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1792 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1793 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1794
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1795 /* FIXME: implement clipping */
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1796 window = SDL_GetWindowFromID(renderer->window);
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1797 real_srcrect.x = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1798 real_srcrect.y = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1799 real_srcrect.w = texture->w;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1800 real_srcrect.h = texture->h;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1801 real_dstrect.x = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1802 real_dstrect.y = 0;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1803 real_dstrect.w = window->w;
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1804 real_dstrect.h = window->h;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1805 if (!srcrect) {
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1806 srcrect = &real_srcrect;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1807 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1808 if (!dstrect) {
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
1809 dstrect = &real_dstrect;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1810 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1811
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1812 return renderer->RenderCopy(renderer, texture, srcrect, dstrect,
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1813 blendMode, scaleMode);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1814 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1815
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1816 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1817 SDL_RenderReadPixels(const SDL_Rect * rect, void *pixels, int pitch)
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1818 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1819 SDL_Renderer *renderer;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1820 SDL_Rect full_rect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1821
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1822 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1823 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1824 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1825
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1826 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1827 if (!renderer || !renderer->RenderReadPixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1828 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1829 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1830
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1831 if (!rect) {
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1832 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1833 full_rect.x = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1834 full_rect.y = 0;
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1835 full_rect.w = window->w;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1836 full_rect.h = window->h;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1837 rect = &full_rect;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1838 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1839
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1840 return renderer->RenderReadPixels(renderer, rect, pixels, pitch);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1841 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1842
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1843 int
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
1844 SDL_RenderWritePixels(const SDL_Rect * rect, const void *pixels, int pitch)
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1845 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1846 SDL_Renderer *renderer;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1847 SDL_Rect full_rect;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1848
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1849 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1850 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1851 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1852
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1853 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1854 if (!renderer || !renderer->RenderWritePixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1855 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1856 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1857
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1858 if (!rect) {
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1859 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1860 full_rect.x = 0;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1861 full_rect.y = 0;
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1862 full_rect.w = window->w;
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1684
diff changeset
1863 full_rect.h = window->h;
1684
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1864 rect = &full_rect;
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1865 }
c4aa1a2f48f1 Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
1866
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1867 return renderer->RenderWritePixels(renderer, rect, pixels, pitch);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1868 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1869
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1870 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1871 SDL_RenderPresent(void)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1872 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1873 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1874
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1875 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1876 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1877 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1878
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1879 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1880 if (!renderer || !renderer->RenderPresent) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1881 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1882 }
650
fe445b59d307 We need to lookup the address of glGetString before calling GL_MakeCurrent(),
Ryan C. Gordon <icculus@icculus.org>
parents: 630
diff changeset
1883
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1884 renderer->RenderPresent(renderer);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1885 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1886
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1887 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1888 SDL_DestroyTexture(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1889 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1890 int hash;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1891 SDL_Texture *prev, *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1892 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1893
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1894 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1895 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1896 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1897
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1898 /* Look up the texture in the hash table */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1899 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1900 prev = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1901 for (texture = SDL_CurrentDisplay.textures[hash]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1902 prev = texture, texture = texture->next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1903 if (texture->id == textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1904 break;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1905 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1906 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1907 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1908 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1909 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1910
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1911 /* Unlink the texture from the list */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1912 if (prev) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1913 prev->next = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1914 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1915 SDL_CurrentDisplay.textures[hash] = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1916 }
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
1917
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1918 /* Free the texture */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1919 renderer = texture->renderer;
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1920 renderer->DestroyTexture(renderer, texture);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1921 SDL_free(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1922 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1923
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1924 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1925 SDL_DestroyRenderer(SDL_WindowID windowID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1926 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1927 SDL_Window *window = SDL_GetWindowFromID(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1928 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1929 int i;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1930
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1931 if (!window) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1932 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1933 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1934
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1935 renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1936 if (!renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1937 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1938 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1939
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1940 /* Free existing textures for this renderer */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1941 for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1942 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1943 SDL_Texture *prev = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1944 SDL_Texture *next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1945 for (texture = SDL_CurrentDisplay.textures[i]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1946 texture = next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1947 next = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1948 if (texture->renderer == renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1949 if (prev) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1950 prev->next = next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1951 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1952 SDL_CurrentDisplay.textures[i] = next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1953 }
1676
e136f3ffdc1b Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents: 1672
diff changeset
1954 renderer->DestroyTexture(renderer, texture);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1955 SDL_free(texture);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1956 } else {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1957 prev = texture;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1958 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1959 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1960 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1961
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1962 /* Free the renderer instance */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1963 renderer->DestroyRenderer(renderer);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1964
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1965 /* Clear references */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1966 window->renderer = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1967 if (SDL_CurrentDisplay.current_renderer == renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1968 SDL_CurrentDisplay.current_renderer = NULL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1969 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1970 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1971
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1972 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1973 SDL_VideoQuit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1974 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1975 int i, j;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1976
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1977 if (!_this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1978 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1979 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1980
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1981 /* Halt event processing before doing anything else */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1982 SDL_StopEventLoop();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1983
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1984 /* Clean up the system video */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1985 for (i = _this->num_displays; i--;) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1986 SDL_VideoDisplay *display = &_this->displays[i];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1987 for (j = display->num_windows; j--;) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1988 SDL_DestroyWindow(display->windows[i].id);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1989 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1990 if (display->windows) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1991 SDL_free(display->windows);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1992 display->windows = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1993 }
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1994 display->num_windows = 0;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1995 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1996 _this->VideoQuit(_this);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1997
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1998 for (i = _this->num_displays; i--;) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
1999 SDL_VideoDisplay *display = &_this->displays[i];
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2000 for (j = display->num_display_modes; j--;) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2001 if (display->display_modes[j].driverdata) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2002 SDL_free(display->display_modes[j].driverdata);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2003 display->display_modes[j].driverdata = NULL;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2004 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2005 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2006 if (display->display_modes) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2007 SDL_free(display->display_modes);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2008 display->display_modes = NULL;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2009 }
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2010 if (display->desktop_mode.driverdata) {
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2011 SDL_free(display->desktop_mode.driverdata);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2012 display->desktop_mode.driverdata = NULL;
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2013 }
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
2014 if (display->palette) {
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
2015 SDL_FreePalette(display->palette);
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
2016 display->palette = NULL;
1681
80a5e6a4e1e2 Working on paletted display and texture support (two different issues)
Sam Lantinga <slouken@libsdl.org>
parents: 1680
diff changeset
2017 }
1733
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2018 if (display->gamma) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2019 SDL_free(display->gamma);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2020 }
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2021 if (display->driverdata) {
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2022 SDL_free(display->driverdata);
0b1070f2f94d Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents: 1729
diff changeset
2023 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2024 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2025 if (_this->displays) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2026 SDL_free(_this->displays);
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
2027 _this->displays = NULL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2028 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2029 _this->free(_this);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2030 _this = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2031 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2032
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2033 /* Load the GL driver library */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2034 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2035 SDL_GL_LoadLibrary(const char *path)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2036 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2037 int retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2038
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2039 retval = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2040 if (_this == NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2041 SDL_SetError("Video subsystem has not been initialized");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2042 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2043 if (_this->GL_LoadLibrary) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2044 retval = _this->GL_LoadLibrary(_this, path);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2045 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2046 SDL_SetError("No dynamic GL support in video driver");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2047 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2048 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2049 return (retval);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2050 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2051
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2052 void *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2053 SDL_GL_GetProcAddress(const char *proc)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2054 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2055 void *func;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2056
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2057 func = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2058 if (_this->GL_GetProcAddress) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2059 if (_this->gl_config.driver_loaded) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2060 func = _this->GL_GetProcAddress(_this, proc);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2061 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2062 SDL_SetError("No GL driver has been loaded");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2063 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2064 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2065 SDL_SetError("No dynamic GL support in video driver");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2066 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2067 return func;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2068 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2069
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2070 /* Set the specified GL attribute for setting up a GL video mode */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2071 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2072 SDL_GL_SetAttribute(SDL_GLattr attr, int value)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2073 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2074 int retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2075
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2076 retval = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2077 switch (attr) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2078 case SDL_GL_RED_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2079 _this->gl_config.red_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2080 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2081 case SDL_GL_GREEN_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2082 _this->gl_config.green_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2083 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2084 case SDL_GL_BLUE_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2085 _this->gl_config.blue_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2086 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2087 case SDL_GL_ALPHA_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2088 _this->gl_config.alpha_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2089 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2090 case SDL_GL_DOUBLEBUFFER:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2091 _this->gl_config.double_buffer = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2092 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2093 case SDL_GL_BUFFER_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2094 _this->gl_config.buffer_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2095 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2096 case SDL_GL_DEPTH_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2097 _this->gl_config.depth_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2098 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2099 case SDL_GL_STENCIL_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2100 _this->gl_config.stencil_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2101 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2102 case SDL_GL_ACCUM_RED_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2103 _this->gl_config.accum_red_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2104 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2105 case SDL_GL_ACCUM_GREEN_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2106 _this->gl_config.accum_green_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2107 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2108 case SDL_GL_ACCUM_BLUE_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2109 _this->gl_config.accum_blue_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2110 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2111 case SDL_GL_ACCUM_ALPHA_SIZE:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2112 _this->gl_config.accum_alpha_size = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2113 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2114 case SDL_GL_STEREO:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2115 _this->gl_config.stereo = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2116 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2117 case SDL_GL_MULTISAMPLEBUFFERS:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2118 _this->gl_config.multisamplebuffers = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2119 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2120 case SDL_GL_MULTISAMPLESAMPLES:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2121 _this->gl_config.multisamplesamples = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2122 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2123 case SDL_GL_ACCELERATED_VISUAL:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2124 _this->gl_config.accelerated = value;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2125 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2126 default:
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2127 SDL_SetError("Unknown OpenGL attribute");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2128 retval = -1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2129 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2130 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2131 return (retval);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2132 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2133
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2134 /* Retrieve an attribute value from the windowing system. */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2135 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2136 SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2137 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2138 int retval = -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2139
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2140 if (_this->GL_GetAttribute) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2141 retval = _this->GL_GetAttribute(_this, attr, value);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2142 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2143 *value = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2144 SDL_SetError("GL_GetAttribute not supported");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2145 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2146 return retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2147 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2148
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2149 /* Perform a GL buffer swap on the current GL context */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2150 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2151 SDL_GL_SwapBuffers(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2152 {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
2153 // FIXME: Track the current window context - do we provide N contexts, and match them to M windows, or is there a one-to-one mapping?
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
2154 _this->GL_SwapBuffers(_this);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2155 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2156
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2157 #if 0 // FIXME
541
796f2fe699be Support 1-bit alpha on surfaces passed to SDL_WM_SetIcon() (thanks Glenn!)
Sam Lantinga <slouken@libsdl.org>
parents: 509
diff changeset
2158 /* Utility function used by SDL_WM_SetIcon();
796f2fe699be Support 1-bit alpha on surfaces passed to SDL_WM_SetIcon() (thanks Glenn!)
Sam Lantinga <slouken@libsdl.org>
parents: 509
diff changeset
2159 * flags & 1 for color key, flags & 2 for alpha channel. */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2160 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2161 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2162 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2163 int x, y;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2164 Uint32 colorkey;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2165 #define SET_MASKBIT(icon, x, y, mask) \
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2166 mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8)))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2167
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2168 colorkey = icon->format->colorkey;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2169 switch (icon->format->BytesPerPixel) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2170 case 1:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2171 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2172 Uint8 *pixels;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2173 for (y = 0; y < icon->h; ++y) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2174 pixels = (Uint8 *) icon->pixels + y * icon->pitch;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2175 for (x = 0; x < icon->w; ++x) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2176 if (*pixels++ == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2177 SET_MASKBIT(icon, x, y, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2178 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2179 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2180 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2181 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2182 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2183
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2184 case 2:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2185 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2186 Uint16 *pixels;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2187 for (y = 0; y < icon->h; ++y) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2188 pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2189 for (x = 0; x < icon->w; ++x) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2190 if ((flags & 1) && *pixels == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2191 SET_MASKBIT(icon, x, y, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2192 } else if ((flags & 2)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2193 && (*pixels & icon->format->Amask) == 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2194 SET_MASKBIT(icon, x, y, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2195 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2196 pixels++;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2197 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2198 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2199 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2200 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2201
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2202 case 4:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2203 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2204 Uint32 *pixels;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2205 for (y = 0; y < icon->h; ++y) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2206 pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2207 for (x = 0; x < icon->w; ++x) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2208 if ((flags & 1) && *pixels == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2209 SET_MASKBIT(icon, x, y, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2210 } else if ((flags & 2)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2211 && (*pixels & icon->format->Amask) == 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2212 SET_MASKBIT(icon, x, y, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2213 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2214 pixels++;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2215 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2216 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2217 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2218 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2219 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2220 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2221
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2222 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2223 * Sets the window manager icon for the display window.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2224 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2225 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2226 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2227 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2228 if (icon && _this->SetIcon) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2229 /* Generate a mask if necessary, and create the icon! */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2230 if (mask == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2231 int mask_len = icon->h * (icon->w + 7) / 8;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2232 int flags = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2233 mask = (Uint8 *) SDL_malloc(mask_len);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2234 if (mask == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2235 return;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2236 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2237 SDL_memset(mask, ~0, mask_len);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2238 if (icon->flags & SDL_SRCCOLORKEY)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2239 flags |= 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2240 if (icon->flags & SDL_SRCALPHA)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2241 flags |= 2;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2242 if (flags) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2243 CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2244 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2245 _this->SetIcon(_this, icon, mask);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2246 SDL_free(mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2247 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2248 _this->SetIcon(_this, icon, mask);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2249 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2250 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2251 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2252 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2253
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2254 SDL_bool
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1719
diff changeset
2255 SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2256 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2257 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2258
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2259 if (!window || !_this->GetWindowWMInfo) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2260 return SDL_FALSE;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2261 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
2262 return (_this->GetWindowWMInfo(_this, window, info));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2263 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2264
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
2265 /* vi: set ts=4 sw=4 expandtab: */