Archived
1
Fork 0

Now try Metal, Vulkan and then finally Dummy in that order

This only applies to the SDL backend though, this will be expanded
upon though.
This commit is contained in:
Joshua Goins 2022-02-21 12:09:43 -05:00
parent ca57de8f99
commit 138cbf3f4b

View file

@ -16,6 +16,8 @@
#include "gfx_metal.hpp"
#endif
#include "gfx_dummy.hpp"
#ifdef PLATFORM_WINDOWS
#include <winrt/Windows.UI.ViewManagement.h>
#pragma comment(lib, "windowsapp")
@ -391,17 +393,33 @@ void* platform::get_next_image(window_ptr window) {
return nullptr;
}
template<class GFXBackend>
void try_initialize() {
if(gfx_interface == nullptr) {
auto backend = new GFXBackend();
const bool supported = backend->is_supported();
if(!supported) {
prism::log("Failed to initialize GFX backend... trying next...");
} else {
gfx_interface = backend;
platform::initialize_context(gfx_interface->required_context());
}
}
}
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
// determine gfx context at the beginning
#ifdef ENABLE_METAL
gfx_interface = new GFXMetal();
#else
gfx_interface = new GFXVulkan();
try_initialize<GFXMetal>();
#endif
platform::initialize_context(gfx_interface->required_context());
#ifdef ENABLE_VULKAN
try_initialize<GFXVulkan>();
#endif
try_initialize<GFXDummy>();
engine = new prism::engine(argc, argv);