mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Forbid window creating and event fetching from worker thread as it's an OS X limitation.
Fix context not activated when created (now shader and renderimage works without having to creat a window or a context explicitly). git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1800 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
4813ca8d8e
commit
73370dc178
@ -49,10 +49,10 @@
|
||||
}
|
||||
|
||||
// If there are some other event read them.
|
||||
while (event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:[NSDate distantPast]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES]) // Remove the event from the dequeue
|
||||
while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
untilDate:[NSDate distantPast]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES])) // Remove the event from the dequeue
|
||||
{
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
||||
/*
|
||||
* DISCUSSION :
|
||||
* ============
|
||||
@ -57,6 +56,9 @@ SFContext::SFContext(SFContext* shared)
|
||||
|
||||
// Create the context
|
||||
CreateContext(shared, 0, ContextSettings(0, 0, 0));
|
||||
|
||||
// Activate the context
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
@ -72,6 +74,9 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner,
|
||||
// Apply context.
|
||||
WindowImplCocoa const * ownerCocoa = static_cast<WindowImplCocoa const *>(owner);
|
||||
ownerCocoa->ApplyContext(myContext);
|
||||
|
||||
// Activate the context
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
@ -106,12 +111,12 @@ void SFContext::Display()
|
||||
void SFContext::EnableVerticalSync(bool enabled)
|
||||
{
|
||||
// Make compiler happy
|
||||
#ifdef USE_OS_X_VERSION_10_4
|
||||
long int swapInterval = enabled ? 1 : 0;
|
||||
#else /* USE_OS_X_VERSION_10_6 */
|
||||
GLint swapInterval = enabled ? 1 : 0;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
typedef int GLint;
|
||||
#endif
|
||||
|
||||
GLint swapInterval = enabled ? 1 : 0;
|
||||
|
||||
[myContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,19 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(id)initWithMode:(sf::VideoMode const &)mode andStyle:(unsigned long)style
|
||||
{
|
||||
// If we are not on the main thread we stop here and advice the user.
|
||||
if ([NSThread currentThread] != [NSThread mainThread]) {
|
||||
/*
|
||||
* See http://lists.apple.com/archives/cocoa-dev/2011/Feb/msg00460.html
|
||||
* for more information.
|
||||
*/
|
||||
sf::Err()
|
||||
<< "Cannot create a window from a worker thread. (OS X limitation)"
|
||||
<< std::endl;
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((self = [super init])) {
|
||||
myRequester = 0;
|
||||
|
||||
@ -414,6 +427,19 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)processEventWithBlockingMode:(BOOL)block
|
||||
{
|
||||
// If we are not on the main thread we stop here and advice the user.
|
||||
if ([NSThread currentThread] != [NSThread mainThread]) {
|
||||
/*
|
||||
* See http://lists.apple.com/archives/cocoa-dev/2011/Feb/msg00460.html
|
||||
* for more information.
|
||||
*/
|
||||
sf::Err()
|
||||
<< "Cannot fetch event from a worker thread. (OS X limitation)"
|
||||
<< std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we don't have a requester we don't fetch event.
|
||||
if (myRequester != 0) {
|
||||
[SFApplication processEventWithBlockingMode:block];
|
||||
|
Loading…
Reference in New Issue
Block a user