OSX, fixed mouse pos in event.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1771 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
mantognini 2011-01-20 13:04:25 +00:00
parent bef6b3bbf6
commit f9c4740894
4 changed files with 24 additions and 20 deletions

View File

@ -79,7 +79,7 @@ public:
///
////////////////////////////////////////////////////////////
SFContext(SFContext* shared, const WindowImpl* owner,
unsigned int bitsPerPixel, const ContextSettings& settings);
unsigned int bitsPerPixel, const ContextSettings& settings);
////////////////////////////////////////////////////////////
/// \brief Destructor
@ -127,13 +127,13 @@ private:
///
////////////////////////////////////////////////////////////
void CreateContext(SFContext* shared,
const ContextSettings& settings,
unsigned int bitsPerPixel);
const ContextSettings& settings,
unsigned int bitsPerPixel);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
NSOpenGLContextRef myContext; ///< OpenGL context
NSOpenGLContextRef myContext; ///< OpenGL context
NSAutoreleasePoolRef myPool; ///< Memory manager for this class.
};

View File

@ -62,7 +62,7 @@ SFContext::SFContext(SFContext* shared)
////////////////////////////////////////////////////////////
SFContext::SFContext(SFContext* shared, const WindowImpl* owner,
unsigned int bitsPerPixel, const ContextSettings& settings)
unsigned int bitsPerPixel, const ContextSettings& settings)
{
myPool = [[NSAutoreleasePool alloc] init];
@ -79,7 +79,11 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner,
SFContext::~SFContext()
{
[myContext release];
[myPool release];
[myPool drain]; // [1]
/*
[1] : Produce sometimes "*** attempt to pop an unknown autorelease pool"
*/
}
@ -114,8 +118,8 @@ void SFContext::EnableVerticalSync(bool enabled)
////////////////////////////////////////////////////////////
void SFContext::CreateContext(SFContext* shared,
const ContextSettings& settings,
unsigned int bitsPerPixel)
const ContextSettings& settings,
unsigned int bitsPerPixel)
{
// Choose the attributs of OGL context.
std::vector<NSOpenGLPixelFormatAttribute> attrs;
@ -163,7 +167,7 @@ void SFContext::CreateContext(SFContext* shared,
// Create the context.
myContext = [[NSOpenGLContext alloc] initWithFormat:pixFmt
shareContext:sharedContext];
shareContext:sharedContext];
// Free up.
[pixFmt release];

View File

@ -160,7 +160,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseDownAt(sf::Mouse::Left, loc.x, h - loc.y);
}
@ -172,7 +172,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseUpAt(sf::Mouse::Left, loc.x, h - loc.y);
}
@ -199,7 +199,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, h - loc.y);
}
@ -233,7 +233,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseDownAt(sf::Mouse::Right, loc.x, h - loc.y);
}
@ -245,7 +245,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseUpAt(sf::Mouse::Right, loc.x, h - loc.y);
}
@ -271,7 +271,7 @@
break;
}
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseDownAt(button, loc.x, h - loc.y);
}
@ -297,7 +297,7 @@
break;
}
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseUpAt(button, loc.x, h - loc.y);
}
@ -312,7 +312,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseMovedAt(loc.x, h - loc.y);
}
@ -327,7 +327,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseMovedAt(loc.x, h - loc.y);
}
@ -342,7 +342,7 @@
NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
// Don't forget to change to SFML coord system.
float h = [[theEvent window] frame].size.height;
float h = [self frame].size.height;
myRequester->MouseMovedAt(loc.x, h - loc.y);
}

View File

@ -104,7 +104,7 @@ WindowImplCocoa::~WindowImplCocoa()
[myDelegate closeWindow];
[myDelegate release];
[myPool release];
[myPool drain];
}