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