Mercurial > sdl-ios-xcode
annotate docs/html/cdrom.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 >CD-ROM</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
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="SDL Reference" | |
14 HREF="reference.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_CloseAudio" | |
17 HREF="sdlcloseaudio.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CDNumDrives" | |
20 HREF="sdlcdnumdrives.html"><META | |
21 NAME="KEYWORD" | |
22 CONTENT="cdrom"><META | |
23 NAME="KEYWORD" | |
24 CONTENT="function"></HEAD | |
25 ><BODY | |
26 CLASS="CHAPTER" | |
27 BGCOLOR="#FFF8DC" | |
28 TEXT="#000000" | |
29 LINK="#0000ee" | |
30 VLINK="#551a8b" | |
31 ALINK="#ff0000" | |
32 ><DIV | |
33 CLASS="NAVHEADER" | |
34 ><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
35 SUMMARY="Header navigation table" |
0 | 36 WIDTH="100%" |
37 BORDER="0" | |
38 CELLPADDING="0" | |
39 CELLSPACING="0" | |
40 ><TR | |
41 ><TH | |
42 COLSPAN="3" | |
43 ALIGN="center" | |
44 >SDL Library Documentation</TH | |
45 ></TR | |
46 ><TR | |
47 ><TD | |
48 WIDTH="10%" | |
49 ALIGN="left" | |
50 VALIGN="bottom" | |
51 ><A | |
52 HREF="sdlcloseaudio.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
53 ACCESSKEY="P" |
0 | 54 >Prev</A |
55 ></TD | |
56 ><TD | |
57 WIDTH="80%" | |
58 ALIGN="center" | |
59 VALIGN="bottom" | |
60 ></TD | |
61 ><TD | |
62 WIDTH="10%" | |
63 ALIGN="right" | |
64 VALIGN="bottom" | |
65 ><A | |
66 HREF="sdlcdnumdrives.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
67 ACCESSKEY="N" |
0 | 68 >Next</A |
69 ></TD | |
70 ></TR | |
71 ></TABLE | |
72 ><HR | |
73 ALIGN="LEFT" | |
74 WIDTH="100%"></DIV | |
75 ><DIV | |
76 CLASS="CHAPTER" | |
77 ><H1 | |
78 ><A | |
79 NAME="CDROM" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
80 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
81 >Chapter 11. CD-ROM</H1 |
0 | 82 ><DIV |
83 CLASS="TOC" | |
84 ><DL | |
85 ><DT | |
86 ><B | |
87 >Table of Contents</B | |
88 ></DT | |
89 ><DT | |
90 ><A | |
91 HREF="sdlcdnumdrives.html" | |
92 >SDL_CDNumDrives</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
93 > -- Returns the number of CD-ROM drives on the system.</DT |
0 | 94 ><DT |
95 ><A | |
96 HREF="sdlcdname.html" | |
97 >SDL_CDName</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
98 > -- Returns a human-readable, system-dependent identifier for the CD-ROM.</DT |
0 | 99 ><DT |
100 ><A | |
101 HREF="sdlcdopen.html" | |
102 >SDL_CDOpen</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
103 > -- Opens a CD-ROM drive for access.</DT |
0 | 104 ><DT |
105 ><A | |
106 HREF="sdlcdstatus.html" | |
107 >SDL_CDStatus</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
108 > -- Returns the current status of the given drive.</DT |
0 | 109 ><DT |
110 ><A | |
111 HREF="sdlcdplay.html" | |
112 >SDL_CDPlay</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
113 > -- Play a CD</DT |
0 | 114 ><DT |
115 ><A | |
116 HREF="sdlcdplaytracks.html" | |
117 >SDL_CDPlayTracks</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
118 > -- Play the given CD track(s)</DT |
0 | 119 ><DT |
120 ><A | |
121 HREF="sdlcdpause.html" | |
122 >SDL_CDPause</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
123 > -- Pauses a CDROM</DT |
0 | 124 ><DT |
125 ><A | |
126 HREF="sdlcdresume.html" | |
127 >SDL_CDResume</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
128 > -- Resumes a CDROM</DT |
0 | 129 ><DT |
130 ><A | |
131 HREF="sdlcdstop.html" | |
132 >SDL_CDStop</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
133 > -- Stops a CDROM</DT |
0 | 134 ><DT |
135 ><A | |
136 HREF="sdlcdeject.html" | |
137 >SDL_CDEject</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
138 > -- Ejects a CDROM</DT |
0 | 139 ><DT |
140 ><A | |
141 HREF="sdlcdclose.html" | |
142 >SDL_CDClose</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
143 > -- Closes a SDL_CD handle</DT |
0 | 144 ><DT |
145 ><A | |
146 HREF="sdlcd.html" | |
147 >SDL_CD</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
148 > -- CDROM Drive Information</DT |
0 | 149 ><DT |
150 ><A | |
151 HREF="sdlcdtrack.html" | |
152 >SDL_CDtrack</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
153 > -- CD Track Information Structure</DT |
0 | 154 ></DL |
155 ></DIV | |
156 ><P | |
157 >SDL supports audio control of up to 32 local CD-ROM drives at once.</P | |
158 ><P | |
159 >You use this API to perform all the basic functions of a CD player, | |
160 including listing the tracks, playing, stopping, and ejecting the CD-ROM. | |
161 (Currently, multi-changer CD drives are not supported.)</P | |
162 ><P | |
163 >Before you call any of the SDL CD-ROM functions, you must first call | |
164 "<TT | |
165 CLASS="FUNCTION" | |
166 >SDL_Init(SDL_INIT_CDROM)</TT | |
167 >", which scans the system for | |
168 CD-ROM drives, and sets the program up for audio control. Check the | |
169 return code, which should be <SPAN | |
170 CLASS="RETURNVALUE" | |
171 >0</SPAN | |
172 >, to see if there | |
173 were any errors in starting up.</P | |
174 ><P | |
175 >After you have initialized the library, you can find out how many drives | |
176 are available using the <TT | |
177 CLASS="FUNCTION" | |
178 >SDL_CDNumDrives()</TT | |
179 > function. | |
180 The first drive listed is the system default CD-ROM drive. After you have | |
181 chosen a drive, and have opened it with <TT | |
182 CLASS="FUNCTION" | |
183 >SDL_CDOpen()</TT | |
184 >, | |
185 you can check the status and start playing if there's a CD in the drive.</P | |
186 ><P | |
187 >A CD-ROM is organized into one or more tracks, each consisting of a certain | |
188 number of "frames". Each frame is ~2K in size, and at normal playing speed, | |
189 a CD plays 75 frames per second. SDL works with the number of frames on a | |
190 CD, but this can easily be converted to the more familiar minutes/seconds | |
191 format by using the <TT | |
192 CLASS="FUNCTION" | |
193 >FRAMES_TO_MSF()</TT | |
194 > macro.</P | |
195 ></DIV | |
196 ><DIV | |
197 CLASS="NAVFOOTER" | |
198 ><HR | |
199 ALIGN="LEFT" | |
200 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
201 SUMMARY="Footer navigation table" |
0 | 202 WIDTH="100%" |
203 BORDER="0" | |
204 CELLPADDING="0" | |
205 CELLSPACING="0" | |
206 ><TR | |
207 ><TD | |
208 WIDTH="33%" | |
209 ALIGN="left" | |
210 VALIGN="top" | |
211 ><A | |
212 HREF="sdlcloseaudio.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
213 ACCESSKEY="P" |
0 | 214 >Prev</A |
215 ></TD | |
216 ><TD | |
217 WIDTH="34%" | |
218 ALIGN="center" | |
219 VALIGN="top" | |
220 ><A | |
221 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
222 ACCESSKEY="H" |
0 | 223 >Home</A |
224 ></TD | |
225 ><TD | |
226 WIDTH="33%" | |
227 ALIGN="right" | |
228 VALIGN="top" | |
229 ><A | |
230 HREF="sdlcdnumdrives.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
231 ACCESSKEY="N" |
0 | 232 >Next</A |
233 ></TD | |
234 ></TR | |
235 ><TR | |
236 ><TD | |
237 WIDTH="33%" | |
238 ALIGN="left" | |
239 VALIGN="top" | |
240 >SDL_CloseAudio</TD | |
241 ><TD | |
242 WIDTH="34%" | |
243 ALIGN="center" | |
244 VALIGN="top" | |
245 ><A | |
246 HREF="reference.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
247 ACCESSKEY="U" |
0 | 248 >Up</A |
249 ></TD | |
250 ><TD | |
251 WIDTH="33%" | |
252 ALIGN="right" | |
253 VALIGN="top" | |
254 >SDL_CDNumDrives</TD | |
255 ></TR | |
256 ></TABLE | |
257 ></DIV | |
258 ></BODY | |
259 ></HTML | |
260 > |