Mercurial > sdl-ios-xcode
annotate src/cdrom/macos/SDL_syscdrom_c.h @ 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 | b8d311d90021 |
children | d910939febfa |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* This is the MacOS specific header for the SDL CD-ROM API | |
24 Contributed by Matt Slot | |
25 */ | |
26 | |
27 /* AppleCD Control calls */ | |
28 #define kVerifyTheDisc 5 /* Returns noErr if there is disc inserted */ | |
29 #define kEjectTheDisc 7 /* Eject disc from drive */ | |
30 #define kUserEject 80 /* Enable/disable the CD-ROM eject button */ | |
31 #define kReadTOC 100 /* Extract various TOC information from the disc */ | |
32 #define kReadQ 101 /* Extract Q subcode info for the current track */ | |
33 #define kAudioTrackSearch 103 /* Start playback from the indicated position */ | |
34 #define kAudioPlay 104 /* Start playback from the indicated position */ | |
35 #define kAudioPause 105 /* Pause/continue the playback */ | |
36 #define kAudioStop 106 /* Stop playback at the indicated position */ | |
37 #define kAudioStatus 107 /* Return audio play status */ | |
38 #define kAudioControl 109 /* Set the output volume for the audio channels */ | |
39 #define kReadAudioVolume 112 /* Get the output volume for the audio channels */ | |
40 #define kSetTrackList 122 /* Set the track program for the audio CD to play */ | |
41 #define kGetTrackList 123 /* Get the track program the audio CD is playing */ | |
42 #define kGetTrackIndex 124 /* Get the track index the audio CD is playing */ | |
43 #define kSetPlayMode 125 /* Set the audio tracks play mode */ | |
44 #define kGetPlayMode 126 /* Get the audio tracks play mode */ | |
45 | |
46 /* AppleCD Status calls */ | |
47 #define kGetDriveType 96 /* Get the type of the physical CD-ROM drive */ | |
48 #define kWhoIsThere 97 /* Get a bitmap of SCSI IDs the driver controls */ | |
49 #define kGetBlockSize 98 /* Get current block size of the CD-ROM drive */ | |
50 | |
51 /* AppleCD other constants */ | |
52 #define kBlockPosition 0 /* Position at the specified logical block number */ | |
53 #define kAbsMSFPosition 1 /* Position at the specified Min/Sec/Frame (in BCD) */ | |
54 #define kTrackPosition 2 /* Position at the specified track number (in BCD) */ | |
55 #define kIndexPosition 3 /* Position at the nth track in program (in BCD) */ | |
56 | |
57 #define kMutedPlayMode 0 /* Play the audio track with no output */ | |
58 #define kStereoPlayMode 9 /* Play the audio track in normal stereo */ | |
59 | |
60 #define kControlFieldMask 0x0D /* Bits 3,2,0 in the nibble */ | |
61 #define kDataTrackMask 0x04 /* Indicates Data Track */ | |
62 | |
63 #define kGetTrackRange 1 /* Query TOC for track numbers */ | |
64 #define kGetLeadOutArea 2 /* Query TOC for "Lead Out" end of audio data */ | |
65 #define kGetTrackEntries 3 /* Query TOC for track starts and data types */ | |
66 | |
67 #define kStatusPlaying 0 /* Audio Play operation in progress */ | |
68 #define kStatusPaused 1 /* CD-ROM device in Hold Track ("Pause") state */ | |
69 #define kStatusMuted 2 /* MUTING-ON operation in progress */ | |
70 #define kStatusDone 3 /* Audio Play completed */ | |
71 #define kStatusError 4 /* Error occurred during audio play operation */ | |
72 #define kStatusStopped 5 /* Audio play operation not requested */ | |
73 | |
74 #define kPlayModeSequential 0 /* Play tracks in order */ | |
75 #define kPlayModeShuffled 1 /* Play tracks randomly */ | |
76 #define kPlayModeProgrammed 2 /* Use custom playlist */ | |
77 | |
78 /* AppleCD Gestalt selectors */ | |
79 #define kGestaltAudioCDSelector 'aucd' | |
80 #define kDriverVersion52 0x00000520 | |
81 #define kDriverVersion51 0x00000510 | |
82 #define kDriverVersion50 0x00000500 | |
83 | |
84 /* Drive type constants */ | |
85 #define kDriveAppleCD_SC 1 | |
86 #define kDriveAppleCD_SCPlus_or_150 2 | |
87 #define kDriveAppleCD_300_or_300Plus 3 | |
88 | |
89 /* Misc constants */ | |
90 #define kFirstSCSIDevice -33 | |
91 #define kLastSCSIDevice -40 | |
92 | |
93 #if PRAGMA_STRUCT_ALIGN | |
94 #pragma options align=mac68k | |
95 #endif | |
96 | |
97 /* AppleCD driver parameter block */ | |
98 typedef struct CDCntrlParam { | |
99 QElemPtr qLink; | |
100 short qType; | |
101 short ioTrap; | |
102 Ptr ioCmdAddr; | |
103 IOCompletionUPP ioCompletion; | |
104 OSErr ioResult; | |
105 StringPtr ioNamePtr; | |
106 short ioVRefNum; | |
107 short ioCRefNum; | |
108 short csCode; | |
109 | |
110 union { | |
111 long longs[6]; | |
112 short words[11]; | |
113 unsigned char bytes[22]; | |
114 struct { | |
115 unsigned char status; | |
116 unsigned char play; | |
117 unsigned char control; | |
118 unsigned char minute; | |
119 unsigned char second; | |
120 unsigned char frame; | |
121 } cd; | |
122 } csParam; | |
123 | |
124 } CDCntrlParam, *CDCntrlParamPtr; | |
125 | |
126 typedef union CDTrackData { | |
127 long value; /* Treat as a longword value */ | |
128 struct { | |
129 unsigned char reserved : 4; /* Unused by AppleCD driver */ | |
130 unsigned char control : 4; /* Track flags (data track?) */ | |
131 unsigned char min; /* Start of track (BCD) */ | |
132 unsigned char sec; /* Start of track (BCD) */ | |
133 unsigned char frame; /* Start of track (BCD) */ | |
134 } entry; /* Broken into fields */ | |
135 } CDTrackData, *CDTrackPtr; | |
136 | |
137 #if PRAGMA_STRUCT_ALIGN | |
138 #pragma options align=reset | |
139 #endif |