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