mirror of
https://github.com/glfw/glfw.git
synced 2025-04-20 23:52:51 +00:00
feat: Add new glfwAddCocoaMTKSubview function
this new function allows glfw to better interface with Apple's metal API. Before one had to directly interface with the native cocoa window and replace GLFW's content view. Thus removing GLFW's ability to detect input from the window. Now this function gives user's the ability to add a Metal MTKView as a "subview" which allows the default glfw window view to still capture input while also displaying a Metal view.
This commit is contained in:
parent
d3ede7b684
commit
fee0e530aa
@ -121,6 +121,7 @@ information on what to include when reporting a bug.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
- Added `glfwAddCocoaMTKSubview` function for better metal support
|
||||||
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
||||||
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||||
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||||
|
@ -275,6 +275,20 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
|||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Adds an 'MTKView' to the window's main NSView as a subview
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety Call this function from the main thread.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwAddCocoaMTKSubview(GLFWwindow* window, void* view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#import <MetalKit/MetalKit.h>
|
||||||
|
|
||||||
// Returns the style mask corresponding to the window settings
|
// Returns the style mask corresponding to the window settings
|
||||||
//
|
//
|
||||||
@ -1950,3 +1951,20 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
|||||||
return window->ns.object;
|
return window->ns.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwAddCocoaMTKSubview(GLFWwindow* handle, void* view) {
|
||||||
|
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN();
|
||||||
|
|
||||||
|
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||||
|
"Cocoa: Platform not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[window->ns.view addSubview: (MTKView*) view];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user