Mercurial > sdl-ios-xcode
annotate docs/html/sdlsetcolors.html @ 934:af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
From: Eric Wing <ewing2121@yahoo.com>
Subject: New OS X patch (was Re: [SDL] Bug with inverted mouse coordinates in
I have a new patch for OS X I would like to submit.
First, it appears no further action has been taken on
my fix from Apple on the OpenGL windowed mode mouse
inversion problem. The fix would reunify the code, and
no longer require case checking for which version of
the OS you are running. This is probably a good fix
because the behavior with the old code could change
again with future versions of the OS, so those fixes
are included in this new patch.
But in addition, when I was at Apple, I asked them
about the ability to distinguish between the modifier
keys on the left and right sides of the keyboard (e.g.
Left Shift, Right Shift, Left/Right Alt, L/R Cmd, L/R
Ctrl). They told me that starting with Panther, the OS
began supporting this feature. This has always been a
source of annoyance for me when bringing a program
that comes from Windows or Linux to OS X when the
keybindings happened to need distinguishable left-side
and right-side keys. So the rest of the patch I am
submitting contains new code to support this feature
on Panther (and presumably later versions of the OS).
So after removing the OS version checks for the mouse
inversion problem, I reused the OS version checks to
activate the Left/Right detection of modifier keys. If
you are running Panther (or above), the new code will
attempt to distinguish between sides. For the older
OS's, the code path reverts to the original code.
I've tested with Panther on a G4 Cube, G5 dual
processor, and Powerbook Rev C. The Cube and G5
keyboards demonstrated the ability to distinguish
between sides. The Powerbook seems to only have
left-side keys, but the patch was still able to handle
it by producing the same results as before the patch.
I also wanted to test a non-Apple keyboard.
Unfortunately, I don't have any PC USB keyboards.
However, I was able to borrow a Sun Microsystems USB
keyboard, so I tried that out on the G5, and I got the
correct behavior for left and right sides. I'm
expecting that if it worked with a Sun keyboard, most
other keyboards should work with no problems.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 20 Aug 2004 22:35:23 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_SetColors</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
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 | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
31 SUMMARY="Header navigation table" |
0 | 32 WIDTH="100%" |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >SDL Library Documentation</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="sdlflip.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
49 ACCESSKEY="P" |
0 | 50 >Prev</A |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 ></TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="sdlsetpalette.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
63 ACCESSKEY="N" |
0 | 64 >Next</A |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><H1 | |
72 ><A | |
73 NAME="SDLSETCOLORS" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
74 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
75 >SDL_SetColors</H1 |
0 | 76 ><DIV |
77 CLASS="REFNAMEDIV" | |
78 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
79 NAME="AEN1462" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_SetColors -- Sets a portion of the colormap for the given 8-bit surface.</DIV | |
84 ><DIV | |
85 CLASS="REFSYNOPSISDIV" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN1465" |
0 | 88 ></A |
89 ><H2 | |
90 >Synopsis</H2 | |
91 ><DIV | |
92 CLASS="FUNCSYNOPSIS" | |
93 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
94 NAME="AEN1466" |
0 | 95 ></A |
96 ><P | |
97 ></P | |
98 ><PRE | |
99 CLASS="FUNCSYNOPSISINFO" | |
100 >#include "SDL.h"</PRE | |
101 ><P | |
102 ><CODE | |
103 ><CODE | |
104 CLASS="FUNCDEF" | |
105 >int <B | |
106 CLASS="FSFUNC" | |
107 >SDL_SetColors</B | |
108 ></CODE | |
109 >(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);</CODE | |
110 ></P | |
111 ><P | |
112 ></P | |
113 ></DIV | |
114 ></DIV | |
115 ><DIV | |
116 CLASS="REFSECT1" | |
117 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
118 NAME="AEN1472" |
0 | 119 ></A |
120 ><H2 | |
121 >Description</H2 | |
122 ><P | |
123 >Sets a portion of the colormap for the given 8-bit surface.</P | |
124 ><P | |
125 >When <TT | |
126 CLASS="PARAMETER" | |
127 ><I | |
128 >surface</I | |
129 ></TT | |
130 > is the surface associated with the current | |
131 display, the display colormap will be updated with the requested colors. If | |
132 <TT | |
133 CLASS="LITERAL" | |
134 >SDL_HWPALETTE</TT | |
135 > was set in <A | |
136 HREF="sdlsetvideomode.html" | |
137 >SDL_SetVideoMode</A | |
138 > flags, | |
139 <TT | |
140 CLASS="FUNCTION" | |
141 >SDL_SetColors</TT | |
142 > will always return <SPAN | |
143 CLASS="RETURNVALUE" | |
144 >1</SPAN | |
145 >, | |
146 and the palette is guaranteed to be set the way you desire, even if the window | |
147 colormap has to be warped or run under emulation.</P | |
148 ><P | |
149 >The color components of a | |
150 <A | |
151 HREF="sdlcolor.html" | |
152 ><SPAN | |
153 CLASS="STRUCTNAME" | |
154 >SDL_Color</SPAN | |
155 ></A | |
156 > | |
157 structure are 8-bits in size, giving you a total of 256<SUP | |
158 >3</SUP | |
159 > | |
160 =16777216 colors.</P | |
161 ><P | |
162 >Palettized (8-bit) screen surfaces with the <TT | |
163 CLASS="LITERAL" | |
164 >SDL_HWPALETTE</TT | |
165 > | |
166 flag have two palettes, a logical palette that is used for mapping blits | |
167 to/from the surface and a physical palette (that determines how the | |
168 hardware will map the colors to the display). <TT | |
169 CLASS="FUNCTION" | |
170 >SDL_SetColors</TT | |
171 > | |
172 modifies both palettes (if present), and is equivalent to calling | |
173 <A | |
174 HREF="sdlsetpalette.html" | |
175 >SDL_SetPalette</A | |
176 > with the | |
177 <TT | |
178 CLASS="PARAMETER" | |
179 ><I | |
180 >flags</I | |
181 ></TT | |
182 > set to | |
183 <TT | |
184 CLASS="LITERAL" | |
185 >(SDL_LOGPAL | SDL_PHYSPAL)</TT | |
186 >.</P | |
187 ></DIV | |
188 ><DIV | |
189 CLASS="REFSECT1" | |
190 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
191 NAME="AEN1491" |
0 | 192 ></A |
193 ><H2 | |
194 >Return Value</H2 | |
195 ><P | |
196 >If <TT | |
197 CLASS="PARAMETER" | |
198 ><I | |
199 >surface</I | |
200 ></TT | |
201 > is not a palettized surface, this function | |
202 does nothing, returning <SPAN | |
203 CLASS="RETURNVALUE" | |
204 >0</SPAN | |
205 >. If all of the colors were set | |
206 as passed to <TT | |
207 CLASS="FUNCTION" | |
208 >SDL_SetColors</TT | |
209 >, it will return | |
210 <SPAN | |
211 CLASS="RETURNVALUE" | |
212 >1</SPAN | |
213 >. If not all the color entries were set exactly as | |
214 given, it will return <SPAN | |
215 CLASS="RETURNVALUE" | |
216 >0</SPAN | |
217 >, and you should look at the | |
218 surface palette to determine the actual color palette.</P | |
219 ></DIV | |
220 ><DIV | |
221 CLASS="REFSECT1" | |
222 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
223 NAME="AEN1499" |
0 | 224 ></A |
225 ><H2 | |
226 >Example</H2 | |
227 ><PRE | |
228 CLASS="PROGRAMLISTING" | |
229 >/* Create a display surface with a grayscale palette */ | |
230 SDL_Surface *screen; | |
231 SDL_Color colors[256]; | |
232 int i; | |
233 . | |
234 . | |
235 . | |
236 /* Fill colors with color information */ | |
237 for(i=0;i<256;i++){ | |
238 colors[i].r=i; | |
239 colors[i].g=i; | |
240 colors[i].b=i; | |
241 } | |
242 | |
243 /* Create display */ | |
244 screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE); | |
245 if(!screen){ | |
246 printf("Couldn't set video mode: %s\n", SDL_GetError()); | |
247 exit(-1); | |
248 } | |
249 | |
250 /* Set palette */ | |
251 SDL_SetColors(screen, colors, 0, 256); | |
252 . | |
253 . | |
254 . | |
255 .</PRE | |
256 ></DIV | |
257 ><DIV | |
258 CLASS="REFSECT1" | |
259 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
260 NAME="AEN1502" |
0 | 261 ></A |
262 ><H2 | |
263 >See Also</H2 | |
264 ><P | |
265 ><A | |
266 HREF="sdlcolor.html" | |
267 ><SPAN | |
268 CLASS="STRUCTNAME" | |
269 >SDL_Color</SPAN | |
270 ></A | |
271 > | |
272 <A | |
273 HREF="sdlsurface.html" | |
274 ><SPAN | |
275 CLASS="STRUCTNAME" | |
276 >SDL_Surface</SPAN | |
277 ></A | |
278 >, | |
279 <A | |
280 HREF="sdlsetpalette.html" | |
281 ><TT | |
282 CLASS="FUNCTION" | |
283 >SDL_SetPalette</TT | |
284 ></A | |
285 >, | |
286 <A | |
287 HREF="sdlsetvideomode.html" | |
288 ><TT | |
289 CLASS="FUNCTION" | |
290 >SDL_SetVideoMode</TT | |
291 ></A | |
292 ></P | |
293 ></DIV | |
294 ><DIV | |
295 CLASS="NAVFOOTER" | |
296 ><HR | |
297 ALIGN="LEFT" | |
298 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
299 SUMMARY="Footer navigation table" |
0 | 300 WIDTH="100%" |
301 BORDER="0" | |
302 CELLPADDING="0" | |
303 CELLSPACING="0" | |
304 ><TR | |
305 ><TD | |
306 WIDTH="33%" | |
307 ALIGN="left" | |
308 VALIGN="top" | |
309 ><A | |
310 HREF="sdlflip.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
311 ACCESSKEY="P" |
0 | 312 >Prev</A |
313 ></TD | |
314 ><TD | |
315 WIDTH="34%" | |
316 ALIGN="center" | |
317 VALIGN="top" | |
318 ><A | |
319 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
320 ACCESSKEY="H" |
0 | 321 >Home</A |
322 ></TD | |
323 ><TD | |
324 WIDTH="33%" | |
325 ALIGN="right" | |
326 VALIGN="top" | |
327 ><A | |
328 HREF="sdlsetpalette.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
329 ACCESSKEY="N" |
0 | 330 >Next</A |
331 ></TD | |
332 ></TR | |
333 ><TR | |
334 ><TD | |
335 WIDTH="33%" | |
336 ALIGN="left" | |
337 VALIGN="top" | |
338 >SDL_Flip</TD | |
339 ><TD | |
340 WIDTH="34%" | |
341 ALIGN="center" | |
342 VALIGN="top" | |
343 ><A | |
344 HREF="video.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
345 ACCESSKEY="U" |
0 | 346 >Up</A |
347 ></TD | |
348 ><TD | |
349 WIDTH="33%" | |
350 ALIGN="right" | |
351 VALIGN="top" | |
352 >SDL_SetPalette</TD | |
353 ></TR | |
354 ></TABLE | |
355 ></DIV | |
356 ></BODY | |
357 ></HTML | |
358 > |