No subject


Wed Jan 24 21:54:03 PST 2007


known that Quartz follows the convention with the
bottom-left coordinate at (0,0), but it seems to be
acting inconsistently between the windowed 2D and 3D
modes. Looking at the source, for the windowed code,
it seems to follow all one path so I don't know why it
would be flipped in one case. I don't know the Apple
API's (Cocoa, CoreGraphics, etc), but I might
speculate that maybe mixing NS and CG calls might have
accidentally led to the inconsistency, but that's pure
speculation and I might be just as inclined to call it
an Apple bug. Somebody more knowledgeable with Cocoa
might want to investigate this further.

For the meantime, attached is a workaround patch that
should reinvert the coordinates for this one case.
This fixed all my simple cases and my own programs,
but somebody might want to check to see if this fix
needs to be applied in other places of the source code
for SDL functions I didn't test.

Thanks,
Eric

--0-1943710500-1079510349=:80254
Content-Type: text/plain; name="SDL_QuartzMouseFix.patch"
Content-Description: SDL_QuartzMouseFix.patch
Content-Disposition: inline; filename="SDL_QuartzMouseFix.patch"

Index: src/video/quartz/SDL_QuartzWM.m
===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
retrieving revision 1.19
diff -p -u -r1.19 SDL_QuartzWM.m
--- src/video/quartz/SDL_QuartzWM.m	7 Jan 2004 15:01:51 -0000	1.19
+++ src/video/quartz/SDL_QuartzWM.m	17 Mar 2004 06:09:39 -0000
@@ -161,6 +161,17 @@ void QZ_PrivateCocoaToSDL (_THIS, NSPoin
         newPoint = [ window_view convertPoint:*p fromView:[ qz_window contentView ] ];
         
         *p = newPoint;
+
+        /* 
+         * For a reason I can't explain, the y-coordinates returned for 
+         * a windowed OpenGL context are inverted compared to all 
+         * other modes (OpenGL fullscreen, SDL2D fullscreen, SDL2D windowed).
+         * To workaround this issue, the coordinate must be inverted by
+         * the window height.
+         */
+        if( SDL_VideoSurface->flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
+            p->y = [window_view frame].size.height - p->y - 1;
+        }
     }
 }
 

--0-1943710500-1079510349=:80254--




More information about the SDL mailing list