Mercurial > sdl-ios-xcode
annotate src/SDL_compat.c @ 1734:f7c667ded87d SDL-1.3
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Support for changing fullscreen/windowed mode in progress.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 09 Jul 2006 18:09:16 +0000 |
parents | 0b1070f2f94d |
children | 8dd28c4ef746 |
rev | line source |
---|---|
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* This file contains functions for backwards compatibility with SDL 1.2 */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL.h" |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
1691
diff
changeset
|
27 #include "SDL_syswm.h" |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
29 #include "video/SDL_sysvideo.h" |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
30 #include "video/SDL_pixels_c.h" |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
33 static SDL_WindowID SDL_VideoWindow; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
34 static SDL_TextureID SDL_VideoTexture; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
35 static SDL_Surface *SDL_VideoSurface; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
36 static SDL_Surface *SDL_ShadowSurface; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
37 static SDL_Surface *SDL_PublicSurface; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 static char *wm_title; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 char * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
41 SDL_AudioDriverName(char *namebuf, int maxlen) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
43 const char *name = SDL_GetCurrentAudioDriver(); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 if (name) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
45 SDL_strlcpy(namebuf, name, maxlen); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 return namebuf; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 char * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
52 SDL_VideoDriverName(char *namebuf, int maxlen) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
54 const char *name = SDL_GetCurrentVideoDriver(); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 if (name) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
56 SDL_strlcpy(namebuf, name, maxlen); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 return namebuf; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
1670 | 62 const SDL_VideoInfo * |
63 SDL_GetVideoInfo(void) | |
64 { | |
65 static SDL_VideoInfo info; | |
66 | |
67 /* Memory leak, compatibility code, who cares? */ | |
68 if (!info.vfmt && SDL_GetDesktopDisplayMode()) { | |
69 int bpp; | |
70 Uint32 Rmask, Gmask, Bmask, Amask; | |
71 | |
72 SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp, | |
73 &Rmask, &Gmask, &Bmask, &Amask); | |
74 info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); | |
75 } | |
76 return &info; | |
77 } | |
78 | |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
80 SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 int i, actual_bpp = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
84 if (!SDL_GetVideoDevice()) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 return 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 if (!(flags & SDL_FULLSCREEN)) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
89 return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()->format); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
92 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
93 const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 if (!mode->w || !mode->h || (width == mode->w && height == mode->h)) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 if (!mode->format) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 return bpp; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
98 if (SDL_BITSPERPIXEL(mode->format) >= (Uint32) bpp) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
99 actual_bpp = SDL_BITSPERPIXEL(mode->format); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 return actual_bpp; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 SDL_Rect ** |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
107 SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 int i, nmodes; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 SDL_Rect **modes; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
112 if (!SDL_GetVideoDevice()) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 if (!(flags & SDL_FULLSCREEN)) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 return (SDL_Rect **) (-1); |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 /* Memory leak, but this is a compatibility function, who cares? */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 nmodes = 0; |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
122 modes = NULL; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
123 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
124 const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 if (!mode->w || !mode->h) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 return (SDL_Rect **) (-1); |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
128 if (SDL_BITSPERPIXEL(mode->format) != format->BitsPerPixel) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 continue; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 if (nmodes > 0 && modes[nmodes - 1]->w == mode->w |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 && modes[nmodes - 1]->h == mode->h) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 continue; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
136 modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes)); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 if (!modes) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
140 modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 if (!modes[nmodes]) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 modes[nmodes]->x = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 modes[nmodes]->y = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 modes[nmodes]->w = mode->w; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 modes[nmodes]->h = mode->h; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 ++nmodes; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 if (modes) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 modes[nmodes] = NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 return modes; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
156 static int |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
157 SDL_CompatEventFilter(void *userdata, SDL_Event * event) |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
158 { |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
159 SDL_Event fake; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
160 |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
161 switch (event->type) { |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
162 case SDL_WINDOWEVENT: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
163 switch (event->window.event) { |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
164 case SDL_WINDOWEVENT_EXPOSED: |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
165 if (!SDL_HasEvent(SDL_VIDEOEXPOSEMASK)) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
166 fake.type = SDL_VIDEOEXPOSE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
167 SDL_PushEvent(&fake); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
168 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
169 break; |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
170 case SDL_WINDOWEVENT_RESIZED: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
171 fake.type = SDL_VIDEORESIZE; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
172 fake.resize.w = event->window.data1; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
173 fake.resize.h = event->window.data2; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
174 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
175 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
176 case SDL_WINDOWEVENT_MINIMIZED: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
177 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
178 fake.active.gain = 0; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
179 fake.active.state = SDL_APPACTIVE; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
180 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
181 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
182 case SDL_WINDOWEVENT_RESTORED: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
183 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
184 fake.active.gain = 1; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
185 fake.active.state = SDL_APPACTIVE; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
186 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
187 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
188 case SDL_WINDOWEVENT_ENTER: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
189 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
190 fake.active.gain = 1; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
191 fake.active.state = SDL_APPMOUSEFOCUS; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
192 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
193 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
194 case SDL_WINDOWEVENT_LEAVE: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
195 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
196 fake.active.gain = 0; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
197 fake.active.state = SDL_APPMOUSEFOCUS; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
198 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
199 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
200 case SDL_WINDOWEVENT_FOCUS_GAINED: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
201 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
202 fake.active.gain = 1; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
203 fake.active.state = SDL_APPINPUTFOCUS; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
204 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
205 break; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
206 case SDL_WINDOWEVENT_FOCUS_LOST: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
207 fake.type = SDL_ACTIVEEVENT; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
208 fake.active.gain = 1; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
209 fake.active.state = SDL_APPINPUTFOCUS; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
210 SDL_PushEvent(&fake); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
211 break; |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
212 case SDL_WINDOWEVENT_CLOSE: |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
213 fake.type = SDL_QUIT; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
214 SDL_PushEvent(&fake); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
215 break; |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
216 } |
1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
217 case SDL_KEYDOWN: |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
218 case SDL_KEYUP: |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
219 { |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
220 Uint32 unicode = 0; |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
221 if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) { |
1687
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
222 unicode = event->key.keysym.sym; |
1691
c901fd2a42da
I think this fixes bug #244
Sam Lantinga <slouken@libsdl.org>
parents:
1687
diff
changeset
|
223 if (unicode >= 'a' && unicode <= 'z') { |
1687
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
224 int shifted = !!(event->key.keysym.mod & KMOD_SHIFT); |
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
225 int capslock = !!(event->key.keysym.mod & KMOD_CAPS); |
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
226 if ((shifted ^ capslock) != 0) { |
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
227 unicode = SDL_toupper(unicode); |
d36048e8e302
This trick only works for English
Sam Lantinga <slouken@libsdl.org>
parents:
1686
diff
changeset
|
228 } |
1686
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
229 } |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
230 } |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
231 if (unicode) { |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
232 event->key.keysym.unicode = unicode; |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
233 } |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
234 break; |
8d7fecceb9ef
Added the unicode keysym memory again for backwards compatibility.
Sam Lantinga <slouken@libsdl.org>
parents:
1685
diff
changeset
|
235 } |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
236 case SDL_MOUSEWHEEL: |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
237 { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
238 Uint8 button; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
239 int selected; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
240 int x, y; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
241 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
242 selected = SDL_SelectMouse(event->wheel.which); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
243 SDL_GetMouseState(&x, &y); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
244 SDL_SelectMouse(selected); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
245 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
246 if (event->wheel.motion > 0) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
247 button = SDL_BUTTON_WHEELUP; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
248 } else { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
249 button = SDL_BUTTON_WHEELDOWN; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
250 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
251 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
252 fake.button.which = event->wheel.windowID; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
253 fake.button.button = button; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
254 fake.button.x = x; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
255 fake.button.y = y; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
256 fake.button.windowID = event->wheel.windowID; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
257 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
258 fake.type = SDL_MOUSEBUTTONDOWN; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
259 fake.button.state = SDL_PRESSED; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
260 SDL_PushEvent(&fake); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
261 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
262 fake.type = SDL_MOUSEBUTTONUP; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
263 fake.button.state = SDL_RELEASED; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
264 SDL_PushEvent(&fake); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
265 break; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
266 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
267 |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
268 } |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
269 return 1; |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
270 } |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
271 |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
272 static int |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
273 SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette) |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
274 { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
275 if (userdata == SDL_ShadowSurface) { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
276 /* If the shadow palette changed, make the changes visible */ |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
277 if (!SDL_VideoSurface->format->palette) { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
278 SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
279 } |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
280 } |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
281 if (userdata == SDL_VideoSurface) { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
282 return SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
283 } |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
284 return 0; |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
285 } |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
286 |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
287 static void |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
288 GetEnvironmentWindowPosition(int w, int h, int *x, int *y) |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
289 { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
290 const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
291 const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
292 if (window) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
293 if (SDL_sscanf(window, "%d,%d", x, y) == 2) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
294 return; |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
295 } |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
296 if (SDL_strcmp(window, "center") == 0) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
297 center = window; |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
298 } |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
299 } |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
300 if (center) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
301 const SDL_DisplayMode *current = SDL_GetDesktopDisplayMode(); |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
302 *x = (current->w - w) / 2; |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
303 *y = (current->h - h) / 2; |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
304 } |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
305 } |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
306 |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 SDL_Surface * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
308 SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 { |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
310 SDL_EventFilter filter; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
311 void *filterparam; |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
312 const SDL_DisplayMode *desktop_mode; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 SDL_DisplayMode mode; |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
314 int window_x = SDL_WINDOWPOS_UNDEFINED; |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
315 int window_y = SDL_WINDOWPOS_UNDEFINED; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 Uint32 window_flags; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 Uint32 desktop_format; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 Uint32 desired_format; |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
319 Uint32 surface_flags; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
321 if (!SDL_GetVideoDevice()) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
322 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 /* Destroy existing window */ |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
328 SDL_PublicSurface = NULL; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
329 if (SDL_ShadowSurface) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
330 SDL_FreeSurface(SDL_ShadowSurface); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
331 SDL_ShadowSurface = NULL; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
332 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
333 if (SDL_VideoSurface) { |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
334 SDL_DelPaletteWatch(SDL_VideoSurface->format->palette, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
335 SDL_VideoPaletteChanged, NULL); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
336 SDL_FreeSurface(SDL_VideoSurface); |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
337 SDL_VideoSurface = NULL; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
338 } |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
339 if (SDL_VideoWindow) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
340 SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y); |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
341 } |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
342 SDL_DestroyWindow(SDL_VideoWindow); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
344 /* Set up the event filter */ |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
345 if (!SDL_GetEventFilter(NULL, NULL)) { |
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
346 SDL_SetEventFilter(SDL_CompatEventFilter, NULL); |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
347 } |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
348 |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 /* Create a new window */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 window_flags = SDL_WINDOW_SHOWN; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 if (flags & SDL_FULLSCREEN) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 window_flags |= SDL_WINDOW_FULLSCREEN; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 if (flags & SDL_OPENGL) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 window_flags |= SDL_WINDOW_OPENGL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 if (flags & SDL_RESIZABLE) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 window_flags |= SDL_WINDOW_RESIZABLE; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 if (flags & SDL_NOFRAME) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 window_flags |= SDL_WINDOW_BORDERLESS; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 } |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
363 GetEnvironmentWindowPosition(width, height, &window_x, &window_y); |
1733
0b1070f2f94d
Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
1731
diff
changeset
|
364 SDL_SetFullscreenDisplayMode(NULL); |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
365 SDL_VideoWindow = |
1731
875c3cf1a12c
SDL_PushEvent() calls the event filter code, and has a return value to tell
Sam Lantinga <slouken@libsdl.org>
parents:
1724
diff
changeset
|
366 SDL_CreateWindow(wm_title, window_x, window_y, width, height, |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
367 window_flags); |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
368 if (!SDL_VideoWindow) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
372 window_flags = SDL_GetWindowFlags(SDL_VideoWindow); |
1716
6ab5e712e642
The screen/shadow surface flags are no longer needed
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
373 surface_flags = 0; |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
374 if (window_flags & SDL_WINDOW_FULLSCREEN) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
375 surface_flags |= SDL_FULLSCREEN; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
376 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
377 if (window_flags & SDL_WINDOW_OPENGL) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
378 surface_flags |= SDL_OPENGL; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
379 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
380 if (window_flags & SDL_WINDOW_RESIZABLE) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
381 surface_flags |= SDL_RESIZABLE; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
382 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
383 if (window_flags & SDL_WINDOW_BORDERLESS) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
384 surface_flags |= SDL_NOFRAME; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
385 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
386 |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 /* Set up the desired display mode */ |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
388 desktop_mode = SDL_GetDesktopDisplayMode(); |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
389 desktop_format = desktop_mode->format; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
390 if (desktop_format && ((flags & SDL_ANYFORMAT) |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
391 || (bpp == SDL_BITSPERPIXEL(desktop_format)))) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 desired_format = desktop_format; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } else { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 switch (bpp) { |
1669
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
395 case 0: |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
396 if (desktop_format) { |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
397 desired_format = desktop_format; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
398 } else { |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
399 desired_format = SDL_PixelFormat_RGB888; |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
400 } |
9857d21967bb
The test programs compile again.
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
401 break; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 case 8: |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 desired_format = SDL_PixelFormat_Index8; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 break; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 case 15: |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 desired_format = SDL_PixelFormat_RGB555; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 break; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 case 16: |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 desired_format = SDL_PixelFormat_RGB565; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 break; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 case 24: |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 desired_format = SDL_PixelFormat_RGB24; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 break; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 case 32: |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 desired_format = SDL_PixelFormat_RGB888; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 break; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 default: |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
418 SDL_SetError("Unsupported bpp in SDL_SetVideoMode()"); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 mode.format = desired_format; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 mode.w = width; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 mode.h = height; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 mode.refresh_rate = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 /* Set the desired display mode */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 if (flags & SDL_FULLSCREEN) { |
1733
0b1070f2f94d
Implemented gamma correction on Windows.
Sam Lantinga <slouken@libsdl.org>
parents:
1731
diff
changeset
|
429 if (SDL_SetFullscreenDisplayMode(&mode) < 0) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 return NULL; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
434 /* If we're in OpenGL mode, just create a stub surface and we're done! */ |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
435 if (flags & SDL_OPENGL) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
436 SDL_VideoSurface = |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
437 SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0); |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
438 if (!SDL_VideoSurface) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
439 return NULL; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
440 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
441 SDL_VideoSurface->flags |= surface_flags; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
442 SDL_PublicSurface = SDL_VideoSurface; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
443 return SDL_PublicSurface; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
444 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
445 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
446 /* Create a renderer for the window */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
447 if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) { |
1670 | 448 return NULL; |
449 } | |
450 | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
451 /* Create a texture for the screen surface */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
452 SDL_VideoTexture = |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
453 SDL_CreateTexture(desired_format, SDL_TextureAccess_Local, width, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
454 height); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
455 if (!SDL_VideoTexture) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
456 SDL_VideoTexture = |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
457 SDL_CreateTexture(0, SDL_TextureAccess_Local, width, height); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
458 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
459 if (!SDL_VideoTexture) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
460 return NULL; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
461 } |
1670 | 462 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
463 /* Create the screen surface */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
464 SDL_VideoSurface = SDL_CreateRGBSurfaceFromTexture(SDL_VideoTexture); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
465 if (!SDL_VideoSurface) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
466 return NULL; |
1670 | 467 } |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
468 SDL_VideoSurface->flags |= surface_flags; |
1670 | 469 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
470 /* Set a default screen palette */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
471 if (SDL_VideoSurface->format->palette) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
472 SDL_VideoSurface->flags |= SDL_HWPALETTE; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
473 SDL_DitherColors(SDL_VideoSurface->format->palette->colors, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
474 SDL_VideoSurface->format->BitsPerPixel); |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
475 SDL_AddPaletteWatch(SDL_VideoSurface->format->palette, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
476 SDL_VideoPaletteChanged, NULL); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
477 SDL_SetPaletteColors(SDL_VideoSurface->format->palette, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
478 SDL_VideoSurface->format->palette->colors, 0, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
479 SDL_VideoSurface->format->palette->ncolors); |
1670 | 480 } |
481 | |
482 /* Create a shadow surface if necessary */ | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
483 if (((bpp != SDL_VideoSurface->format->BitsPerPixel) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
484 && !(flags & SDL_ANYFORMAT)) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
485 || ((SDL_VideoSurface->flags & SDL_HWSURFACE) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
486 && !(flags & SDL_HWSURFACE))) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
487 if ((bpp == SDL_VideoSurface->format->BitsPerPixel) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
488 || (flags & SDL_ANYFORMAT)) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
489 SDL_ShadowSurface = |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
490 SDL_CreateRGBSurface(0, width, height, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
491 SDL_VideoSurface->format->BitsPerPixel, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
492 SDL_VideoSurface->format->Rmask, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
493 SDL_VideoSurface->format->Gmask, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
494 SDL_VideoSurface->format->Bmask, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
495 SDL_VideoSurface->format->Amask); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
496 } else { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
497 SDL_ShadowSurface = |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
498 SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
499 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
500 if (!SDL_ShadowSurface) { |
1670 | 501 return NULL; |
502 } | |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
503 SDL_ShadowSurface->flags |= surface_flags; |
1670 | 504 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
505 /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
506 if (SDL_ShadowSurface->format->palette) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
507 SDL_ShadowSurface->flags |= SDL_HWPALETTE; |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
508 if (SDL_VideoSurface->format->palette) { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
509 SDL_SetSurfacePalette(SDL_ShadowSurface, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
510 SDL_VideoSurface->format->palette); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
511 } else { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
512 SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
513 SDL_ShadowSurface->format->BitsPerPixel); |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
514 } |
1670 | 515 } |
516 } | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
517 SDL_PublicSurface = |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
518 (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface); |
1670 | 519 |
520 /* Clear the surface for display */ | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
521 SDL_FillRect(SDL_PublicSurface, NULL, 0); |
1670 | 522 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
523 /* We're finally done! */ |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
524 return SDL_PublicSurface; |
1670 | 525 } |
526 | |
527 SDL_Surface * | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
528 SDL_GetVideoSurface(void) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 { |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
530 return SDL_PublicSurface; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 |
1670 | 533 SDL_Surface * |
534 SDL_DisplayFormat(SDL_Surface * surface) | |
535 { | |
536 Uint32 flags; | |
537 | |
538 if (!SDL_PublicSurface) { | |
539 SDL_SetError("No video mode has been set"); | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
540 return NULL; |
1670 | 541 } |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
542 |
1670 | 543 /* Set the flags appropriate for copying to display surface */ |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
544 flags = SDL_SWSURFACE; |
1670 | 545 #ifdef AUTORLE_DISPLAYFORMAT |
546 flags |= (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA)); | |
547 flags |= SDL_RLEACCELOK; | |
548 #else | |
549 flags |= | |
550 surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK); | |
551 #endif | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
552 return SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags); |
1670 | 553 } |
554 | |
555 SDL_Surface * | |
556 SDL_DisplayFormatAlpha(SDL_Surface * surface) | |
557 { | |
558 SDL_PixelFormat *vf; | |
559 SDL_PixelFormat *format; | |
560 SDL_Surface *converted; | |
561 Uint32 flags; | |
562 /* default to ARGB8888 */ | |
563 Uint32 amask = 0xff000000; | |
564 Uint32 rmask = 0x00ff0000; | |
565 Uint32 gmask = 0x0000ff00; | |
566 Uint32 bmask = 0x000000ff; | |
567 | |
568 if (!SDL_PublicSurface) { | |
569 SDL_SetError("No video mode has been set"); | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
570 return NULL; |
1670 | 571 } |
572 vf = SDL_PublicSurface->format; | |
573 | |
574 switch (vf->BytesPerPixel) { | |
575 case 2: | |
576 /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. | |
577 For anything else (like ARGB4444) it doesn't matter | |
578 since we have no special code for it anyway */ | |
579 if ((vf->Rmask == 0x1f) && | |
580 (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) { | |
581 rmask = 0xff; | |
582 bmask = 0xff0000; | |
583 } | |
584 break; | |
585 | |
586 case 3: | |
587 case 4: | |
588 /* Keep the video format, as long as the high 8 bits are | |
589 unused or alpha */ | |
590 if ((vf->Rmask == 0xff) && (vf->Bmask == 0xff0000)) { | |
591 rmask = 0xff; | |
592 bmask = 0xff0000; | |
593 } | |
594 break; | |
595 | |
596 default: | |
597 /* We have no other optimised formats right now. When/if a new | |
598 optimised alpha format is written, add the converter here */ | |
599 break; | |
600 } | |
601 format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); | |
602 flags = SDL_PublicSurface->flags & SDL_HWSURFACE; | |
603 flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); | |
604 converted = SDL_ConvertSurface(surface, format, flags); | |
605 SDL_FreeFormat(format); | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
606 return converted; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
607 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
608 |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
609 int |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
610 SDL_Flip(SDL_Surface * screen) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
611 { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
612 SDL_UpdateRect(screen, 0, 0, 0, 0); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
613 return 0; |
1670 | 614 } |
615 | |
616 void | |
617 SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) | |
618 { | |
619 if (screen) { | |
620 SDL_Rect rect; | |
621 | |
622 /* Perform some checking */ | |
623 if (w == 0) | |
624 w = screen->w; | |
625 if (h == 0) | |
626 h = screen->h; | |
627 if ((int) (x + w) > screen->w) | |
628 return; | |
629 if ((int) (y + h) > screen->h) | |
630 return; | |
631 | |
632 /* Fill the rectangle */ | |
633 rect.x = (Sint16) x; | |
634 rect.y = (Sint16) y; | |
635 rect.w = (Uint16) w; | |
636 rect.h = (Uint16) h; | |
637 SDL_UpdateRects(screen, 1, &rect); | |
638 } | |
639 } | |
640 void | |
641 SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects) | |
642 { | |
643 int i; | |
644 | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
645 if (screen == SDL_ShadowSurface) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
646 for (i = 0; i < numrects; ++i) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
647 SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
648 &rects[i]); |
1670 | 649 } |
650 | |
651 /* Fall through to video surface update */ | |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
652 screen = SDL_VideoSurface; |
1670 | 653 } |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
654 if (screen == SDL_VideoSurface) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
655 for (i = 0; i < numrects; ++i) { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
656 SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i], |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
657 SDL_TextureBlendMode_None, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
658 SDL_TextureScaleMode_None); |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
659 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
660 SDL_RenderPresent(); |
1670 | 661 } |
662 } | |
663 | |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
665 SDL_WM_SetCaption(const char *title, const char *icon) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 if (wm_title) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
668 SDL_free(wm_title); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 } else { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
670 wm_title = SDL_strdup(title); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 } |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
672 SDL_SetWindowTitle(SDL_VideoWindow, wm_title); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
676 SDL_WM_GetCaption(char **title, char **icon) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 if (title) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 *title = wm_title; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 if (icon) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 *icon = ""; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
687 SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 /* FIXME */ |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
693 SDL_WM_IconifyWindow(void) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 { |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
695 SDL_MinimizeWindow(SDL_VideoWindow); |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
696 return 0; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
700 SDL_WM_ToggleFullScreen(SDL_Surface * surface) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 { |
1734
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
702 if (SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN) { |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
703 if (SDL_SetWindowFullscreen(SDL_VideoWindow, 0) < 0) { |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
704 return 0; |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
705 } |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
706 SDL_PublicSurface->flags &= ~SDL_FULLSCREEN; |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
707 } else { |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
708 if (SDL_SetWindowFullscreen(SDL_VideoWindow, 1) < 0) { |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
709 return 0; |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
710 } |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
711 SDL_PublicSurface->flags |= SDL_FULLSCREEN; |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
712 } |
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
713 return 1; |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 SDL_GrabMode |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
717 SDL_WM_GrabInput(SDL_GrabMode mode) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 if (mode != SDL_GRAB_QUERY) { |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
720 SDL_SetWindowGrab(SDL_VideoWindow, mode); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
721 } |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
722 return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
723 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
725 void |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
726 SDL_WarpMouse(Uint16 x, Uint16 y) |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
727 { |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
728 SDL_WarpMouseInWindow(SDL_VideoWindow, x, y); |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
729 } |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
730 |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 Uint8 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
732 SDL_GetAppState(void) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 Uint8 state = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 Uint32 flags = 0; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
737 flags = SDL_GetWindowFlags(SDL_VideoWindow); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 state |= SDL_APPACTIVE; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 } |
1734
f7c667ded87d
The general code handles restoring video mode/gamma/etc. when the window loses focus.
Sam Lantinga <slouken@libsdl.org>
parents:
1733
diff
changeset
|
741 if (flags & SDL_WINDOW_INPUT_FOCUS) { |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 state |= SDL_APPINPUTFOCUS; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 if (flags & SDL_WINDOW_MOUSE_FOCUS) { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 state |= SDL_APPMOUSEFOCUS; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 return state; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 const SDL_version * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
751 SDL_Linked_Version(void) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
752 { |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 static SDL_version version; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
754 SDL_VERSION(&version); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
755 return &version; |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
757 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
758 int |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1681
diff
changeset
|
759 SDL_SetPalette(SDL_Surface * surface, int flags, const SDL_Color * colors, |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
760 int firstcolor, int ncolors) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
761 { |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
762 return SDL_SetColors(surface, colors, firstcolor, ncolors); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
763 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
764 |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
765 int |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
766 SDL_SetColors(SDL_Surface * surface, const SDL_Color * colors, int firstcolor, |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
767 int ncolors) |
1670 | 768 { |
1683
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
769 if (SDL_SetPaletteColors |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
770 (surface->format->palette, colors, firstcolor, ncolors) == 0) { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
771 return 1; |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
772 } else { |
396a35389351
Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents:
1682
diff
changeset
|
773 return 0; |
1670 | 774 } |
775 } | |
776 | |
777 int | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1667
diff
changeset
|
778 SDL_GetWMInfo(SDL_SysWMinfo * info) |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 { |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
780 return SDL_GetWindowWMInfo(SDL_VideoWindow, info); |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 } |
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1675
diff
changeset
|
783 #if 0 |
1670 | 784 void |
785 SDL_MoveCursor(int x, int y) | |
786 { | |
787 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
788 | |
789 /* Erase and update the current mouse position */ | |
790 if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { | |
791 /* Erase and redraw mouse cursor in new position */ | |
792 SDL_LockCursor(); | |
793 SDL_EraseCursor(SDL_VideoSurface); | |
794 SDL_cursor->area.x = (x - SDL_cursor->hot_x); | |
795 SDL_cursor->area.y = (y - SDL_cursor->hot_y); | |
796 SDL_DrawCursor(SDL_VideoSurface); | |
797 SDL_UnlockCursor(); | |
798 } else if (_this->MoveWMCursor) { | |
799 _this->MoveWMCursor(_this, x, y); | |
800 } | |
801 } | |
802 | |
803 /* Keep track of the current cursor colors */ | |
804 static int palette_changed = 1; | |
805 static Uint8 pixels8[2]; | |
806 | |
807 void | |
808 SDL_CursorPaletteChanged(void) | |
809 { | |
810 palette_changed = 1; | |
811 } | |
812 | |
813 void | |
814 SDL_MouseRect(SDL_Rect * area) | |
815 { | |
816 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
817 int clip_diff; | |
818 | |
819 *area = SDL_cursor->area; | |
820 if (area->x < 0) { | |
821 area->w += area->x; | |
822 area->x = 0; | |
823 } | |
824 if (area->y < 0) { | |
825 area->h += area->y; | |
826 area->y = 0; | |
827 } | |
828 clip_diff = (area->x + area->w) - SDL_VideoSurface->w; | |
829 if (clip_diff > 0) { | |
830 area->w = area->w < clip_diff ? 0 : area->w - clip_diff; | |
831 } | |
832 clip_diff = (area->y + area->h) - SDL_VideoSurface->h; | |
833 if (clip_diff > 0) { | |
834 area->h = area->h < clip_diff ? 0 : area->h - clip_diff; | |
835 } | |
836 } | |
837 | |
838 static void | |
839 SDL_DrawCursorFast(SDL_Surface * screen, SDL_Rect * area) | |
840 { | |
841 const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 }; | |
842 int i, w, h; | |
843 Uint8 *data, datab; | |
844 Uint8 *mask, maskb; | |
845 | |
846 data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8; | |
847 mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8; | |
848 switch (screen->format->BytesPerPixel) { | |
849 | |
850 case 1: | |
851 { | |
852 Uint8 *dst; | |
853 int dstskip; | |
854 | |
855 if (palette_changed) { | |
856 pixels8[0] = | |
857 (Uint8) SDL_MapRGB(screen->format, 255, 255, 255); | |
858 pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0); | |
859 palette_changed = 0; | |
860 } | |
861 dst = (Uint8 *) screen->pixels + | |
862 (SDL_cursor->area.y + area->y) * screen->pitch + | |
863 SDL_cursor->area.x; | |
864 dstskip = screen->pitch - area->w; | |
865 | |
866 for (h = area->h; h; h--) { | |
867 for (w = area->w / 8; w; w--) { | |
868 maskb = *mask++; | |
869 datab = *data++; | |
870 for (i = 0; i < 8; ++i) { | |
871 if (maskb & 0x80) { | |
872 *dst = pixels8[datab >> 7]; | |
873 } | |
874 maskb <<= 1; | |
875 datab <<= 1; | |
876 dst++; | |
877 } | |
878 } | |
879 dst += dstskip; | |
880 } | |
881 } | |
882 break; | |
883 | |
884 case 2: | |
885 { | |
886 Uint16 *dst; | |
887 int dstskip; | |
888 | |
889 dst = (Uint16 *) screen->pixels + | |
890 (SDL_cursor->area.y + area->y) * screen->pitch / 2 + | |
891 SDL_cursor->area.x; | |
892 dstskip = (screen->pitch / 2) - area->w; | |
893 | |
894 for (h = area->h; h; h--) { | |
895 for (w = area->w / 8; w; w--) { | |
896 maskb = *mask++; | |
897 datab = *data++; | |
898 for (i = 0; i < 8; ++i) { | |
899 if (maskb & 0x80) { | |
900 *dst = (Uint16) pixels[datab >> 7]; | |
901 } | |
902 maskb <<= 1; | |
903 datab <<= 1; | |
904 dst++; | |
905 } | |
906 } | |
907 dst += dstskip; | |
908 } | |
909 } | |
910 break; | |
911 | |
912 case 3: | |
913 { | |
914 Uint8 *dst; | |
915 int dstskip; | |
916 | |
917 dst = (Uint8 *) screen->pixels + | |
918 (SDL_cursor->area.y + area->y) * screen->pitch + | |
919 SDL_cursor->area.x * 3; | |
920 dstskip = screen->pitch - area->w * 3; | |
921 | |
922 for (h = area->h; h; h--) { | |
923 for (w = area->w / 8; w; w--) { | |
924 maskb = *mask++; | |
925 datab = *data++; | |
926 for (i = 0; i < 8; ++i) { | |
927 if (maskb & 0x80) { | |
928 SDL_memset(dst, pixels[datab >> 7], 3); | |
929 } | |
930 maskb <<= 1; | |
931 datab <<= 1; | |
932 dst += 3; | |
933 } | |
934 } | |
935 dst += dstskip; | |
936 } | |
937 } | |
938 break; | |
939 | |
940 case 4: | |
941 { | |
942 Uint32 *dst; | |
943 int dstskip; | |
944 | |
945 dst = (Uint32 *) screen->pixels + | |
946 (SDL_cursor->area.y + area->y) * screen->pitch / 4 + | |
947 SDL_cursor->area.x; | |
948 dstskip = (screen->pitch / 4) - area->w; | |
949 | |
950 for (h = area->h; h; h--) { | |
951 for (w = area->w / 8; w; w--) { | |
952 maskb = *mask++; | |
953 datab = *data++; | |
954 for (i = 0; i < 8; ++i) { | |
955 if (maskb & 0x80) { | |
956 *dst = pixels[datab >> 7]; | |
957 } | |
958 maskb <<= 1; | |
959 datab <<= 1; | |
960 dst++; | |
961 } | |
962 } | |
963 dst += dstskip; | |
964 } | |
965 } | |
966 break; | |
967 } | |
968 } | |
969 | |
970 static void | |
971 SDL_DrawCursorSlow(SDL_Surface * screen, SDL_Rect * area) | |
972 { | |
973 const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 }; | |
974 int h; | |
975 int x, minx, maxx; | |
976 Uint8 *data, datab = 0; | |
977 Uint8 *mask, maskb = 0; | |
978 Uint8 *dst; | |
979 int dstbpp, dstskip; | |
980 | |
981 data = SDL_cursor->data + area->y * SDL_cursor->area.w / 8; | |
982 mask = SDL_cursor->mask + area->y * SDL_cursor->area.w / 8; | |
983 dstbpp = screen->format->BytesPerPixel; | |
984 dst = (Uint8 *) screen->pixels + | |
985 (SDL_cursor->area.y + area->y) * screen->pitch + | |
986 SDL_cursor->area.x * dstbpp; | |
987 dstskip = screen->pitch - SDL_cursor->area.w * dstbpp; | |
988 | |
989 minx = area->x; | |
990 maxx = area->x + area->w; | |
991 if (screen->format->BytesPerPixel == 1) { | |
992 if (palette_changed) { | |
993 pixels8[0] = (Uint8) SDL_MapRGB(screen->format, 255, 255, 255); | |
994 pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0); | |
995 palette_changed = 0; | |
996 } | |
997 for (h = area->h; h; h--) { | |
998 for (x = 0; x < SDL_cursor->area.w; ++x) { | |
999 if ((x % 8) == 0) { | |
1000 maskb = *mask++; | |
1001 datab = *data++; | |
1002 } | |
1003 if ((x >= minx) && (x < maxx)) { | |
1004 if (maskb & 0x80) { | |
1005 SDL_memset(dst, pixels8[datab >> 7], dstbpp); | |
1006 } | |
1007 } | |
1008 maskb <<= 1; | |
1009 datab <<= 1; | |
1010 dst += dstbpp; | |
1011 } | |
1012 dst += dstskip; | |
1013 } | |
1014 } else { | |
1015 for (h = area->h; h; h--) { | |
1016 for (x = 0; x < SDL_cursor->area.w; ++x) { | |
1017 if ((x % 8) == 0) { | |
1018 maskb = *mask++; | |
1019 datab = *data++; | |
1020 } | |
1021 if ((x >= minx) && (x < maxx)) { | |
1022 if (maskb & 0x80) { | |
1023 SDL_memset(dst, pixels[datab >> 7], dstbpp); | |
1024 } | |
1025 } | |
1026 maskb <<= 1; | |
1027 datab <<= 1; | |
1028 dst += dstbpp; | |
1029 } | |
1030 dst += dstskip; | |
1031 } | |
1032 } | |
1033 } | |
1034 | |
1035 /* This handles the ugly work of converting the saved cursor background from | |
1036 the pixel format of the shadow surface to that of the video surface. | |
1037 This is only necessary when blitting from a shadow surface of a different | |
1038 pixel format than the video surface, and using a software rendered cursor. | |
1039 */ | |
1040 static void | |
1041 SDL_ConvertCursorSave(SDL_Surface * screen, int w, int h) | |
1042 { | |
1043 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
1044 SDL_BlitInfo info; | |
1045 SDL_loblit RunBlit; | |
1046 | |
1047 /* Make sure we can steal the blit mapping */ | |
1048 if (screen->map->dst != SDL_VideoSurface) { | |
1049 return; | |
1050 } | |
1051 | |
1052 /* Set up the blit information */ | |
1053 info.s_pixels = SDL_cursor->save[1]; | |
1054 info.s_width = w; | |
1055 info.s_height = h; | |
1056 info.s_skip = 0; | |
1057 info.d_pixels = SDL_cursor->save[0]; | |
1058 info.d_width = w; | |
1059 info.d_height = h; | |
1060 info.d_skip = 0; | |
1061 info.aux_data = screen->map->sw_data->aux_data; | |
1062 info.src = screen->format; | |
1063 info.table = screen->map->table; | |
1064 info.dst = SDL_VideoSurface->format; | |
1065 RunBlit = screen->map->sw_data->blit; | |
1066 | |
1067 /* Run the actual software blit */ | |
1068 RunBlit(&info); | |
1069 } | |
1070 | |
1071 void | |
1072 SDL_DrawCursorNoLock(SDL_Surface * screen) | |
1073 { | |
1074 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
1075 SDL_Rect area; | |
1076 | |
1077 /* Get the mouse rectangle, clipped to the screen */ | |
1078 SDL_MouseRect(&area); | |
1079 if ((area.w == 0) || (area.h == 0)) { | |
1080 return; | |
1081 } | |
1082 | |
1083 /* Copy mouse background */ | |
1084 { | |
1085 int w, h, screenbpp; | |
1086 Uint8 *src, *dst; | |
1087 | |
1088 /* Set up the copy pointers */ | |
1089 screenbpp = screen->format->BytesPerPixel; | |
1090 if ((screen == SDL_VideoSurface) || | |
1091 FORMAT_EQUAL(screen->format, SDL_VideoSurface->format)) { | |
1092 dst = SDL_cursor->save[0]; | |
1093 } else { | |
1094 dst = SDL_cursor->save[1]; | |
1095 } | |
1096 src = (Uint8 *) screen->pixels + area.y * screen->pitch + | |
1097 area.x * screenbpp; | |
1098 | |
1099 /* Perform the copy */ | |
1100 w = area.w * screenbpp; | |
1101 h = area.h; | |
1102 while (h--) { | |
1103 SDL_memcpy(dst, src, w); | |
1104 dst += w; | |
1105 src += screen->pitch; | |
1106 } | |
1107 } | |
1108 | |
1109 /* Draw the mouse cursor */ | |
1110 area.x -= SDL_cursor->area.x; | |
1111 area.y -= SDL_cursor->area.y; | |
1112 if ((area.x == 0) && (area.w == SDL_cursor->area.w)) { | |
1113 SDL_DrawCursorFast(screen, &area); | |
1114 } else { | |
1115 SDL_DrawCursorSlow(screen, &area); | |
1116 } | |
1117 } | |
1118 | |
1119 void | |
1120 SDL_DrawCursor(SDL_Surface * screen) | |
1121 { | |
1122 /* Lock the screen if necessary */ | |
1123 if (screen == NULL) { | |
1124 return; | |
1125 } | |
1126 if (SDL_MUSTLOCK(screen)) { | |
1127 if (SDL_LockSurface(screen) < 0) { | |
1128 return; | |
1129 } | |
1130 } | |
1131 | |
1132 SDL_DrawCursorNoLock(screen); | |
1133 | |
1134 /* Unlock the screen and update if necessary */ | |
1135 if (SDL_MUSTLOCK(screen)) { | |
1136 SDL_UnlockSurface(screen); | |
1137 } | |
1138 if ((screen->flags & SDL_SCREEN_SURFACE) && | |
1139 !(screen->flags & SDL_HWSURFACE)) { | |
1140 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
1141 SDL_Window *window; | |
1142 SDL_Rect area; | |
1143 | |
1144 window = SDL_GetWindowFromSurface(screen); | |
1145 if (!window) { | |
1146 return; | |
1147 } | |
1148 | |
1149 SDL_MouseRect(&area); | |
1150 | |
1151 if (_this->UpdateWindowSurface) { | |
1152 _this->UpdateWindowSurface(_this, window, 1, &area); | |
1153 } | |
1154 } | |
1155 } | |
1156 | |
1157 void | |
1158 SDL_EraseCursorNoLock(SDL_Surface * screen) | |
1159 { | |
1160 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
1161 SDL_Window *window; | |
1162 SDL_Rect area; | |
1163 | |
1164 /* Get the window associated with the surface */ | |
1165 window = SDL_GetWindowFromSurface(screen); | |
1166 if (!window || !window->surface) { | |
1167 return; | |
1168 } | |
1169 | |
1170 /* Get the mouse rectangle, clipped to the screen */ | |
1171 SDL_MouseRect(&area); | |
1172 if ((area.w == 0) || (area.h == 0)) { | |
1173 return; | |
1174 } | |
1175 | |
1176 /* Copy mouse background */ | |
1177 { | |
1178 int w, h, screenbpp; | |
1179 Uint8 *src, *dst; | |
1180 | |
1181 /* Set up the copy pointers */ | |
1182 screenbpp = screen->format->BytesPerPixel; | |
1183 if ((screen->flags & SDL_SCREEN_SURFACE) || | |
1184 FORMAT_EQUAL(screen->format, window->surface->format)) { | |
1185 src = SDL_cursor->save[0]; | |
1186 } else { | |
1187 src = SDL_cursor->save[1]; | |
1188 } | |
1189 dst = (Uint8 *) screen->pixels + area.y * screen->pitch + | |
1190 area.x * screenbpp; | |
1191 | |
1192 /* Perform the copy */ | |
1193 w = area.w * screenbpp; | |
1194 h = area.h; | |
1195 while (h--) { | |
1196 SDL_memcpy(dst, src, w); | |
1197 src += w; | |
1198 dst += screen->pitch; | |
1199 } | |
1200 | |
1201 /* Perform pixel conversion on cursor background */ | |
1202 if (src > SDL_cursor->save[1]) { | |
1203 SDL_ConvertCursorSave(screen, area.w, area.h); | |
1204 } | |
1205 } | |
1206 } | |
1207 | |
1208 void | |
1209 SDL_EraseCursor(SDL_Surface * screen) | |
1210 { | |
1211 /* Lock the screen if necessary */ | |
1212 if (screen == NULL) { | |
1213 return; | |
1214 } | |
1215 if (SDL_MUSTLOCK(screen)) { | |
1216 if (SDL_LockSurface(screen) < 0) { | |
1217 return; | |
1218 } | |
1219 } | |
1220 | |
1221 SDL_EraseCursorNoLock(screen); | |
1222 | |
1223 /* Unlock the screen and update if necessary */ | |
1224 if (SDL_MUSTLOCK(screen)) { | |
1225 SDL_UnlockSurface(screen); | |
1226 } | |
1227 if ((screen->flags & SDL_SCREEN_SURFACE) && | |
1228 !(screen->flags & SDL_HWSURFACE)) { | |
1229 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
1230 SDL_Window *window; | |
1231 SDL_Rect area; | |
1232 | |
1233 window = SDL_GetWindowFromSurface(screen); | |
1234 if (!window) { | |
1235 return; | |
1236 } | |
1237 | |
1238 SDL_MouseRect(&area); | |
1239 | |
1240 if (_this->UpdateWindowSurface) { | |
1241 _this->UpdateWindowSurface(_this, window, 1, &area); | |
1242 } | |
1243 } | |
1244 } | |
1245 | |
1246 /* Reset the cursor on video mode change | |
1247 FIXME: Keep track of all cursors, and reset them all. | |
1248 */ | |
1249 void | |
1250 SDL_ResetCursor(void) | |
1251 { | |
1252 int savelen; | |
1253 | |
1254 if (SDL_cursor) { | |
1255 savelen = SDL_cursor->area.w * 4 * SDL_cursor->area.h; | |
1256 SDL_cursor->area.x = 0; | |
1257 SDL_cursor->area.y = 0; | |
1258 SDL_memset(SDL_cursor->save[0], 0, savelen); | |
1259 } | |
1260 } | |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1261 #endif |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1262 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1263 struct private_yuvhwdata |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1264 { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1265 Uint16 pitches[3]; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1266 Uint8 *planes[3]; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1267 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1268 SDL_TextureID textureID; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1269 }; |
1670 | 1270 |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1271 SDL_Overlay * |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1272 SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1273 { |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1274 SDL_Overlay *overlay; |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1275 Uint32 texture_format; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1276 |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1277 if ((display->flags & SDL_OPENGL) == SDL_OPENGL) { |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1278 SDL_SetError("YUV overlays are not supported in OpenGL mode"); |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1279 return NULL; |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1280 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1281 |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1282 if (display != SDL_PublicSurface) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1283 SDL_SetError("YUV display is only supported on the screen surface"); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1284 return NULL; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1285 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1286 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1287 switch (format) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1288 case SDL_YV12_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1289 texture_format = SDL_PixelFormat_YV12; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1290 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1291 case SDL_IYUV_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1292 texture_format = SDL_PixelFormat_IYUV; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1293 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1294 case SDL_YUY2_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1295 texture_format = SDL_PixelFormat_YUY2; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1296 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1297 case SDL_UYVY_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1298 texture_format = SDL_PixelFormat_UYVY; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1299 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1300 case SDL_YVYU_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1301 texture_format = SDL_PixelFormat_YVYU; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1302 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1303 default: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1304 SDL_SetError("Unknown YUV format"); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1305 return NULL; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1306 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1307 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1308 overlay = (SDL_Overlay *) SDL_malloc(sizeof(*overlay)); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1309 if (!overlay) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1310 SDL_OutOfMemory(); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1311 return NULL; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1312 } |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1313 SDL_zerop(overlay); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1314 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1315 overlay->hwdata = |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1316 (struct private_yuvhwdata *) SDL_malloc(sizeof(*overlay->hwdata)); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1317 if (!overlay->hwdata) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1318 SDL_free(overlay); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1319 SDL_OutOfMemory(); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1320 return NULL; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1321 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1322 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1323 overlay->format = format; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1324 overlay->w = w; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1325 overlay->h = h; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1326 if (format == SDL_YV12_OVERLAY || format == SDL_IYUV_OVERLAY) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1327 overlay->planes = 3; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1328 } else { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1329 overlay->planes = 1; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1330 } |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1331 overlay->pitches = overlay->hwdata->pitches; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1332 overlay->pixels = overlay->hwdata->planes; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1333 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1334 switch (format) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1335 case SDL_YV12_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1336 case SDL_IYUV_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1337 overlay->pitches[0] = overlay->w; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1338 overlay->pitches[1] = overlay->w / 2; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1339 overlay->pitches[2] = overlay->w / 2; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1340 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1341 case SDL_YUY2_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1342 case SDL_UYVY_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1343 case SDL_YVYU_OVERLAY: |
1685 | 1344 overlay->pitches[0] = overlay->w * 2; |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1345 break; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1346 } |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1347 |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1348 overlay->hwdata->textureID = |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1349 SDL_CreateTexture(texture_format, SDL_TextureAccess_Local, w, h); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1350 if (!overlay->hwdata->textureID) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1351 SDL_FreeYUVOverlay(overlay); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1352 return NULL; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1353 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1354 |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1355 return overlay; |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1356 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1357 |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1358 int |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1359 SDL_LockYUVOverlay(SDL_Overlay * overlay) |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1360 { |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1361 void *pixels; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1362 int pitch; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1363 if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1364 < 0) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1365 return -1; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1366 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1367 switch (overlay->format) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1368 case SDL_YV12_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1369 case SDL_IYUV_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1370 overlay->pixels[0] = (Uint8 *) pixels; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1371 overlay->pixels[1] = |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1372 overlay->pixels[0] + overlay->pitches[0] * overlay->h; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1373 overlay->pixels[2] = |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1374 overlay->pixels[1] + overlay->pitches[1] * overlay->h; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1375 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1376 case SDL_YUY2_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1377 case SDL_UYVY_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1378 case SDL_YVYU_OVERLAY: |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1379 overlay->pixels[0] = (Uint8 *) pixels; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1380 break; |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1381 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1382 return 0; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1383 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1384 |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1385 void |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1386 SDL_UnlockYUVOverlay(SDL_Overlay * overlay) |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1387 { |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1388 SDL_UnlockTexture(overlay->hwdata->textureID); |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1389 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1390 |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1391 int |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1392 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1393 { |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1394 if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect, |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1395 SDL_TextureBlendMode_None, |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1396 SDL_TextureScaleMode_Fast) < 0) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1397 return -1; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1398 } |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1399 SDL_RenderPresent(); |
1720
a1ebb17f9c52
Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents:
1716
diff
changeset
|
1400 return 0; |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1401 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1402 |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1403 void |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1404 SDL_FreeYUVOverlay(SDL_Overlay * overlay) |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1405 { |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1406 if (overlay) { |
1684
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1407 if (overlay->hwdata) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1408 if (overlay->hwdata->textureID) { |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1409 SDL_DestroyTexture(overlay->hwdata->textureID); |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1410 } |
c4aa1a2f48f1
Software YUV texture support in progress...
Sam Lantinga <slouken@libsdl.org>
parents:
1683
diff
changeset
|
1411 SDL_free(overlay->hwdata); |
1675
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1412 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1413 SDL_free(overlay); |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1414 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1415 } |
d33dcfc3fde7
Overlay functions are being replaced by YUV textures.
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
1416 |
1667
1fddae038bc8
Implemented many compatibility functions
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1417 /* vi: set ts=4 sw=4 expandtab: */ |