Re: Converting mouse coordinates in fullscreen context?
Re: Converting mouse coordinates in fullscreen context?
- Subject: Re: Converting mouse coordinates in fullscreen context?
- From: "Timothy J. Wood" <email@hidden>
- Date: Tue, 25 Feb 2003 18:52:00 -0800
Please note that this code is for some ancient version of OS X :)
It really needs updating, so feel free to gather info from it, but be
warned that things have moved on a bit since then (like you can use HID
for mouse and keyboard now, etc)
-tim
On Tuesday, February 25, 2003, at 06:49 AM, publiclook wrote:
See the Omni examples of exactly what you want to do at
http://www.omnigroup.com/developer/gamedevelopment/gdc2001/
On Tuesday, February 25, 2003, at 12:59 AM, arekkusu wrote:
(I posted this to mac-opengl last week, no replies. So cross-posting
to
this list now in hopes of more eyes looking at it...)
I need to get the mouse coordinates in a fullscreen game context.
Unrelated factors (minification, etc) have steered my event handling
approach to:
1) controller is subclass of NSResponder, and implements mouseDown:
etc
for normal windowed mode.
2) window is created programatically and has the controller as
nextResponder during windowed mode (for keystroke handling.)
3) window's first responder is swapped to the controller when in
fullscreen mode, so all events (escape key, mouse) are caught. The
event handler just passes relevant events to the normal mouseDown: etc
handlers.
Here's my problem: in windowed mode I am getting sensible mouse
coordinates via:
- (void) mouseDown:(NSEvent*)event{
NSPoint loc = [viewport convertPoint:[event locationInWindow]
fromView:nil];
NSLog(@"mouse down (%@): (%f, %f)", event, loc.x, loc.y);
}
e.g. from (0,0) to (639,399) in a 640x400 window (although the resize
widget obscures one corner, as expected.)
But, in a fullscreen context, 896x600 for example, the same function
reports mouse coordinates from (0, -454) to (895, 145).
The vertical coordinates change depending on how big the (windowed
mode) window is, but they always include some negative values.
Looking at the event, winNum is changing each time I enter fullscreen
mode; I guess it's a temporary shielding window CG creates? How can I
get the fullscreen window's coordinate system to make sense?
My view returns YES for isFlipped, if that makes any difference. The
coordinates are totally screwed up when my fullscreen context is on a
second display; they look more like global coordinates, as if
convertPoint: hasn't done anything. Is convertPoint: just broken with
fullscreen contexts? I'll gladly log a bug unless somebody shows me
what I'm doing wrong...
thanks,
-alex
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.