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