mirror of
https://github.com/SFML/SFML.git
synced 2025-02-12 19:38:09 +08:00
Add support for external window handling (NSView + NSWindow) (bis)
This commit is contained in:
parent
284bd09709
commit
9c07503350
@ -68,6 +68,8 @@ else() # MACOSX
|
|||||||
${SRCROOT}/OSX/SFWindow.m
|
${SRCROOT}/OSX/SFWindow.m
|
||||||
${SRCROOT}/OSX/SFWindowController.h
|
${SRCROOT}/OSX/SFWindowController.h
|
||||||
${SRCROOT}/OSX/SFWindowController.mm
|
${SRCROOT}/OSX/SFWindowController.mm
|
||||||
|
${SRCROOT}/OSX/SFViewController.h
|
||||||
|
${SRCROOT}/OSX/SFViewController.mm
|
||||||
${SRCROOT}/OSX/VideoModeImpl.cpp
|
${SRCROOT}/OSX/VideoModeImpl.cpp
|
||||||
${SRCROOT}/OSX/WindowImplCocoa.hpp
|
${SRCROOT}/OSX/WindowImplCocoa.hpp
|
||||||
${SRCROOT}/OSX/WindowImplCocoa.mm
|
${SRCROOT}/OSX/WindowImplCocoa.mm
|
||||||
|
@ -55,7 +55,7 @@ SFContext::SFContext(SFContext* shared)
|
|||||||
myPool = [[NSAutoreleasePool alloc] init];
|
myPool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
CreateContext(shared, 0, ContextSettings(0, 0, 0));
|
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));
|
||||||
|
|
||||||
// Activate the context
|
// Activate the context
|
||||||
SetActive(true);
|
SetActive(true);
|
||||||
@ -83,6 +83,7 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner,
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext::~SFContext()
|
SFContext::~SFContext()
|
||||||
{
|
{
|
||||||
|
[myContext clearDrawable];
|
||||||
[myContext release];
|
[myContext release];
|
||||||
[myPool drain]; // [A]
|
[myPool drain]; // [A]
|
||||||
|
|
||||||
|
@ -88,14 +88,14 @@
|
|||||||
|
|
||||||
sf::Err()
|
sf::Err()
|
||||||
<< "Could not create an instance of NSOpenGLView "
|
<< "Could not create an instance of NSOpenGLView "
|
||||||
<< "in (SFWindowController -initWithMode:andStyle:)."
|
<< "in (SFWindowController -initWithWindow:)."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the view to the window as its content view.
|
// Set the view to the window as its content view.
|
||||||
[myWindow setContentView:myOGLView];
|
[[myWindow contentView] addSubview:myOGLView];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -434,7 +434,7 @@
|
|||||||
* for more information.
|
* for more information.
|
||||||
*/
|
*/
|
||||||
sf::Err()
|
sf::Err()
|
||||||
<< "Cannot fetch event from a worker thread. (OS X limitation)"
|
<< "Cannot fetch event from a worker thread. (OS X restriction)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
#include <SFML/System/Err.hpp>
|
#include <SFML/System/Err.hpp>
|
||||||
|
|
||||||
#import <SFML/Window/OSX/SFWindowController.h>
|
#import <SFML/Window/OSX/SFWindowController.h>
|
||||||
//#import <SFML/Window/OSX/SFViewController.h>
|
#import <SFML/Window/OSX/SFViewController.h>
|
||||||
#warning SFViewController not yet implemented.
|
|
||||||
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -45,9 +44,6 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
||||||
{
|
{
|
||||||
sf::Err() << "Not yet fully supported." << std::endl;
|
|
||||||
#warning WindowImplCocoa(WindowHandle handle) not yet fully implemented
|
|
||||||
|
|
||||||
SetUpPoolAndApplication();
|
SetUpPoolAndApplication();
|
||||||
|
|
||||||
// Treat the handle as it real type
|
// Treat the handle as it real type
|
||||||
@ -57,12 +53,20 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
|||||||
// We have a window.
|
// We have a window.
|
||||||
myDelegate = [[SFWindowController alloc] initWithWindow:nsHandle];
|
myDelegate = [[SFWindowController alloc] initWithWindow:nsHandle];
|
||||||
|
|
||||||
} /*else if ([nsHandle isKindOfClass:[NSView class]]) {
|
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||||
|
myWidth = [[nsHandle contentView] frame].size.width;
|
||||||
|
myHeight = [[nsHandle contentView] frame].size.height;
|
||||||
|
|
||||||
|
} else if ([nsHandle isKindOfClass:[NSView class]]) {
|
||||||
|
|
||||||
// We have a view.
|
// We have a view.
|
||||||
myDelegate = [[SFViewController alloc] initWithView:nsHandle];
|
myDelegate = [[SFViewController alloc] initWithView:nsHandle];
|
||||||
|
|
||||||
} */ else {
|
// Don't forget to update our parent (that is, WindowImpl) size :
|
||||||
|
myWidth = [nsHandle frame].size.width;
|
||||||
|
myHeight = [nsHandle frame].size.height;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
sf::Err()
|
sf::Err()
|
||||||
<< "Cannot import this Window Handle because it is neither "
|
<< "Cannot import this Window Handle because it is neither "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user