Enable Metal by default on SDL backend
This commit is contained in:
parent
aa33bb6bf9
commit
93c2639539
2 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,11 @@
|
||||||
include(../../cmake/AddPlatformExecutable.cmake)
|
include(../../cmake/AddPlatformExecutable.cmake)
|
||||||
|
|
||||||
|
if(ENABLE_MACOS)
|
||||||
|
find_library(METAL Metal)
|
||||||
|
|
||||||
|
set(EXTRA_LIBRARIES ${METAL})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_platform(
|
add_platform(
|
||||||
SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
|
SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
|
||||||
MAIN_FILE
|
MAIN_FILE
|
||||||
|
@ -12,6 +18,7 @@ add_platform(
|
||||||
Core
|
Core
|
||||||
GFXVulkan
|
GFXVulkan
|
||||||
GFXMetal
|
GFXMetal
|
||||||
|
${EXTRA_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
function(add_platform_commands target)
|
function(add_platform_commands target)
|
||||||
|
|
|
@ -87,7 +87,11 @@ bool platform::supports_feature(const PlatformFeature feature) {
|
||||||
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||||
auto& win = windows.emplace_back();
|
auto& win = windows.emplace_back();
|
||||||
|
|
||||||
int sdl_flags = SDL_WINDOW_VULKAN | SDL_WINDOW_ALLOW_HIGHDPI;
|
int sdl_flags = SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
#ifndef ENABLE_METAL
|
||||||
|
sdl_flags |= SDL_WINDOW_VULKAN;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(flags & WindowFlags::Borderless)
|
if(flags & WindowFlags::Borderless)
|
||||||
sdl_flags |= SDL_WINDOW_BORDERLESS;
|
sdl_flags |= SDL_WINDOW_BORDERLESS;
|
||||||
|
|
||||||
|
@ -299,6 +303,10 @@ void platform::end_text_input() {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
|
||||||
|
|
||||||
|
#ifdef ENABLE_METAL
|
||||||
|
SDL_setenv("METAL_DEVICE_WRAPPER_TYPE", "1", 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
engine = new prism::engine(argc, argv);
|
engine = new prism::engine(argc, argv);
|
||||||
|
|
||||||
app = new @APP_CLASS@();
|
app = new @APP_CLASS@();
|
||||||
|
@ -306,7 +314,11 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
GFXCreateInfo info = {};
|
GFXCreateInfo info = {};
|
||||||
|
|
||||||
|
#ifdef ENABLE_METAL
|
||||||
|
gfx_interface = new GFXMetal();
|
||||||
|
#else
|
||||||
gfx_interface = new GFXVulkan();
|
gfx_interface = new GFXVulkan();
|
||||||
|
#endif
|
||||||
if(gfx_interface->initialize(info)) {
|
if(gfx_interface->initialize(info)) {
|
||||||
engine->set_gfx(gfx_interface);
|
engine->set_gfx(gfx_interface);
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in a new issue