Mercurial > sdl-ios-xcode
annotate docs/html/sdlsetcolors.html @ 664:abfdc08eb289
Date: Sun, 3 Aug 2003 22:07:57 +0200
From: Max Horn
Subject: SDL OSX fullscreen FIX
the attached patch fixes the fullscreen problems on SDL/OSX. The cause
was that click events are bounded by winRect. Now, winRect is set to
the size of the video surface. But if you e.g. request a 640x420
surface, you might get a 640x480 "real" surface. Still,
SDL_VideoSurface->h will be set to 420! Thus, the upper 60 pixels in my
example received no mouse down events.
My fix simply disables this clipping when in full screen mode - after
all, all clicks then should be inside the screen surface. Higher SDL
functions ensure that the coordinates then are clipped to 640x420. It
works fine in all my tests here. I don't know if it's the right thing
to do in multi screen scenarios, though.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 04 Aug 2003 01:00:30 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_SetColors</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Video" | |
14 HREF="video.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_Flip" | |
17 HREF="sdlflip.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_SetPalette" | |
20 HREF="sdlsetpalette.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="sdlflip.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 ></TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="sdlsetpalette.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><H1 | |
69 ><A | |
70 NAME="SDLSETCOLORS" | |
71 >SDL_SetColors</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
76 NAME="AEN1078" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_SetColors -- Sets a portion of the colormap for the given 8-bit surface.</DIV | |
81 ><DIV | |
82 CLASS="REFSYNOPSISDIV" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN1081" |
0 | 85 ></A |
86 ><H2 | |
87 >Synopsis</H2 | |
88 ><DIV | |
89 CLASS="FUNCSYNOPSIS" | |
90 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
91 NAME="AEN1082" |
0 | 92 ></A |
93 ><P | |
94 ></P | |
95 ><PRE | |
96 CLASS="FUNCSYNOPSISINFO" | |
97 >#include "SDL.h"</PRE | |
98 ><P | |
99 ><CODE | |
100 ><CODE | |
101 CLASS="FUNCDEF" | |
102 >int <B | |
103 CLASS="FSFUNC" | |
104 >SDL_SetColors</B | |
105 ></CODE | |
106 >(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);</CODE | |
107 ></P | |
108 ><P | |
109 ></P | |
110 ></DIV | |
111 ></DIV | |
112 ><DIV | |
113 CLASS="REFSECT1" | |
114 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
115 NAME="AEN1088" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 >Sets a portion of the colormap for the given 8-bit surface.</P | |
121 ><P | |
122 >When <TT | |
123 CLASS="PARAMETER" | |
124 ><I | |
125 >surface</I | |
126 ></TT | |
127 > is the surface associated with the current | |
128 display, the display colormap will be updated with the requested colors. If | |
129 <TT | |
130 CLASS="LITERAL" | |
131 >SDL_HWPALETTE</TT | |
132 > was set in <A | |
133 HREF="sdlsetvideomode.html" | |
134 >SDL_SetVideoMode</A | |
135 > flags, | |
136 <TT | |
137 CLASS="FUNCTION" | |
138 >SDL_SetColors</TT | |
139 > will always return <SPAN | |
140 CLASS="RETURNVALUE" | |
141 >1</SPAN | |
142 >, | |
143 and the palette is guaranteed to be set the way you desire, even if the window | |
144 colormap has to be warped or run under emulation.</P | |
145 ><P | |
146 >The color components of a | |
147 <A | |
148 HREF="sdlcolor.html" | |
149 ><SPAN | |
150 CLASS="STRUCTNAME" | |
151 >SDL_Color</SPAN | |
152 ></A | |
153 > | |
154 structure are 8-bits in size, giving you a total of 256<SUP | |
155 >3</SUP | |
156 > | |
157 =16777216 colors.</P | |
158 ><P | |
159 >Palettized (8-bit) screen surfaces with the <TT | |
160 CLASS="LITERAL" | |
161 >SDL_HWPALETTE</TT | |
162 > | |
163 flag have two palettes, a logical palette that is used for mapping blits | |
164 to/from the surface and a physical palette (that determines how the | |
165 hardware will map the colors to the display). <TT | |
166 CLASS="FUNCTION" | |
167 >SDL_SetColors</TT | |
168 > | |
169 modifies both palettes (if present), and is equivalent to calling | |
170 <A | |
171 HREF="sdlsetpalette.html" | |
172 >SDL_SetPalette</A | |
173 > with the | |
174 <TT | |
175 CLASS="PARAMETER" | |
176 ><I | |
177 >flags</I | |
178 ></TT | |
179 > set to | |
180 <TT | |
181 CLASS="LITERAL" | |
182 >(SDL_LOGPAL | SDL_PHYSPAL)</TT | |
183 >.</P | |
184 ></DIV | |
185 ><DIV | |
186 CLASS="REFSECT1" | |
187 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
188 NAME="AEN1107" |
0 | 189 ></A |
190 ><H2 | |
191 >Return Value</H2 | |
192 ><P | |
193 >If <TT | |
194 CLASS="PARAMETER" | |
195 ><I | |
196 >surface</I | |
197 ></TT | |
198 > is not a palettized surface, this function | |
199 does nothing, returning <SPAN | |
200 CLASS="RETURNVALUE" | |
201 >0</SPAN | |
202 >. If all of the colors were set | |
203 as passed to <TT | |
204 CLASS="FUNCTION" | |
205 >SDL_SetColors</TT | |
206 >, it will return | |
207 <SPAN | |
208 CLASS="RETURNVALUE" | |
209 >1</SPAN | |
210 >. If not all the color entries were set exactly as | |
211 given, it will return <SPAN | |
212 CLASS="RETURNVALUE" | |
213 >0</SPAN | |
214 >, and you should look at the | |
215 surface palette to determine the actual color palette.</P | |
216 ></DIV | |
217 ><DIV | |
218 CLASS="REFSECT1" | |
219 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
220 NAME="AEN1115" |
0 | 221 ></A |
222 ><H2 | |
223 >Example</H2 | |
224 ><PRE | |
225 CLASS="PROGRAMLISTING" | |
226 >/* Create a display surface with a grayscale palette */ | |
227 SDL_Surface *screen; | |
228 SDL_Color colors[256]; | |
229 int i; | |
230 . | |
231 . | |
232 . | |
233 /* Fill colors with color information */ | |
234 for(i=0;i<256;i++){ | |
235 colors[i].r=i; | |
236 colors[i].g=i; | |
237 colors[i].b=i; | |
238 } | |
239 | |
240 /* Create display */ | |
241 screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE); | |
242 if(!screen){ | |
243 printf("Couldn't set video mode: %s\n", SDL_GetError()); | |
244 exit(-1); | |
245 } | |
246 | |
247 /* Set palette */ | |
248 SDL_SetColors(screen, colors, 0, 256); | |
249 . | |
250 . | |
251 . | |
252 .</PRE | |
253 ></DIV | |
254 ><DIV | |
255 CLASS="REFSECT1" | |
256 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
257 NAME="AEN1118" |
0 | 258 ></A |
259 ><H2 | |
260 >See Also</H2 | |
261 ><P | |
262 ><A | |
263 HREF="sdlcolor.html" | |
264 ><SPAN | |
265 CLASS="STRUCTNAME" | |
266 >SDL_Color</SPAN | |
267 ></A | |
268 > | |
269 <A | |
270 HREF="sdlsurface.html" | |
271 ><SPAN | |
272 CLASS="STRUCTNAME" | |
273 >SDL_Surface</SPAN | |
274 ></A | |
275 >, | |
276 <A | |
277 HREF="sdlsetpalette.html" | |
278 ><TT | |
279 CLASS="FUNCTION" | |
280 >SDL_SetPalette</TT | |
281 ></A | |
282 >, | |
283 <A | |
284 HREF="sdlsetvideomode.html" | |
285 ><TT | |
286 CLASS="FUNCTION" | |
287 >SDL_SetVideoMode</TT | |
288 ></A | |
289 ></P | |
290 ></DIV | |
291 ><DIV | |
292 CLASS="NAVFOOTER" | |
293 ><HR | |
294 ALIGN="LEFT" | |
295 WIDTH="100%"><TABLE | |
296 WIDTH="100%" | |
297 BORDER="0" | |
298 CELLPADDING="0" | |
299 CELLSPACING="0" | |
300 ><TR | |
301 ><TD | |
302 WIDTH="33%" | |
303 ALIGN="left" | |
304 VALIGN="top" | |
305 ><A | |
306 HREF="sdlflip.html" | |
307 >Prev</A | |
308 ></TD | |
309 ><TD | |
310 WIDTH="34%" | |
311 ALIGN="center" | |
312 VALIGN="top" | |
313 ><A | |
314 HREF="index.html" | |
315 >Home</A | |
316 ></TD | |
317 ><TD | |
318 WIDTH="33%" | |
319 ALIGN="right" | |
320 VALIGN="top" | |
321 ><A | |
322 HREF="sdlsetpalette.html" | |
323 >Next</A | |
324 ></TD | |
325 ></TR | |
326 ><TR | |
327 ><TD | |
328 WIDTH="33%" | |
329 ALIGN="left" | |
330 VALIGN="top" | |
331 >SDL_Flip</TD | |
332 ><TD | |
333 WIDTH="34%" | |
334 ALIGN="center" | |
335 VALIGN="top" | |
336 ><A | |
337 HREF="video.html" | |
338 >Up</A | |
339 ></TD | |
340 ><TD | |
341 WIDTH="33%" | |
342 ALIGN="right" | |
343 VALIGN="top" | |
344 >SDL_SetPalette</TD | |
345 ></TR | |
346 ></TABLE | |
347 ></DIV | |
348 ></BODY | |
349 ></HTML | |
350 > |