Mercurial > sdl-ios-xcode
annotate src/hermes/HeadMMX.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 | 74212992fb08 |
children | bb5ace455586 |
rev | line source |
---|---|
0 | 1 /* |
2 Header definitions for the MMX routines for the HERMES library | |
3 Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk) | |
4 This source code is licensed under the GNU LGPL | |
5 | |
6 Please refer to the file COPYING.LIB contained in the distribution for | |
7 licensing conditions | |
8 */ | |
9 | |
10 #ifndef __HERMES_HEAD_MMX__ | |
11 #define __HERMES_HEAD_MMX__ | |
12 | |
13 | |
14 /* If you cannot stand ifdefs, then please do not look into this file, it's | |
15 going to end your life :) */ | |
16 | |
17 #ifdef X86_ASSEMBLER | |
18 | |
19 | |
20 #ifdef __cplusplus | |
21 extern "C" { | |
22 #endif | |
23 | |
24 void STACKCALL ConvertMMX(HermesConverterInterface *); | |
25 | |
26 void STACKCALL ClearMMX_32(HermesClearInterface *); | |
27 void STACKCALL ClearMMX_24(HermesClearInterface *); | |
28 void STACKCALL ClearMMX_16(HermesClearInterface *); | |
29 void STACKCALL ClearMMX_8(HermesClearInterface *); | |
30 | |
31 void ConvertMMXpII32_24RGB888(); | |
32 void ConvertMMXpII32_16RGB565(); | |
33 void ConvertMMXpII32_16BGR565(); | |
34 void ConvertMMXpII32_16RGB555(); | |
35 void ConvertMMXpII32_16BGR565(); | |
36 void ConvertMMXpII32_16BGR555(); | |
37 | |
38 void ConvertMMXp32_16RGB555(); | |
39 | |
40 #ifdef __cplusplus | |
41 } | |
42 #endif | |
43 | |
44 | |
45 | |
46 /* Fix the underscore business with ELF compilers */ | |
47 | |
48 #if defined(__ELF__) && defined(__GNUC__) | |
49 #ifdef __cplusplus | |
50 extern "C" { | |
51 #endif | |
52 | |
53 void ConvertMMX(HermesConverterInterface *) __attribute__ ((alias ("_ConvertMMX"))); | |
54 #if 0 | |
55 void ClearMMX_32(HermesClearInterface *) __attribute__ ((alias ("_ClearMMX_32"))); | |
56 void ClearMMX_24(HermesClearInterface *) __attribute__ ((alias ("_ClearMMX_24"))); | |
57 void ClearMMX_16(HermesClearInterface *) __attribute__ ((alias ("_ClearMMX_16"))); | |
58 void ClearMMX_8(HermesClearInterface *) __attribute__ ((alias ("_ClearMMX_8"))); | |
59 | |
60 void ConvertMMXp32_16RGB555() __attribute__ ((alias ("_ConvertMMXp32_16RGB555"))); | |
61 #endif | |
62 | |
63 void ConvertMMXpII32_24RGB888() __attribute__ ((alias ("_ConvertMMXpII32_24RGB888"))); | |
64 void ConvertMMXpII32_16RGB565() __attribute__ ((alias ("_ConvertMMXpII32_16RGB565"))); | |
65 void ConvertMMXpII32_16BGR565() __attribute__ ((alias ("_ConvertMMXpII32_16BGR565"))); | |
66 void ConvertMMXpII32_16RGB555() __attribute__ ((alias ("_ConvertMMXpII32_16RGB555"))); | |
67 void ConvertMMXpII32_16BGR555() __attribute__ ((alias ("_ConvertMMXpII32_16BGR555"))); | |
68 | |
69 #ifdef __cplusplus | |
70 } | |
71 #endif | |
72 | |
73 #endif /* ELF and GNUC */ | |
74 | |
75 | |
76 | |
77 | |
78 /* Make it work with Watcom */ | |
79 #ifdef __WATCOMC__ | |
80 #pragma warning 601 9 | |
81 | |
82 #pragma aux ConvertMMX "_*" modify [EAX EBX ECX EDX ESI EDI] | |
83 | |
84 #pragma aux ClearMMX_32 "_*" modify [EAX EBX ECX EDX ESI EDI] | |
85 #pragma aux ClearMMX_24 "_*" modify [EAX EBX ECX EDX ESI EDI] | |
86 #pragma aux ClearMMX_16 "_*" modify [EAX EBX ECX EDX ESI EDI] | |
87 #pragma aux ClearMMX_8 "_*" modify [EAX EBX ECX EDX ESI EDI] | |
88 | |
89 #pragma aux ConvertMMXpII32_24RGB888 "_*" | |
90 #pragma aux ConvertMMXpII32_16RGB565 "_*" | |
91 #pragma aux ConvertMMXpII32_16BGR565 "_*" | |
92 #pragma aux ConvertMMXpII32_16RGB555 "_*" | |
93 #pragma aux ConvertMMXpII32_16BGR555 "_*" | |
94 #pragma aux ConvertMMXp32_16RGB555 "_*" | |
95 | |
96 #endif /* WATCOM */ | |
97 | |
98 #endif /* X86_ASSEMBLER */ | |
99 | |
100 | |
101 #endif |