Mercurial > sdl-ios-xcode
annotate docs/html/sdlglattr.html @ 876:9e84d106ec19
(Said Max Horn on the SDL mailing list...)
Hi folks,
based on Eric Wing's patch, I created the attached patch which fixes
the OpenGL coordinate inversion bug in SDL. It works fine over here on
10.3 with Ryan's test program (which I also attached).
There is another change in it: I removed the "- 1" in the two lines
using CGDisplayPixelsHigh()... while I understand from a logical point
of view why they *should* be correct, I checked the actual values
computed that way, and they were off-by-one. After removing the " - 1",
the returned mouse coordinates are correct. I checked this by moving
the mouse to the screen top/bottom in fullscreen mode, BTW. With the
change, the proper values 0 and 479 are returned (in 640x480 mode).
Sam, you may still want to test on 10.1, it's very simple using Ryan's
minimal test code :-)
Cheers,
Max
(Here is the reproduction case for revision history's sake...)
/*
* To compile:
* gcc -o test test.c `sdl-config --cflags` `sdl-config --libs` -framework OpenGL
*
* --ryan.
*/
#include <stdio.h>
#include "SDL.h"
#include "SDL_opengl.h"
int main(int argc, char **argv)
{
Uint32 flags = SDL_OPENGL /* | SDL_FULLSCREEN */;
SDL_Surface *screen;
SDL_Event event;
int done = 0;
GLfloat ratio;
SDL_Init(SDL_INIT_VIDEO);
SDL_ShowCursor(0);
if ((argv[1]) && (strcmp(argv[1], "--grab") == 0))
SDL_WM_GrabInput(SDL_GRAB_ON);
screen = SDL_SetVideoMode(640, 480, 0, flags);
if (!screen)
return(42);
ratio = ((GLfloat) screen->w) / ((GLfloat) screen->h);
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 1.0f );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glViewport( 0, 0, screen->w, screen->h);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();
// eh, close enough.
#define MAX_X 6.12
#define MAX_Y 4.50
while (!done)
{
int x, y;
GLfloat glx, gly;
if (!SDL_WaitEvent(&event))
break;
switch (event.type)
{
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_ESCAPE)
done = 1;
break;
}
SDL_GetMouseState(&x, &y);
glx = ((((GLfloat) x) / ((GLfloat) screen->w)) - 0.5f) * MAX_X;
gly = ((((GLfloat) y) / ((GLfloat) screen->h)) - 0.5f) * MAX_Y;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(glx,-gly,-6.0f);
glBegin(GL_TRIANGLES);
glColor3f(1,0,0); glVertex3f( 0.00f, 0.25f, 0.00f);
glColor3f(0,1,0); glVertex3f(-0.25f, -0.25f, 0.00f);
glColor3f(0,0,1); glVertex3f( 0.25f, -0.25f, 0.00f);
glEnd();
SDL_GL_SwapBuffers();
}
SDL_Quit();
return(0);
}
/* end of test.c ... */
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 22 Mar 2004 09:38:20 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_GLattr</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_FreeYUVOverlay" | |
17 HREF="sdlfreeyuvoverlay.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_Rect" | |
20 HREF="sdlrect.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="sdlfreeyuvoverlay.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="sdlrect.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="SDLGLATTR" | |
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_GLattr</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="AEN2971" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_GLattr -- SDL GL Attributes</DIV | |
84 ><DIV | |
85 CLASS="REFSECT1" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN2974" |
0 | 88 ></A |
89 ><H2 | |
90 >Attributes</H2 | |
91 ><DIV | |
92 CLASS="INFORMALTABLE" | |
93 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
94 NAME="AEN2976" |
0 | 95 ></A |
96 ><P | |
97 ></P | |
98 ><TABLE | |
99 BORDER="0" | |
100 CLASS="CALSTABLE" | |
101 ><TBODY | |
102 ><TR | |
103 ><TD | |
104 ALIGN="LEFT" | |
105 VALIGN="TOP" | |
106 ><TT | |
107 CLASS="LITERAL" | |
108 >SDL_GL_RED_SIZE</TT | |
109 ></TD | |
110 ><TD | |
111 ALIGN="LEFT" | |
112 VALIGN="TOP" | |
113 >Size of the framebuffer red component, in bits</TD | |
114 ></TR | |
115 ><TR | |
116 ><TD | |
117 ALIGN="LEFT" | |
118 VALIGN="TOP" | |
119 ><TT | |
120 CLASS="LITERAL" | |
121 >SDL_GL_GREEN_SIZE</TT | |
122 ></TD | |
123 ><TD | |
124 ALIGN="LEFT" | |
125 VALIGN="TOP" | |
126 >Size of the framebuffer green component, in bits</TD | |
127 ></TR | |
128 ><TR | |
129 ><TD | |
130 ALIGN="LEFT" | |
131 VALIGN="TOP" | |
132 ><TT | |
133 CLASS="LITERAL" | |
134 >SDL_GL_BLUE_SIZE</TT | |
135 ></TD | |
136 ><TD | |
137 ALIGN="LEFT" | |
138 VALIGN="TOP" | |
139 >Size of the framebuffer blue component, in bits</TD | |
140 ></TR | |
141 ><TR | |
142 ><TD | |
143 ALIGN="LEFT" | |
144 VALIGN="TOP" | |
145 ><TT | |
146 CLASS="LITERAL" | |
147 >SDL_GL_ALPHA_SIZE</TT | |
148 ></TD | |
149 ><TD | |
150 ALIGN="LEFT" | |
151 VALIGN="TOP" | |
152 >Size of the framebuffer alpha component, in bits</TD | |
153 ></TR | |
154 ><TR | |
155 ><TD | |
156 ALIGN="LEFT" | |
157 VALIGN="TOP" | |
158 ><TT | |
159 CLASS="LITERAL" | |
160 >SDL_GL_DOUBLEBUFFER</TT | |
161 ></TD | |
162 ><TD | |
163 ALIGN="LEFT" | |
164 VALIGN="TOP" | |
165 >0 or 1, enable or disable double buffering</TD | |
166 ></TR | |
167 ><TR | |
168 ><TD | |
169 ALIGN="LEFT" | |
170 VALIGN="TOP" | |
171 ><TT | |
172 CLASS="LITERAL" | |
173 >SDL_GL_BUFFER_SIZE</TT | |
174 ></TD | |
175 ><TD | |
176 ALIGN="LEFT" | |
177 VALIGN="TOP" | |
178 >Size of the framebuffer, in bits</TD | |
179 ></TR | |
180 ><TR | |
181 ><TD | |
182 ALIGN="LEFT" | |
183 VALIGN="TOP" | |
184 ><TT | |
185 CLASS="LITERAL" | |
186 >SDL_GL_DEPTH_SIZE</TT | |
187 ></TD | |
188 ><TD | |
189 ALIGN="LEFT" | |
190 VALIGN="TOP" | |
191 >Size of the depth buffer, in bits</TD | |
192 ></TR | |
193 ><TR | |
194 ><TD | |
195 ALIGN="LEFT" | |
196 VALIGN="TOP" | |
197 ><TT | |
198 CLASS="LITERAL" | |
199 >SDL_GL_STENCIL_SIZE</TT | |
200 ></TD | |
201 ><TD | |
202 ALIGN="LEFT" | |
203 VALIGN="TOP" | |
204 >Size of the stencil buffer, in bits</TD | |
205 ></TR | |
206 ><TR | |
207 ><TD | |
208 ALIGN="LEFT" | |
209 VALIGN="TOP" | |
210 ><TT | |
211 CLASS="LITERAL" | |
212 >SDL_GL_ACCUM_RED_SIZE</TT | |
213 ></TD | |
214 ><TD | |
215 ALIGN="LEFT" | |
216 VALIGN="TOP" | |
217 >Size of the accumulation buffer red component, in bits</TD | |
218 ></TR | |
219 ><TR | |
220 ><TD | |
221 ALIGN="LEFT" | |
222 VALIGN="TOP" | |
223 ><TT | |
224 CLASS="LITERAL" | |
225 >SDL_GL_ACCUM_GREEN_SIZE</TT | |
226 ></TD | |
227 ><TD | |
228 ALIGN="LEFT" | |
229 VALIGN="TOP" | |
230 >Size of the accumulation buffer green component, in bits</TD | |
231 ></TR | |
232 ><TR | |
233 ><TD | |
234 ALIGN="LEFT" | |
235 VALIGN="TOP" | |
236 ><TT | |
237 CLASS="LITERAL" | |
238 >SDL_GL_ACCUM_BLUE_SIZE</TT | |
239 ></TD | |
240 ><TD | |
241 ALIGN="LEFT" | |
242 VALIGN="TOP" | |
243 >Size of the accumulation buffer blue component, in bits</TD | |
244 ></TR | |
245 ><TR | |
246 ><TD | |
247 ALIGN="LEFT" | |
248 VALIGN="TOP" | |
249 ><TT | |
250 CLASS="LITERAL" | |
251 >SDL_GL_ACCUM_ALPHA_SIZE</TT | |
252 ></TD | |
253 ><TD | |
254 ALIGN="LEFT" | |
255 VALIGN="TOP" | |
256 >Size of the accumulation buffer alpha component, in bits</TD | |
257 ></TR | |
258 ></TBODY | |
259 ></TABLE | |
260 ><P | |
261 ></P | |
262 ></DIV | |
263 ></DIV | |
264 ><DIV | |
265 CLASS="REFSECT1" | |
266 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
267 NAME="AEN3027" |
0 | 268 ></A |
269 ><H2 | |
270 >Description</H2 | |
271 ><P | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
272 >While you can set most OpenGL attributes normally, the attributes list above must be known <SPAN |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
273 CLASS="emphasis" |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
274 ><I |
0 | 275 CLASS="EMPHASIS" |
276 >before</I | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
277 ></SPAN |
0 | 278 > SDL sets the video mode. These attributes a set and read with <A |
279 HREF="sdlglsetattribute.html" | |
280 ><TT | |
281 CLASS="FUNCTION" | |
282 >SDL_GL_SetAttribute</TT | |
283 ></A | |
284 > and <A | |
285 HREF="sdlglgetattribute.html" | |
286 ><TT | |
287 CLASS="FUNCTION" | |
288 >SDL_GL_GetAttribute</TT | |
289 ></A | |
290 >.</P | |
291 ></DIV | |
292 ><DIV | |
293 CLASS="REFSECT1" | |
294 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
295 NAME="AEN3035" |
0 | 296 ></A |
297 ><H2 | |
298 >See Also</H2 | |
299 ><P | |
300 ><A | |
301 HREF="sdlglsetattribute.html" | |
302 ><TT | |
303 CLASS="FUNCTION" | |
304 >SDL_GL_SetAttribute</TT | |
305 ></A | |
306 >, | |
307 <A | |
308 HREF="sdlglgetattribute.html" | |
309 ><TT | |
310 CLASS="FUNCTION" | |
311 >SDL_GL_GetAttribute</TT | |
312 ></A | |
313 ></P | |
314 ></DIV | |
315 ><DIV | |
316 CLASS="NAVFOOTER" | |
317 ><HR | |
318 ALIGN="LEFT" | |
319 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
320 SUMMARY="Footer navigation table" |
0 | 321 WIDTH="100%" |
322 BORDER="0" | |
323 CELLPADDING="0" | |
324 CELLSPACING="0" | |
325 ><TR | |
326 ><TD | |
327 WIDTH="33%" | |
328 ALIGN="left" | |
329 VALIGN="top" | |
330 ><A | |
331 HREF="sdlfreeyuvoverlay.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
332 ACCESSKEY="P" |
0 | 333 >Prev</A |
334 ></TD | |
335 ><TD | |
336 WIDTH="34%" | |
337 ALIGN="center" | |
338 VALIGN="top" | |
339 ><A | |
340 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
341 ACCESSKEY="H" |
0 | 342 >Home</A |
343 ></TD | |
344 ><TD | |
345 WIDTH="33%" | |
346 ALIGN="right" | |
347 VALIGN="top" | |
348 ><A | |
349 HREF="sdlrect.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
350 ACCESSKEY="N" |
0 | 351 >Next</A |
352 ></TD | |
353 ></TR | |
354 ><TR | |
355 ><TD | |
356 WIDTH="33%" | |
357 ALIGN="left" | |
358 VALIGN="top" | |
359 >SDL_FreeYUVOverlay</TD | |
360 ><TD | |
361 WIDTH="34%" | |
362 ALIGN="center" | |
363 VALIGN="top" | |
364 ><A | |
365 HREF="video.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
366 ACCESSKEY="U" |
0 | 367 >Up</A |
368 ></TD | |
369 ><TD | |
370 WIDTH="33%" | |
371 ALIGN="right" | |
372 VALIGN="top" | |
373 >SDL_Rect</TD | |
374 ></TR | |
375 ></TABLE | |
376 ></DIV | |
377 ></BODY | |
378 ></HTML | |
379 > |