diff options
Diffstat (limited to 'src/platform/bootstrap')
-rw-r--r-- | src/platform/bootstrap/Bootstrap.cpp | 30 | ||||
-rw-r--r-- | src/platform/bootstrap/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/platform/bootstrap/GraphicsBootstrap.cpp | 25 |
3 files changed, 41 insertions, 24 deletions
diff --git a/src/platform/bootstrap/Bootstrap.cpp b/src/platform/bootstrap/Bootstrap.cpp index 5c47e95c..e9183550 100644 --- a/src/platform/bootstrap/Bootstrap.cpp +++ b/src/platform/bootstrap/Bootstrap.cpp @@ -1,39 +1,21 @@ #include "cru/platform/bootstrap/Bootstrap.h" +#include "cru/base/Base.h" -#ifdef CRU_PLATFORM_WINDOWS -#include "cru/platform/graphics/direct2d/Factory.h" +#if defined(_WIN32) #include "cru/platform/gui/win/UiApplication.h" -#elif defined(CRU_PLATFORM_OSX) -#include "cru/platform/graphics/quartz/Factory.h" +#elif defined(__APPLE__) #include "cru/platform/gui/osx/UiApplication.h" -#elif defined(CRU_PLATFORM_EMSCRIPTEN) -// TODO: Go fill this! #else -#include "cru/platform/graphics/cairo/CairoGraphicsFactory.h" #endif namespace cru::platform::bootstrap { cru::platform::gui::IUiApplication* CreateUiApplication() { -#ifdef CRU_PLATFORM_WINDOWS +#if defined(_WIN32) return new cru::platform::gui::win::WinUiApplication(); -#elif defined(CRU_PLATFORM_OSX) +#elif defined(__APPLE__) return new cru::platform::gui::osx::OsxUiApplication(); #else - return nullptr; + NotImplemented(); #endif } - -CRU_PLATFORM_BOOTSTRAP_API cru::platform::graphics::IGraphicsFactory* -CreateGraphicsFactory() { -#ifdef CRU_PLATFORM_WINDOWS - return new cru::platform::graphics::direct2d::DirectGraphicsFactory(); -#elif defined(CRU_PLATFORM_OSX) - return new cru::platform::graphics::quartz::QuartzGraphicsFactory(); -#elif defined(CRU_PLATFORM_EMSCRIPTEN) - return nullptr; // TODO: Change this. -#else - return new cru::platform::graphics::cairo::CairoGraphicsFactory(); -#endif -} - } // namespace cru::platform::bootstrap diff --git a/src/platform/bootstrap/CMakeLists.txt b/src/platform/bootstrap/CMakeLists.txt index 4092c677..f600a75c 100644 --- a/src/platform/bootstrap/CMakeLists.txt +++ b/src/platform/bootstrap/CMakeLists.txt @@ -1,14 +1,24 @@ +add_library(CruPlatformGraphicsBootstrap + GraphicsBootstrap.cpp +) + add_library(CruPlatformBootstrap Bootstrap.cpp ) +target_link_libraries(CruPlatformBootstrap PUBLIC CruPlatformGraphicsBootstrap) + if(WIN32) + target_link_libraries(CruPlatformGraphicsBootstrap PUBLIC CruPlatformGraphicsDirect) target_link_libraries(CruPlatformBootstrap PUBLIC CruPlatformGuiWin) elseif(APPLE) + target_link_libraries(CruPlatformGraphicsBootstrap PUBLIC CruPlatformGraphicsQuartz) target_link_libraries(CruPlatformBootstrap PUBLIC CruPlatformGuiOsx) elseif(EMSCRIPTEN) + target_link_libraries(CruPlatformGraphicsBootstrap PUBLIC CruBase) target_link_libraries(CruPlatformBootstrap PUBLIC CruBase) # TODO: Remember to change this. else() + target_link_libraries(CruPlatformGraphicsBootstrap PUBLIC CruPlatformGraphicsCairo) target_link_libraries(CruPlatformBootstrap PUBLIC CruPlatformGraphicsCairo) endif() diff --git a/src/platform/bootstrap/GraphicsBootstrap.cpp b/src/platform/bootstrap/GraphicsBootstrap.cpp new file mode 100644 index 00000000..cce42af8 --- /dev/null +++ b/src/platform/bootstrap/GraphicsBootstrap.cpp @@ -0,0 +1,25 @@ +#include "cru/platform/bootstrap/GraphicsBootstrap.h" + +#if defined(_WIN32) +#include "cru/platform/graphics/direct2d/Factory.h" +#elif defined(__APPLE__) +#include "cru/platform/graphics/quartz/Factory.h" +#elif defined(__unix) +#include "cru/platform/graphics/cairo/CairoGraphicsFactory.h" +#else +#endif + +namespace cru::platform::bootstrap { +CRU_PLATFORM_GRAPHICS_BOOTSTRAP_API cru::platform::graphics::IGraphicsFactory* +CreateGraphicsFactory() { +#if defined(_WIN32) + return new cru::platform::graphics::direct2d::DirectGraphicsFactory(); +#elif defined(__APPLE__) + return new cru::platform::graphics::quartz::QuartzGraphicsFactory(); +#elif defined(__unix) + return new cru::platform::graphics::cairo::CairoGraphicsFactory(); +#else + NotImplemented(); +#endif +} +} // namespace cru::platform::bootstrap |