Hello,
I am making a Win/Mac screensaver.
In both platforms, the OS give you the window handle on which you must draw the screensaver.
It seem that on MAC I cannot create a SFML::RenderWindow using the native window handle.
This works Ok on windows.
As this is part of a bigger project, I do not have a minimal project and I am extracting here the code that is on the way of the RenderWindow creation. I hope you see some obvious mistake.
I am using SFML 2.0 / RC 102.
In MAC OSX you create a subclass of ScreenSaverView which is a subclass of NSView
This object is created by the OS.
In the function startAnimation you have the chance to find the window handle by using
NSWindow *windowHandle = [self window];
I eventually pass this handle to my "TmioanCanvasSFML" class.
class TmioanCanvasSFML: public TmioanCanvasAbstract
{
protected:
NativeWindowHandle windowHandle;
sf::RenderWindow sfmlWindow;
public: // constructor
TmioanCanvasSFML(const NativeWindowHandle wHandle):
windowHandle(wHandle),
sfmlWindow(wHandle) // THE ERROR OCCURS HERE, in the initialization list
{
TmioanUtils::DebugLogLn("TmioanCanvasSFML(wHandle) constructor start");
TmioanUtils::DebugLogLn("wHandle:", (long) wHandle);
if (!wHandle)
TmioanUtils::DebugLogLn("Error: TmioanCanvasSFML(wHandle) with NIL wHandle");
};
The native window handle is defined as
#include <Cocoa/Cocoa.h>
// Window handle is NSWindow (void*) on Mac OS X - Cocoa
typedef NSWindow* NativeWindowHandle;
When sfmlWindow(wHandle) is called, I see in the console the error:
memory_pressure: 0memory_pressure: 02012-12-02 20:17:27.906 ScreenSaverEngine[2414:a0f] invalid context
Error. Unable to create the context.
TmioanCanvasSFML(wHandle) constructor start
wHandle: 8590489248
The debugger shows the error in this screenshot.
http://oi45.tinypic.com/2u88jcz.jpgThank you for any ideas on what to search for….
-----------
By the way, I have a suggestion for a new (simple) function for SFML.
sf:getVersion()
Returns the textual version of SFML, eg. "2.0.094"
I want to log this number in the program's logfile that is sent to me by users in case of problems.
I am logging there all parameters of the OS and all available versions of linked libraries.