Mercurial > sdl-ios-xcode
annotate docs/html/eventstructures.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 Event Structures.</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="Events" | |
14 HREF="event.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="Events" | |
17 HREF="event.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_Event" | |
20 HREF="sdlevent.html"></HEAD | |
21 ><BODY | |
22 CLASS="SECT1" | |
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="event.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 >Chapter 8. Events</TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="sdlevent.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 ><DIV | |
72 CLASS="SECT1" | |
73 ><H1 | |
74 CLASS="SECT1" | |
75 ><A | |
76 NAME="EVENTSTRUCTURES" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
77 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
78 >SDL Event Structures.</H1 |
0 | 79 ><DIV |
80 CLASS="TOC" | |
81 ><DL | |
82 ><DT | |
83 ><B | |
84 >Table of Contents</B | |
85 ></DT | |
86 ><DT | |
87 ><A | |
88 HREF="sdlevent.html" | |
89 >SDL_Event</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
90 > -- General event structure</DT |
0 | 91 ><DT |
92 ><A | |
93 HREF="sdlactiveevent.html" | |
94 >SDL_ActiveEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
95 > -- Application visibility event structure</DT |
0 | 96 ><DT |
97 ><A | |
98 HREF="sdlkeyboardevent.html" | |
99 >SDL_KeyboardEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
100 > -- Keyboard event structure</DT |
0 | 101 ><DT |
102 ><A | |
103 HREF="sdlmousemotionevent.html" | |
104 >SDL_MouseMotionEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
105 > -- Mouse motion event structure</DT |
0 | 106 ><DT |
107 ><A | |
108 HREF="sdlmousebuttonevent.html" | |
109 >SDL_MouseButtonEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
110 > -- Mouse button event structure</DT |
0 | 111 ><DT |
112 ><A | |
113 HREF="sdljoyaxisevent.html" | |
114 >SDL_JoyAxisEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
115 > -- Joystick axis motion event structure</DT |
0 | 116 ><DT |
117 ><A | |
118 HREF="sdljoybuttonevent.html" | |
119 >SDL_JoyButtonEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
120 > -- Joystick button event structure</DT |
0 | 121 ><DT |
122 ><A | |
123 HREF="sdljoyhatevent.html" | |
124 >SDL_JoyHatEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
125 > -- Joystick hat position change event structure</DT |
0 | 126 ><DT |
127 ><A | |
128 HREF="sdljoyballevent.html" | |
129 >SDL_JoyBallEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
130 > -- Joystick trackball motion event structure</DT |
0 | 131 ><DT |
132 ><A | |
133 HREF="sdlresizeevent.html" | |
134 >SDL_ResizeEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
135 > -- Window resize event structure</DT |
0 | 136 ><DT |
137 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
138 HREF="sdlexposeevent.html" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
139 >SDL_ExposeEvent</A |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
140 > -- Quit requested event</DT |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
141 ><DT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
142 ><A |
0 | 143 HREF="sdlsyswmevent.html" |
144 >SDL_SysWMEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
145 > -- Platform-dependent window manager event.</DT |
0 | 146 ><DT |
147 ><A | |
148 HREF="sdluserevent.html" | |
149 >SDL_UserEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
150 > -- A user-defined event type</DT |
0 | 151 ><DT |
152 ><A | |
153 HREF="sdlquitevent.html" | |
154 >SDL_QuitEvent</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
155 > -- Quit requested event</DT |
0 | 156 ><DT |
157 ><A | |
158 HREF="sdlkeysym.html" | |
159 >SDL_keysym</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
160 > -- Keysym structure</DT |
0 | 161 ><DT |
162 ><A | |
163 HREF="sdlkey.html" | |
164 >SDLKey</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
165 > -- Keysym definitions.</DT |
0 | 166 ></DL |
167 ></DIV | |
168 ></DIV | |
169 ><DIV | |
170 CLASS="NAVFOOTER" | |
171 ><HR | |
172 ALIGN="LEFT" | |
173 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
174 SUMMARY="Footer navigation table" |
0 | 175 WIDTH="100%" |
176 BORDER="0" | |
177 CELLPADDING="0" | |
178 CELLSPACING="0" | |
179 ><TR | |
180 ><TD | |
181 WIDTH="33%" | |
182 ALIGN="left" | |
183 VALIGN="top" | |
184 ><A | |
185 HREF="event.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
186 ACCESSKEY="P" |
0 | 187 >Prev</A |
188 ></TD | |
189 ><TD | |
190 WIDTH="34%" | |
191 ALIGN="center" | |
192 VALIGN="top" | |
193 ><A | |
194 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
195 ACCESSKEY="H" |
0 | 196 >Home</A |
197 ></TD | |
198 ><TD | |
199 WIDTH="33%" | |
200 ALIGN="right" | |
201 VALIGN="top" | |
202 ><A | |
203 HREF="sdlevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
204 ACCESSKEY="N" |
0 | 205 >Next</A |
206 ></TD | |
207 ></TR | |
208 ><TR | |
209 ><TD | |
210 WIDTH="33%" | |
211 ALIGN="left" | |
212 VALIGN="top" | |
213 >Events</TD | |
214 ><TD | |
215 WIDTH="34%" | |
216 ALIGN="center" | |
217 VALIGN="top" | |
218 ><A | |
219 HREF="event.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
220 ACCESSKEY="U" |
0 | 221 >Up</A |
222 ></TD | |
223 ><TD | |
224 WIDTH="33%" | |
225 ALIGN="right" | |
226 VALIGN="top" | |
227 >SDL_Event</TD | |
228 ></TR | |
229 ></TABLE | |
230 ></DIV | |
231 ></BODY | |
232 ></HTML | |
233 > |