Remove library-specific graphics api defines in favor of global PSEMEK_GRAPHICS_API_XXX
This commit is contained in:
parent
0718282dda
commit
a4d666096e
7 changed files with 16 additions and 17 deletions
|
|
@ -59,6 +59,7 @@ if(PSEMEK_GRAPHICS_API STREQUAL WEBGPU)
|
|||
endif()
|
||||
|
||||
message(STATUS "Using graphics API ${PSEMEK_GRAPHICS_API}")
|
||||
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_GRAPHICS_API_${PSEMEK_GRAPHICS_API}=1")
|
||||
|
||||
add_subdirectory(3rdparty)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ endif()
|
|||
psemek_add_library(psemek-app ${PSEMEK_APP_HEADERS} ${PSEMEK_APP_SOURCES})
|
||||
target_include_directories(psemek-app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(psemek-app PUBLIC psemek-log psemek-util psemek-gfx psemek-ui)
|
||||
target_compile_definitions(psemek-app PUBLIC -DPSEMEK_APP_${PSEMEK_GRAPHICS_API}=1)
|
||||
if(PSEMEK_GRAPHICS_API STREQUAL WEBGPU)
|
||||
target_link_libraries(psemek-app PUBLIC psemek-wgpu)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <psemek/app/event_handler.hpp>
|
||||
|
||||
#if defined(PSEMEK_APP_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
#include <psemek/wgpu/adapter.hpp>
|
||||
#include <psemek/wgpu/surface.hpp>
|
||||
#include <psemek/wgpu/device.hpp>
|
||||
|
|
@ -23,7 +23,7 @@ namespace psemek::app
|
|||
std::string name;
|
||||
int multisampling = 4;
|
||||
bool highdpi = false;
|
||||
#if defined(PSEMEK_APP_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
std::vector<wgpu::feature> required_features;
|
||||
std::optional<wgpu::limits> required_limits;
|
||||
#endif
|
||||
|
|
@ -36,10 +36,10 @@ namespace psemek::app
|
|||
std::function<void(bool)> show_cursor;
|
||||
std::function<void(bool)> relative_mouse_mode;
|
||||
std::function<void(bool)> windowed;
|
||||
#if defined(PSEMEK_APP_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
std::function<void(bool)> vsync;
|
||||
#endif
|
||||
#if defined(PSEMEK_APP_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
wgpu::adapter adapter;
|
||||
wgpu::surface surface;
|
||||
wgpu::device device;
|
||||
|
|
|
|||
|
|
@ -11,4 +11,3 @@ if(PSEMEK_GRAPHICS_API STREQUAL OPENGL)
|
|||
elseif(PSEMEK_GRAPHICS_API STREQUAL WEBGPU)
|
||||
target_link_libraries(psemek-sdl2 PUBLIC psemek-wgpu)
|
||||
endif()
|
||||
target_compile_definitions(psemek-sdl2 PUBLIC "-DPSEMEK_SDL2_${PSEMEK_GRAPHICS_API}=1")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <psemek/app/application.hpp>
|
||||
|
||||
#if defined(PSEMEK_SDL2_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
#include <psemek/wgpu/surface.hpp>
|
||||
#include <psemek/wgpu/adapter.hpp>
|
||||
#include <psemek/wgpu/device.hpp>
|
||||
|
|
@ -27,7 +27,7 @@ namespace psemek::sdl2
|
|||
void vsync(bool on);
|
||||
void windowed(bool on);
|
||||
|
||||
#if defined(PSEMEK_SDL2_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
wgpu::adapter wgpu_adapter() const { return wgpu_adapter_; }
|
||||
wgpu::surface wgpu_surface() const { return wgpu_surface_; }
|
||||
wgpu::device wgpu_device() const { return wgpu_device_; }
|
||||
|
|
@ -37,9 +37,9 @@ namespace psemek::sdl2
|
|||
std::shared_ptr<void> sdl_init_;
|
||||
SDL_Window * window_ = nullptr;
|
||||
|
||||
#if defined(PSEMEK_SDL2_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
SDL_GLContext gl_context_ = nullptr;
|
||||
#elif defined(PSEMEK_SDL2_WEBGPU)
|
||||
#elif defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
wgpu::adapter wgpu_adapter_;
|
||||
wgpu::surface wgpu_surface_;
|
||||
wgpu::device wgpu_device_;
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ int main(int argc, char ** argv) try
|
|||
context.relative_mouse_mode = [&](bool mode){ window.relative_mouse_mode(mode); };
|
||||
context.windowed = [&](bool on){ window.windowed(on); };
|
||||
|
||||
#if defined(PSEMEK_SDL2_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
context.vsync = [&](bool on){ window.vsync(on); };
|
||||
#endif
|
||||
|
||||
#if defined(PSEMEK_SDL2_WEBGPU)
|
||||
#if defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
context.adapter = window.wgpu_adapter();
|
||||
context.surface = window.wgpu_surface();
|
||||
context.device = window.wgpu_device();
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include <psemek/geom/box.hpp>
|
||||
#include <psemek/log/log.hpp>
|
||||
|
||||
#if defined(PSEMEK_SDL2_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
#include <psemek/gfx/init.hpp>
|
||||
#elif defined(PSEMEK_SDL2_WEBGPU)
|
||||
#elif defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
#include <psemek/wgpu/instance.hpp>
|
||||
#include <psemek/wgpu/logging.hpp>
|
||||
#include <psemek/wgpu/version.hpp>
|
||||
|
|
@ -23,7 +23,7 @@ namespace psemek::sdl2
|
|||
std::uint32_t flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||
if (options.highdpi) flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
#if defined(PSEMEK_SDL2_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl::sys::major_version());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl::sys::minor_version());
|
||||
|
|
@ -66,7 +66,7 @@ namespace psemek::sdl2
|
|||
if (!window_)
|
||||
sdl2::fail("Failed to create window: ");
|
||||
|
||||
#if defined(PSEMEK_SDL2_OPENGL)
|
||||
#if defined(PSEMEK_GRAPHICS_API_OPENGL)
|
||||
gl_context_ = SDL_GL_CreateContext(window_);
|
||||
if (!gl_context_)
|
||||
sdl2::fail("Failed to create OpenGL context: ");
|
||||
|
|
@ -74,7 +74,7 @@ namespace psemek::sdl2
|
|||
SDL_GL_MakeCurrent(window_, gl_context_);
|
||||
|
||||
gfx::init();
|
||||
#elif defined(PSEMEK_SDL2_WEBGPU)
|
||||
#elif defined(PSEMEK_GRAPHICS_API_WEBGPU)
|
||||
wgpu::setup_logging(log::level::error);
|
||||
|
||||
auto instance = wgpu::instance::create({});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue