mirror of
https://github.com/glfw/glfw.git
synced 2025-06-08 00:34:56 +00:00
Merge 2771b709ea
into 6b57e08bb0
This commit is contained in:
commit
7b2fe69345
@ -46,6 +46,8 @@ cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on
|
|||||||
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
||||||
"MSVC" OFF)
|
"MSVC" OFF)
|
||||||
|
|
||||||
|
cmake_dependent_option(GLFW_USE_METALKIT "Allow GLFW to include MetalKit.h for metal support" OFF GLFW_BUILD_COCOA ON)
|
||||||
|
|
||||||
set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
|
set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
|
||||||
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
|
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
|
||||||
|
|
||||||
|
@ -121,6 +121,9 @@ information on what to include when reporting a bug.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
- Added `GLFW_USE_METALKIT` to cmake build options to make metal support optional
|
||||||
|
- [Cocoa] Added `glfwResetCocoaMTKFramesize` function for metal view resizing
|
||||||
|
- [Cocoa] 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
|
||||||
|
@ -281,6 +281,34 @@ 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);
|
||||||
|
|
||||||
|
|
||||||
|
/*! @brief Resizes an 'MTKView' to the window's framebuffer size -helpful because the Apple metal-cpp API lacks the ability to do this
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @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 glfwResetCocoaMTKFramesize(GLFWwindow* window, void* view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
@ -31,6 +31,9 @@ set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
|||||||
|
|
||||||
if (GLFW_BUILD_COCOA)
|
if (GLFW_BUILD_COCOA)
|
||||||
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
|
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
|
||||||
|
if(GLFW_USE_METALKIT)
|
||||||
|
target_compile_definitions(glfw PRIVATE _GLFW_BUILD_METAL_DEPENDENCIES)
|
||||||
|
endif()
|
||||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
|
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
|
||||||
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
|
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
|
||||||
nsgl_context.m)
|
nsgl_context.m)
|
||||||
@ -161,6 +164,15 @@ if (GLFW_BUILD_COCOA)
|
|||||||
"-framework IOKit"
|
"-framework IOKit"
|
||||||
"-framework CoreFoundation")
|
"-framework CoreFoundation")
|
||||||
|
|
||||||
|
if(GLFW_USE_METALKIT)
|
||||||
|
|
||||||
|
target_link_libraries(glfw PRIVATE "-framework Metal"
|
||||||
|
"-framework MetalKit")
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(glfw_PKG_DEPS "")
|
set(glfw_PKG_DEPS "")
|
||||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||||
endif()
|
endif()
|
||||||
|
@ -259,6 +259,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->ns.height = contentRect.size.height;
|
window->ns.height = contentRect.size.height;
|
||||||
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification
|
- (void)windowDidMove:(NSNotification *)notification
|
||||||
@ -346,6 +347,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
[self updateTrackingAreas];
|
[self updateTrackingAreas];
|
||||||
[self registerForDraggedTypes:@[NSPasteboardTypeURL]];
|
[self registerForDraggedTypes:@[NSPasteboardTypeURL]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -2047,3 +2049,64 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
|||||||
return window->ns.object;
|
return window->ns.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _GLFW_BUILD_METAL_DEPENDENCIES
|
||||||
|
#import <MetalKit/MetalKit.h>
|
||||||
|
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];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwResetCocoaMTKFramesize(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
MTKView* mtkView = (MTKView*) view;
|
||||||
|
int width, height;
|
||||||
|
_glfwGetFramebufferSizeCocoa(window, &width, &height);
|
||||||
|
NSSize size = NSMakeSize(width, height);
|
||||||
|
[mtkView setFrameSize: size];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
GLFWAPI void glfwAddCocoaMTKSubview(GLFWwindow* handle, void* view) {
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN();
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"GLFW was compiled without \"GLFW_USE_METALKIT\" enabled");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwResetCocoaMTKFramesize(GLFWwindow* handle, void* view) {
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN();
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"GLFW was compiled without \"GLFW_USE_METALKIT\" enabled");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user