Implement CGLPlatform using CGL and NSOpenGLContext

* On replay on macOS we use NSOpenGLContext so we can render to windows.
* We have two windowing systems on mac - one for Metal compatible outputs and
  one for OpenGL compatible outputs.
This commit is contained in:
baldurk
2019-02-13 18:50:54 +00:00
parent 69c668c27c
commit fe0be58908
20 changed files with 375 additions and 57 deletions
+10 -5
View File
@@ -331,7 +331,8 @@ DOCUMENT(R"(Specifies a windowing system to use for creating an output window.
.. data:: MacOS
The windowing data refers to a MacOS / OS X CALayer. See :func:`CreateMacOSWindowingData`.
The windowing data refers to a MacOS / OS X NSView & CALayer that is Metal/GL compatible.
See :func:`CreateMacOSWindowingData`.
)");
enum class WindowingSystem : uint32_t
{
@@ -403,6 +404,7 @@ struct WindowingData
struct
{
void *view;
void *layer;
} macOS;
};
@@ -494,18 +496,21 @@ inline const WindowingData CreateAndroidWindowingData(ANativeWindow *window)
return ret;
}
DOCUMENT(R"(Create a :class:`WindowingData` for an macOS ``CALayer`` handle (as void pointer).
DOCUMENT(R"(Create a :class:`WindowingData` for an metal/opengl-compatible macOS ``CALayer`` handle
and ``NSView`` handle (as void pointers).
:param CALayer window: The native ``CALayer`` handle for this window.
:param NSView view: The native ``NSView`` handle for this window.
:param CALayer layer: The native ``CALayer`` handle for this window.
:return: A :class:`WindowingData` corresponding to the given window.
:rtype: WindowingData
)");
inline const WindowingData CreateMacOSWindowingData(void *view)
inline const WindowingData CreateMacOSWindowingData(void *view, void *layer)
{
WindowingData ret = {};
ret.system = WindowingSystem::MacOS;
ret.macOS.layer = view;
ret.macOS.view = view;
ret.macOS.layer = layer;
return ret;
}
+15
View File
@@ -54,6 +54,21 @@ std::string DoStringise(const ReplayStatus &el)
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const WindowingSystem &el)
{
BEGIN_ENUM_STRINGISE(WindowingSystem)
{
STRINGISE_ENUM_CLASS(Unknown);
STRINGISE_ENUM_CLASS(Win32);
STRINGISE_ENUM_CLASS(Xlib);
STRINGISE_ENUM_CLASS(XCB);
STRINGISE_ENUM_CLASS(Android);
STRINGISE_ENUM_CLASS(MacOS);
}
END_ENUM_STRINGISE();
}
template <>
std::string DoStringise(const ResourceFormatType &el)
{