annotate src/video/SDL_video.c @ 1672:8e754b82cecc SDL-1.3

Updated SDL_Surface code for software-only access, fixed some build errors
author Sam Lantinga <slouken@libsdl.org>
date Fri, 09 Jun 2006 07:06:12 +0000
parents eef792d31de8
children e136f3ffdc1b
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"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
30 #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
31 #include "../events/SDL_events_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 /* Available video drivers */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 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
35 #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
36 &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
37 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
38 #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
39 &X11_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
41 #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
42 &DGA_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
44 #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
45 &NX_bootstrap,
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents: 19
diff changeset
46 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
47 #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
48 &iPod_bootstrap,
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1133
diff changeset
49 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
50 #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
51 &Qtopia_bootstrap,
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 541
diff changeset
52 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
53 #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
54 &WSCONS_bootstrap,
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1141
diff changeset
55 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
56 #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
57 &FBCON_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
59 #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
60 &DirectFB_bootstrap,
167
cb384ef627f6 Added support for DirectFB video on Linux (thanks Denis!)
Sam Lantinga <slouken@libsdl.org>
parents: 125
diff changeset
61 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
62 #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
63 &PS2GS_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
65 #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
66 &GGI_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
68 #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
69 &VGL_bootstrap,
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents: 58
diff changeset
70 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
71 #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
72 &SVGALIB_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
74 #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
75 &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
76 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
77 #if SDL_VIDEO_DRIVER_WINDIB
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
78 &WINDIB_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
79 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
80 #if SDL_VIDEO_DRIVER_DDRAW
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
81 &DIRECTX_bootstrap,
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
82 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
83 #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
84 &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
85 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
86 #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
87 &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
88 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
89 #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
90 &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
91 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
92 #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
93 &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
94 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
95 #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
96 &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
97 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
98 #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
99 &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
100 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
101 #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
102 &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
103 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
104 #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
105 &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
106 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
107 #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
108 &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
109 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
110 #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
111 &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
112 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
113 #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
114 &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
115 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
116 #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
117 &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
118 #endif
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
119 #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
120 &AALIB_bootstrap,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
122 #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
123 &DUMMY_bootstrap,
610
95433459fbd2 Date: Mon, 14 Apr 2003 22:08:27 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 580
diff changeset
124 #endif
1658
e49147870aac glSDL support
Sam Lantinga <slouken@libsdl.org>
parents: 1656
diff changeset
125 #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
126 &glSDL_bootstrap,
1658
e49147870aac glSDL support
Sam Lantinga <slouken@libsdl.org>
parents: 1656
diff changeset
127 #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
128 NULL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 };
173
83018110dce8 Added initial support for EPOC/Symbian OS (thanks Hannu!)
Sam Lantinga <slouken@libsdl.org>
parents: 167
diff changeset
130
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
131 static SDL_VideoDevice *_this = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 /* Various local functions */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
134 int SDL_VideoInit(const char *driver_name, Uint32 flags);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
135 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
136
782fd950bd46 Revamp of the video system in 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 static int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
138 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
139 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
140 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
141 SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142
1662
782fd950bd46 Revamp of the video system in 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 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
144 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
145 }
782fd950bd46 Revamp of the video system in 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 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
147 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
148 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
149 if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
150 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
151 }
782fd950bd46 Revamp of the video system in 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 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
153 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
154 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
155 return 0;
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
156 }
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
157
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
158 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
159 SDL_GetNumVideoDrivers(void)
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
160 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
161 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
162 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
163
782fd950bd46 Revamp of the video system in 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 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
165 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
166 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
167 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
168 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
169 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
170 return NULL;
1660
8b9d79e7eacf Added API requested in bug #43:
Sam Lantinga <slouken@libsdl.org>
parents: 1658
diff changeset
171 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 * Initialize the video and event subsystems -- determine native pixel format
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
176 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
177 SDL_VideoInit(const char *driver_name, Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 {
1662
782fd950bd46 Revamp of the video system in 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 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
180 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
181 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
182 int bpp;
782fd950bd46 Revamp of the video system in 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 Uint32 Rmask, Gmask, Bmask, Amask;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184
1662
782fd950bd46 Revamp of the video system in 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 /* Toggle the event thread flags, based on OS requirements */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 #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
187 flags |= SDL_INIT_EVENTTHREAD;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 #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
189 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
190 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
191 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
192 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
195 /* 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
196 if (_this != NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
197 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
198 }
782fd950bd46 Revamp of the video system in 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 /* 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
201 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
202 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
203 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
204 for (i = 0; bootstrap[i]; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
205 if (SDL_strncmp(bootstrap[i]->name, driver_name,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
206 SDL_strlen(bootstrap[i]->name)) == 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
207 if (bootstrap[i]->available()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
208 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
209 }
782fd950bd46 Revamp of the video system in 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 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
211 }
782fd950bd46 Revamp of the video system in 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 } 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
214 for (i = 0; bootstrap[i]; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
215 if (bootstrap[i]->available()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
216 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
217 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
218 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
219 }
782fd950bd46 Revamp of the video system in 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 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
224 if (driver_name) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
225 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
226 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
227 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
228 }
782fd950bd46 Revamp of the video system in 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 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
230 }
782fd950bd46 Revamp of the video system in 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 _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
232 _this->name = bootstrap[i]->name;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
233 _this->next_object_id = 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
235
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
236 /* 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
237 _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
238 _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
239 _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
240 _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
241 _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
242 _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
243 _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
244 _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
245 _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
246 _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
247 _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
248 _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
249 _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
250 _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
251 _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
252 _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
253 _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
254 _this->gl_config.accelerated = -1; /* not known, don't set */
782fd950bd46 Revamp of the video system in 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.swap_control = -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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
270 /* Sort the video 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
271 for (i = 0; i < _this->num_displays; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
272 SDL_qsort(_this->displays[i].display_modes,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
273 _this->displays[i].num_display_modes,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
274 sizeof(SDL_DisplayMode), cmpmodes);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
275 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
276
782fd950bd46 Revamp of the video system in 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 /* Start the event loop */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
278 if (SDL_StartEventLoop(flags) < 0) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
279 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
280 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
281 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
282
782fd950bd46 Revamp of the video system in 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 /* 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
284 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
285 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286
1662
782fd950bd46 Revamp of the video system in 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 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
288 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
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 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
291 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
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->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
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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
296 SDL_VideoDevice *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
297 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
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 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
300 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
301
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
303 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
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 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
306
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
307 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
308 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
309 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
310 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
311 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
312
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
313 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
314 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
315
782fd950bd46 Revamp of the video system in 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 void
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
317 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
318 {
782fd950bd46 Revamp of the video system in 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 SDL_VideoDisplay *displays;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
321 displays =
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
322 SDL_realloc(_this->displays,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
323 (_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
324 if (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
325 displays[_this->num_displays] = *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
326 _this->displays = 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
327 _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
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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
331 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
332 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
333 {
782fd950bd46 Revamp of the video system in 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 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
335 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
336 }
782fd950bd46 Revamp of the video system in 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 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
338 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
340 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
341 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
342 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
343 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
344 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
345 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
346 }
782fd950bd46 Revamp of the video system in 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 >= 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
348 if (index >= _this->num_displays) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
349 SDL_SetError("index must be in the range 0 - %d",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
350 _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
351 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
352 }
782fd950bd46 Revamp of the video system in 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 _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
354 }
782fd950bd46 Revamp of the video system in 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 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
356 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
358 void
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
359 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
360 {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
361 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
362 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
363 int i, nmodes;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
365 /* 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
366 modes = display->display_modes;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
367 nmodes = 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
368 for (i = 0; i < nmodes; ++i) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
369 if (SDL_memcmp(mode, &modes[i], sizeof(*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
370 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
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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
374 /* Go ahead and add the new mode */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
375 modes = SDL_realloc(modes, (nmodes + 1) * sizeof(*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
376 if (modes) {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
377 display->display_modes = 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
378 modes[nmodes] = *mode;
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
379 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
380 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382
1662
782fd950bd46 Revamp of the video system in 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 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
384 SDL_GetNumDisplayModes()
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
386 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
387 return SDL_CurrentDisplay.num_display_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
388 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
389 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
390 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
391
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
392 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
393 SDL_GetDisplayMode(int index)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
394 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
395 if (index < 0 || index >= SDL_GetNumDisplayModes()) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
396 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
397 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
398 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
399 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
400 return &SDL_CurrentDisplay.display_modes[index];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
402
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
403 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
404 SDL_GetDesktopDisplayMode(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
405 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
406 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
407 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
408 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
409 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
410 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
411
1662
782fd950bd46 Revamp of the video system in 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 const SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
413 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
414 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
415 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
416 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
417 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
418 return NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
419 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
420
1662
782fd950bd46 Revamp of the video system in 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 SDL_DisplayMode *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
422 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
423 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
424 {
782fd950bd46 Revamp of the video system in 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 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
426 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
427 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
428 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
429
782fd950bd46 Revamp of the video system in 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 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
431 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
432 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
433
782fd950bd46 Revamp of the video system in 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 /* 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
435 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
436 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
437 } 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
438 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
439 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 /* 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
442 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
443 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
444 } 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
445 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
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
782fd950bd46 Revamp of the video system in 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 match = 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
449 for (i = 0; i < SDL_CurrentDisplay.num_display_modes; ++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
450 current = &SDL_CurrentDisplay.display_modes[i];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451
1662
782fd950bd46 Revamp of the video system in 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 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
453 (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
454 /* 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
455 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
456 }
782fd950bd46 Revamp of the video system in 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 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
458 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
459 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
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 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
462 /* 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
463 if (current->format == target_format ||
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
464 (SDL_BITSPERPIXEL(current->format) >=
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
465 SDL_BITSPERPIXEL(target_format)
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
466 && SDL_PIXELTYPE(current->format) ==
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
467 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
468 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
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 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
471 }
782fd950bd46 Revamp of the video system in 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 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
473 /* 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
474 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
475 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
476 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
477 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
478 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
479 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
480 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
481 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
482 } 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
483 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
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 (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
486 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
487 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
488 } 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
489 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
490 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
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->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
493 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
494 } 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
495 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
496 }
782fd950bd46 Revamp of the video system in 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 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
498 }
782fd950bd46 Revamp of the video system in 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 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
500 }
853
dddfc37e1f65 Don't allow video modes larger than the maximum size
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
501
1662
782fd950bd46 Revamp of the video system in 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 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
503 SDL_SetDisplayMode(const SDL_DisplayMode * mode)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
504 {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
505 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
506 SDL_DisplayMode display_mode;
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
507 int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
508
1662
782fd950bd46 Revamp of the video system in 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 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
510 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
511 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
512 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
513
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
514 /* Make sure there's an actual display mode to set */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
515 if (!mode) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
516 SDL_SetError("No mode passed to SDL_SetDisplayMode");
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
517 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
518 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
519 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
520 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
521
782fd950bd46 Revamp of the video system in 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 /* 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
523 if (!display_mode.format) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
524 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
525 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
526 if (!display_mode.w) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
527 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
528 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
529 if (!display_mode.h) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
530 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
531 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
532 if (!display_mode.refresh_rate) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
533 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
534 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
535
782fd950bd46 Revamp of the video system in 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 /* Get a good video mode, the closest one possible */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
537 if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
538 SDL_SetError("No video mode large enough for %dx%d",
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
539 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
540 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
541 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
542
782fd950bd46 Revamp of the video system in 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 /* 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
544 if (SDL_memcmp
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
545 (&display_mode, SDL_GetCurrentDisplayMode(),
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
546 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
547 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
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
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
550 return _this->SetDisplayMode(_this, &display_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
551 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
552
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
553 SDL_WindowID
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
554 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
555 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
556 const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
782fd950bd46 Revamp of the video system in 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 SDL_WINDOW_BORDERLESS |
782fd950bd46 Revamp of the video system in 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 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
559 SDL_WINDOW_OPENGL |
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
560 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
561 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
562 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
563 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
564 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
565 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
566 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
567
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
568 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
569 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
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
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
573 SDL_zero(window);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
574 window.id = _this->next_object_id++;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
575 window.title = title ? SDL_strdup(title) : 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
576 window.x = 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
577 window.y = 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
578 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
579 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
580 window.flags = (flags & allowed_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
581
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
582 if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
583 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
584 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
585 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
586 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
587 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
588
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
589 num_windows = SDL_CurrentDisplay.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
590 windows =
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
591 SDL_realloc(SDL_CurrentDisplay.windows,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
592 (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
593 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
594 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
595 _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
596 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
597 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
598 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
599 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
600 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
601 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
602 windows[num_windows] = 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
603 SDL_CurrentDisplay.windows = 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
604 SDL_CurrentDisplay.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
605
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
606 return window.id;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
607 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
608
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
609 SDL_WindowID
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
610 SDL_CreateWindowFrom(void *data)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
611 {
1662
782fd950bd46 Revamp of the video system in 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 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
613 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
614 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
615
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
616 if (!_this) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
617 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
618 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
619 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
620
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
621 SDL_zero(window);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
622 window.id = _this->next_object_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
623
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
624 if (!_this->CreateWindowFrom ||
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
625 _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
626 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
627 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
628
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
629 num_windows = SDL_CurrentDisplay.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
630 windows =
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
631 SDL_realloc(SDL_CurrentDisplay.windows,
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
632 (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
633 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
634 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
635 _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
636 }
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
637 if (window.title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
638 SDL_free(window.title);
1667
1fddae038bc8 Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents: 1666
diff changeset
639 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
640 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
641 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
642 windows[num_windows] = 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
643 SDL_CurrentDisplay.windows = 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
644 SDL_CurrentDisplay.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
645
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
646 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
647 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
648
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
649 static __inline__ SDL_Window *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
650 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
651 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
652 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
653
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
654 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
655 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
656 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
657
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
658 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
659 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
660 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
661 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
662 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
663 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
664 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
665 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
666 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
667 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
668 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
669
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
670 Uint32
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
671 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
672 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
673 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
674
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
675 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
676 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
677 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
678 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
679 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
680
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
681 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
682 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
683 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
684 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
685
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
686 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
687 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
688 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
689 if (window->title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
690 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
691 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
692 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
693
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
694 if (_this->SetWindowTitle) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
695 _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
696 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
697 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
698
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
699 const char *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
700 SDL_GetWindowTitle(SDL_WindowID windowID)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
701 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
702 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
703
782fd950bd46 Revamp of the video system in 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 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
705 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
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 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
708 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
710 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
711 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
712 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
713 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
714
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
715 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
716 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
717 }
782fd950bd46 Revamp of the video system in 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 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
719 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
720
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
721 void *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
722 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
723 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
724 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
725
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
726 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
727 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
728 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
729 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
730 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
733 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
734 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
735 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
736
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
737 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
738 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
739 }
782fd950bd46 Revamp of the video system in 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 window->x = 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
742 window->y = 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
743
782fd950bd46 Revamp of the video system in 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 if (_this->SetWindowPosition) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
745 _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
746 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
747 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
748
1662
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
750 SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
751 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
752 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
753
1662
782fd950bd46 Revamp of the video system in 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 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
755 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
756 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
757 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
758 *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
759 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
760 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
761 *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
762 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
763 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
764
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
765 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
766 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
767 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
768 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
769
782fd950bd46 Revamp of the video system in 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 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
771 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
772 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
773
782fd950bd46 Revamp of the video system in 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 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
775 window->h = h;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
776
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
777 if (_this->SetWindowSize) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
778 _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
779 }
782fd950bd46 Revamp of the video system in 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 }
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
783 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
784 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
785 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
786
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
787 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
788 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
789 }
782fd950bd46 Revamp of the video system in 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 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
791 *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
792 }
782fd950bd46 Revamp of the video system in 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 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
794 *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
795 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
796 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
797
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
799 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
800 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
801 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
802
782fd950bd46 Revamp of the video system in 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 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
804 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
805 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
806
782fd950bd46 Revamp of the video system in 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 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
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 if (_this->ShowWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
810 _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
811 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
812 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
813
1662
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
815 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
816 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
817 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
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 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
820 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
821 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 window->flags &= ~SDL_WINDOW_SHOWN;
910
4ab6d1fd028f Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 883
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 if (_this->HideWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
826 _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
827 }
782fd950bd46 Revamp of the video system in 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 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
831 SDL_RaiseWindow(SDL_WindowID windowID)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
832 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
833 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
834
782fd950bd46 Revamp of the video system in 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 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
836 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
837 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
838
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
839 if (_this->RaiseWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
840 _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
841 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
842 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
843
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
844 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
845 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
846 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
847 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
848
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
849 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
850 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
851 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 window->flags |= SDL_WINDOW_MAXIMIZED;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
854
1662
782fd950bd46 Revamp of the video system in 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 if (_this->MaximizeWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
856 _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
857 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
858 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
859
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
860 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
861 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
862 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
863 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
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 || (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
866 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
867 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
868
782fd950bd46 Revamp of the video system in 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 window->flags |= SDL_WINDOW_MINIMIZED;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
870
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
871 if (_this->MinimizeWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
872 _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
873 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
874 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
876 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
877 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
878 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
879 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
880
1662
782fd950bd46 Revamp of the video system in 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 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
882 || (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
883 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
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 window->flags &= ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
887
1662
782fd950bd46 Revamp of the video system in 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 if (_this->RestoreWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
889 _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
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 }
782fd950bd46 Revamp of the video system in 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
782fd950bd46 Revamp of the video system in 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 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
894 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
895 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
896 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
897
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
898 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
899 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
900 }
782fd950bd46 Revamp of the video system in 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 (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
903 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
904 } 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
905 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
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 if (_this->SetWindowGrab) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
909 _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
910 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
911 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
912
1662
782fd950bd46 Revamp of the video system in 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 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
914 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
915 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
916 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
917
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
918 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
919 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
920 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
921
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
922 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
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
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
925 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
926 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
927 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
928 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
929
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
930 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
931 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
932 }
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 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
935 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
936 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
937 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
938 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
939 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
940 }
782fd950bd46 Revamp of the video system in 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 if (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
942 window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
943 _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
944 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
945 if (window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
946 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
947 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
948 if (_this->DestroyWindow) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
949 _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
950 }
782fd950bd46 Revamp of the video system in 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 if (window->title) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
952 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
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 if (window->gamma) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
955 SDL_free(window->gamma);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
956 }
782fd950bd46 Revamp of the video system in 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 (j != display->num_windows - 1) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
958 SDL_memcpy(&display->windows[i],
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
959 &display->windows[i + 1],
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
960 (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
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 --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
963 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
964 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
965 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
966 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
967
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
968 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
969 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
970 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
971 SDL_VideoDisplay *display = &_this->displays[displayIndex];
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
972 SDL_RenderDriver *render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
973
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
974 render_drivers =
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
975 SDL_realloc(display->render_drivers,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
976 (display->num_render_drivers +
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
977 1) * sizeof(*render_drivers));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
978 if (render_drivers) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
979 render_drivers[display->num_render_drivers] = *driver;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
980 display->render_drivers = render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
981 display->num_render_drivers++;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
982 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
983 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
984
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
985 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
986 SDL_GetNumRenderers(void)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
987 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
988 if (_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
989 return SDL_CurrentDisplay.num_render_drivers;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
990 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
991 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
992 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
993
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
994 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
995 SDL_GetRendererInfo(int index, SDL_RendererInfo * info)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
996 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
997 if (index < 0 || index >= SDL_GetNumRenderers()) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
998 SDL_SetError("index must be in the range of 0 - %d",
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
999 SDL_GetNumRenderers() - 1);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1000 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1001 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1002 *info = SDL_CurrentDisplay.render_drivers[index].info;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1003 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1004 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1005
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1006 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1007 SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1008 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1009 SDL_Window *window = SDL_GetWindowFromID(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1010
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1011 if (!window) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1012 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1013 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1014
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1015 if (index < 0) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1016 int n = SDL_GetNumRenderers();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1017 for (index = 0; index < n; ++index) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1018 if ((SDL_CurrentDisplay.render_drivers[index].info.
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1019 flags & flags) == flags) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1020 break;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1021 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1022 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1023 if (index == n) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1024 SDL_SetError("Couldn't find matching render driver");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1025 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1026 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1027 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1028
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1029 if (index >= SDL_GetNumRenderers()) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1030 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
1031 SDL_GetNumRenderers() - 1);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1032 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1033 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1034
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1035 /* Free any existing renderer */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1036 SDL_DestroyRenderer(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1037
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1038 /* Create a new renderer instance */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1039 window->renderer =
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1040 SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1041 flags);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1042 if (!window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1043 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1044 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1045 SDL_CurrentDisplay.current_renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1046
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1047 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1048 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1049
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1050 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1051 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
1052 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1053 SDL_Window *window = SDL_GetWindowFromID(windowID);
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1054
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1055 if (!window || !window->renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1056 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1057 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1058 SDL_CurrentDisplay.current_renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1059 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1060 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1061
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1062 SDL_TextureID
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1063 SDL_CreateTexture(Uint32 format, int access, int w, int h)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1064 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1065 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1066 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1067
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1068 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1069 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1070 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1071
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1072 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1073 if (!renderer || !renderer->CreateTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1074 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1075 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1076
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1077 texture = (SDL_Texture *) SDL_malloc(sizeof(*texture));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1078 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1079 SDL_OutOfMemory();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1080 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1081 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1082
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1083 SDL_zerop(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1084 texture->id = _this->next_object_id++;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1085 texture->format = format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1086 texture->access = access;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1087 texture->w = w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1088 texture->h = h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1089 texture->renderer = renderer;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1090
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1091 if (renderer->CreateTexture(texture) < 0) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1092 SDL_free(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1093 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1094 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1095 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1096
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1097 SDL_TextureID
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1098 SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1099 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1100 SDL_TextureID textureID;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1101 Uint32 surface_flags = surface->flags;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1102 SDL_PixelFormat *fmt = surface->format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1103 Uint32 colorkey;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1104 Uint8 alpha;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1105 SDL_Rect bounds;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1106 SDL_Surface dst;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1107 int bpp;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1108 Uint32 Rmask, Gmask, Bmask, Amask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1109
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1110 if (!surface) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1111 SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1112 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1113 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1114
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1115 if (format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1116 if (!SDL_PixelFormatEnumToMasks
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1117 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1118 SDL_SetError("Unknown pixel format");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1119 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1120 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1121 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1122 bpp = fmt->BitsPerPixel;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1123 Rmask = fmt->Rmask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1124 Gmask = fmt->Gmask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1125 Bmask = fmt->Bmask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1126 Amask = fmt->Amask;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1127 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1128 if (!format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1129 SDL_SetError("Unknown pixel format");
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1130 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1131 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1132 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1133
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1134 textureID = SDL_CreateTexture(format, access, surface->w, surface->h);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1135 if (!textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1136 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
1137 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1138
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1139 /* Set up a destination surface for the texture update */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1140 SDL_zero(dst);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1141 dst.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1142 if (!dst.format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1143 SDL_DestroyTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1144 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1145 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1146 dst.w = surface->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1147 dst.h = surface->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1148 if (SDL_LockTexture(textureID, NULL, 1, &dst.pixels, &dst.pitch) == 0) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1149 dst.flags |= SDL_PREALLOC;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1150 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1151 dst.pitch = SDL_CalculatePitch(&dst);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1152 dst.pixels = SDL_malloc(dst.h * dst.pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1153 if (!dst.pixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1154 SDL_DestroyTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1155 SDL_FreeFormat(dst.format);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1156 SDL_OutOfMemory();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1157 return 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1158 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1159 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1160
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1161 /* Copy the palette if any */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1162 if (fmt->palette && dst.format->palette) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1163 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1164 fmt->palette->ncolors);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1165
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1166 SDL_memcpy(dst.format->palette->colors,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1167 fmt->palette->colors,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1168 fmt->palette->ncolors * sizeof(SDL_Color));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1169 dst.format->palette->ncolors = fmt->palette->ncolors;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1170 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1171
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1172 /* Make the texture transparent if the surface has colorkey */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1173 if (surface_flags & SDL_SRCCOLORKEY) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1174 int row;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1175 int length = dst.w * dst.format->BytesPerPixel;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1176 Uint8 *p = (Uint8 *) dst.pixels;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1177 for (row = 0; row < dst.h; ++row) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1178 SDL_memset(p, 0, length);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1179 p += dst.pitch;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1180 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1181 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1182
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1183 /* Copy over the alpha channel */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1184 if (surface_flags & SDL_SRCALPHA) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1185 if (fmt->Amask) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1186 surface->flags &= ~SDL_SRCALPHA;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1187 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1188 /* FIXME: Need to make sure the texture has an alpha channel
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1189 * and copy 'alpha' into the texture alpha channel.
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1190 */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1191 alpha = surface->format->alpha;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1192 SDL_SetAlpha(surface, 0, 0);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1193 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1194 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1195
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1196 /* Copy over the image data */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1197 bounds.x = 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1198 bounds.y = 0;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1199 bounds.w = surface->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1200 bounds.h = surface->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1201 SDL_LowerBlit(surface, &bounds, &dst, &bounds);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1202
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1203 /* Clean up the original surface */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1204 if ((surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1205 Uint32 cflags = surface_flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1206 SDL_SetColorKey(surface, cflags, colorkey);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1207 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1208 if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1209 Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1210 if (fmt->Amask) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1211 surface->flags |= SDL_SRCALPHA;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1212 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1213 SDL_SetAlpha(surface, aflags, alpha);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1214 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1215 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1216
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1217 /* Update the texture */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1218 if (dst.flags & SDL_PREALLOC) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1219 SDL_UnlockTexture(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1220 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1221 SDL_UpdateTexture(textureID, NULL, dst.pixels, dst.pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1222 SDL_free(dst.pixels);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1223 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1224 SDL_FreeFormat(dst.format);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1225
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1226 return textureID;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1227 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1228
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1229 static __inline__ SDL_Texture *
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1230 SDL_GetTextureFromID(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1231 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1232 int hash;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1233 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1234
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1235 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
1236 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
1237 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1238
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1239 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1240 for (texture = SDL_CurrentDisplay.textures[hash]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1241 texture = texture->next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1242 if (texture->id == textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1243 return texture;
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
1244 }
1662
782fd950bd46 Revamp of the video system in 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 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1246 return NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1247 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1248
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1249 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1250 SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1251 int *w, int *h)
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_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1254
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1255 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1256 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1257 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1258
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1259 if (format) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1260 *format = texture->format;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1261 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1262 if (access) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1263 *access = texture->access;
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 if (w) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1266 *w = texture->w;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1267 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1268 if (h) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1269 *h = texture->h;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1270 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1271 return 0;
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1274 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1275 SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect * rect,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1276 const void *pixels, int pitch)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1277 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1278 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1279 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1280
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1281 if (!texture) {
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1285 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1286 if (!renderer->UpdateTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1287 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1288 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1289 return renderer->UpdateTexture(texture, rect, pixels, pitch);
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1292 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1293 SDL_LockTexture(SDL_TextureID textureID, SDL_Rect * rect, int markDirty,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1294 void **pixels, int *pitch)
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 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1297 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1298
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1299 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1300 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1301 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1302
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1303 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1304 if (!renderer->LockTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1305 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1306 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1307 return renderer->LockTexture(texture, rect, markDirty, pixels, pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1308 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1309
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1310 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1311 SDL_UnlockTexture(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1312 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1313 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1314 SDL_Renderer *renderer;
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 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1317 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1318 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1319
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1320 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1321 if (!renderer->UnlockTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1322 return;
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 return renderer->UnlockTexture(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1325 }
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 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1328 SDL_DirtyTexture(SDL_TextureID textureID, int numrects, SDL_Rect * rects)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1329 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1330 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1331 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1332
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1333 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1334 return;
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1337 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1338 if (!renderer->DirtyTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1339 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1340 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1341 renderer->DirtyTexture(texture, numrects, rects);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1342 }
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 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1345 SDL_SelectRenderTexture(SDL_TextureID textureID)
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_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1348 SDL_Renderer *renderer;
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 if (!texture || texture->access != SDL_TextureAccess_Render) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1351 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1352 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1353 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1354 if (!renderer->SelectRenderTexture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1355 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1356 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1357 renderer->SelectRenderTexture(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1358 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1359
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1360 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1361 SDL_RenderFill(SDL_Rect * rect, Uint32 color)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1362 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1363 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1364
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1365 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1366 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1367 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1368
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1369 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1370 if (!renderer || !renderer->RenderFill) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1371 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
1372 }
910
4ab6d1fd028f Date: Sat, 26 Jun 2004 14:58:42 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 883
diff changeset
1373
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1374 renderer->RenderFill(rect, color);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1375 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1376
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1377 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1378 SDL_RenderCopy(SDL_TextureID textureID, SDL_Rect * srcrect,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1379 SDL_Rect * dstrect, int blendMode, int scaleMode)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1380 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1381 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1382 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1383
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1384 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1385 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1386 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1387
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1388 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1389 if (!renderer || !renderer->RenderCopy) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1390 return -1;
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 return renderer->RenderCopy(texture, srcrect, dstrect, blendMode,
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1394 scaleMode);
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1397 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1398 SDL_RenderReadPixels(SDL_Rect * rect, void *pixels, int pitch)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1399 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1400 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1401
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1402 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1403 return -1;
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1406 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1407 if (!renderer || !renderer->RenderReadPixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1408 return -1;
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1411 return renderer->RenderReadPixels(rect, pixels, pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1412 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1413
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1414 int
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1415 SDL_RenderWritePixels(SDL_Rect * rect, const void *pixels, int pitch)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1416 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1417 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1418
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1419 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1420 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1421 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1422
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1423 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1424 if (!renderer || !renderer->RenderWritePixels) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1425 return -1;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1426 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1427
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1428 return renderer->RenderWritePixels(rect, pixels, pitch);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1429 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1430
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1431 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1432 SDL_RenderPresent(void)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1433 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1434 SDL_Renderer *renderer;
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 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1437 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1438 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1439
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1440 renderer = SDL_CurrentDisplay.current_renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1441 if (!renderer || !renderer->RenderPresent) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1442 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1443 }
650
fe445b59d307 We need to lookup the address of glGetString before calling GL_MakeCurrent(),
Ryan C. Gordon <icculus@icculus.org>
parents: 630
diff changeset
1444
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1445 renderer->RenderPresent();
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1446 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1447
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1448 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1449 SDL_DestroyTexture(SDL_TextureID textureID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1450 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1451 int hash;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1452 SDL_Texture *prev, *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1453 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1454
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1455 if (!_this) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1456 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1457 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1458
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1459 /* Look up the texture in the hash table */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1460 hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1461 prev = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1462 for (texture = SDL_CurrentDisplay.textures[hash]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1463 prev = texture, texture = texture->next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1464 if (texture->id == textureID) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1465 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
1466 }
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1467 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1468 if (!texture) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1469 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1470 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1471
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1472 /* Unlink the texture from the list */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1473 if (prev) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1474 prev->next = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1475 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1476 SDL_CurrentDisplay.textures[hash] = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1477 }
1669
9857d21967bb The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents: 1668
diff changeset
1478
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1479 /* Free the texture */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1480 renderer = texture->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1481 renderer->DestroyTexture(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1482 SDL_free(texture);
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
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1485 void
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1486 SDL_DestroyRenderer(SDL_WindowID windowID)
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1487 {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1488 SDL_Window *window = SDL_GetWindowFromID(windowID);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1489 SDL_Renderer *renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1490 int i;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1491
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1492 if (!window) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1493 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1494 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1495
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1496 renderer = window->renderer;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1497 if (!renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1498 return;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1499 }
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1500
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1501 /* Free existing textures for this renderer */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1502 for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1503 SDL_Texture *texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1504 SDL_Texture *prev = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1505 SDL_Texture *next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1506 for (texture = SDL_CurrentDisplay.textures[i]; texture;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1507 texture = next) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1508 next = texture->next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1509 if (texture->renderer == renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1510 if (prev) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1511 prev->next = next;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1512 } else {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1513 SDL_CurrentDisplay.textures[i] = next;
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 renderer->DestroyTexture(texture);
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1516 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
1517 } else {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1518 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
1519 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1520 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1521 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1522
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1523 /* Free the renderer instance */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1524 renderer->DestroyRenderer(renderer);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1525
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1526 /* Clear references */
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1527 window->renderer = NULL;
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1528 if (SDL_CurrentDisplay.current_renderer == renderer) {
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1529 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
1530 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1531 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1532
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1533 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1534 SDL_VideoQuit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1535 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1536 int i, j;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1537
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1538 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
1539 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
1540 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1541
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1542 /* Halt event processing before doing anything else */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1543 SDL_StopEventLoop();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1544
1662
782fd950bd46 Revamp of the video system in 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 /* Clean up allocated window manager items */
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1546 SDL_CursorQuit();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1547
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1548 /* 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
1549 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
1550 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
1551 for (j = display->num_windows; j--;) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1552 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
1553 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1554 if (display->windows) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1555 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
1556 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
1557 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1558 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1559 _this->VideoQuit(_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
1560 if (_this->displays) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1561 SDL_free(_this->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
1562 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1563 _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
1564 _this = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1565 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1566
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1567 /* 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
1568 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1569 SDL_GL_LoadLibrary(const char *path)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1570 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1571 int retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1572
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1573 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
1574 if (_this == NULL) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1575 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
1576 } 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
1577 if (_this->GL_LoadLibrary) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1578 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
1579 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1580 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
1581 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1582 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1583 return (retval);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1584 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1585
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1586 void *
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1587 SDL_GL_GetProcAddress(const char *proc)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1588 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1589 void *func;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1590
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1591 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
1592 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
1593 if (_this->gl_config.driver_loaded) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1594 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
1595 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1596 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
1597 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1598 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1599 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
1600 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1601 return func;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1602 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1603
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1604 /* 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
1605 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1606 SDL_GL_SetAttribute(SDL_GLattr attr, int value)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1607 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1608 int retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1609
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1610 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
1611 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
1612 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
1613 _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
1614 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
1615 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
1616 _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
1617 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
1618 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
1619 _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
1620 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
1621 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
1622 _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
1623 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
1624 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
1625 _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
1626 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
1627 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
1628 _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
1629 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
1630 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
1631 _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
1632 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
1633 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
1634 _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
1635 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
1636 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
1637 _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
1638 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
1639 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
1640 _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
1641 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
1642 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
1643 _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
1644 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
1645 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
1646 _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
1647 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
1648 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
1649 _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
1650 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
1651 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
1652 _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
1653 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
1654 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
1655 _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
1656 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
1657 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
1658 _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
1659 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
1660 case SDL_GL_SWAP_CONTROL:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1661 _this->gl_config.swap_control = 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
1662 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
1663 default:
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1664 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
1665 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
1666 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
1667 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1668 return (retval);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1669 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1670
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1671 /* 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
1672 int
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1673 SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1674 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1675 int retval = -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1676
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1677 if (_this->GL_GetAttribute) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1678 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
1679 } 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
1680 *value = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1681 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
1682 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1683 return retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1684 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1685
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1686 /* 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
1687 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1688 SDL_GL_SwapBuffers(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1689 {
1670
eef792d31de8 Work in progress. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1669
diff changeset
1690 // 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
1691 _this->GL_SwapBuffers(_this);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1692 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1693
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1694 #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
1695 /* 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
1696 * 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
1697 static void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1698 CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1699 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1700 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
1701 Uint32 colorkey;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1702 #define SET_MASKBIT(icon, x, y, mask) \
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1703 mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8)))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1704
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1705 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
1706 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
1707 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
1708 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1709 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
1710 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
1711 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
1712 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
1713 if (*pixels++ == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1714 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
1715 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1716 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1717 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1718 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1719 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1720
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1721 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
1722 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1723 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
1724 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
1725 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
1726 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
1727 if ((flags & 1) && *pixels == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1728 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
1729 } 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
1730 && (*pixels & icon->format->Amask) == 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1731 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
1732 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1733 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
1734 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1735 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1736 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1737 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1738
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1739 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
1740 {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1741 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
1742 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
1743 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
1744 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
1745 if ((flags & 1) && *pixels == colorkey) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1746 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
1747 } 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
1748 && (*pixels & icon->format->Amask) == 0) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1749 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
1750 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1751 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
1752 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1753 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1754 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1755 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
1756 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1757 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1758
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1759 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1760 * Sets the window manager icon for the display window.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1761 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1762 void
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1763 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1764 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1765 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
1766 /* 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
1767 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
1768 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
1769 int flags = 0;
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1770 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
1771 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
1772 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
1773 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1774 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
1775 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
1776 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
1777 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
1778 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
1779 if (flags) {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1780 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
1781 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1782 _this->SetIcon(_this, icon, mask);
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1783 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
1784 } else {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1785 _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
1786 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1787 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1788 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1789 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1790
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1791 SDL_bool
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1792 SDL_GetWindowWMInfo(SDL_WindowID windowID, SDL_SysWMinfo * info)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1793 {
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1794 SDL_Window *window = SDL_GetWindowFromID(windowID);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1795
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1796 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
1797 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
1798 }
1668
4da1ee79c9af more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents: 1667
diff changeset
1799 return (_this->GetWindowWMInfo(_this, window, info));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1800 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1801
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1660
diff changeset
1802 /* vi: set ts=4 sw=4 expandtab: */