annotate src/SDL_compat.c @ 1687:d36048e8e302 SDL-1.3

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