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