Files
cuber/CMakeLists.txt
T
portersky 5ec8cfc735 feat: add gfx pipeline abstraction with render targets
Add cbt/gfx layer (pipeline + render_target) inspired by Sokol but
C++-friendly with RAII and pipeline_desc. Supports building full
graphics pipelines (VS/IA/raster/PS/OM), render-to-texture (FBO),
and post-processing steps (scene -> RT -> fullscreen quad with
sampler + vignette).

- Depth/state/viewport/texture cleanup for reliable scene switching.
- Updated cube/sphere to demonstrate (sphere uses RT+post).
- Vulkan backend easy via PIMPL in impl (same public API).
- Fixed depth test, viewport restore, and state leakage on switch.

Followed coding conventions (snake_case, trailing returns, east const,
include order, no ; after ns/class, etc.).
2026-05-06 00:43:00 +02:00

76 lines
2.5 KiB
CMake

cmake_minimum_required(VERSION 3.21)
project(cuber VERSION 0.1.0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add the deps directory to the module path
# Required for find_package injection
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
# Platform and compiler detection
include(Platform)
include(Flags)
# Dependencies
find_package(fmt REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glad REQUIRED)
find_package(asio REQUIRED)
find_package(glm REQUIRED)
find_package(stb REQUIRED)
# OpenGL abstraction library
add_library(cbt_opengl STATIC
"cbt/window.cpp"
"cbt/opengl/context.cpp"
"cbt/opengl/buffer.cpp"
"cbt/opengl/texture.cpp"
"cbt/opengl/descriptor.cpp"
"cbt/opengl/shader.cpp"
"cbt/opengl/vao.cpp"
"cbt/gfx.cpp"
)
target_include_directories(cbt_opengl PRIVATE ".")
target_compile_features(cbt_opengl PRIVATE cxx_std_23)
target_compile_options(cbt_opengl PRIVATE ${BASE_OPTIONS})
target_compile_definitions(cbt_opengl PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(cbt_opengl PUBLIC fmt::fmt glfw::glfw glad::glad stb::stb glm::glm)
# Scene base library
add_library(cbt_scene STATIC
"cbt/scene.cpp"
)
target_include_directories(cbt_scene PRIVATE ".")
target_compile_features(cbt_scene PRIVATE cxx_std_23)
target_compile_options(cbt_scene PRIVATE ${BASE_OPTIONS})
target_compile_definitions(cbt_scene PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(cbt_scene PUBLIC cbt_opengl)
# Application scenes
add_library(scenes_cube STATIC
"scenes/cube.cpp"
)
target_include_directories(scenes_cube PRIVATE ".")
target_compile_features(scenes_cube PRIVATE cxx_std_23)
target_compile_options(scenes_cube PRIVATE ${BASE_OPTIONS})
target_compile_definitions(scenes_cube PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(scenes_cube PUBLIC cbt_scene glm::glm)
# Sphere scene
add_library(scenes_sphere STATIC
"scenes/sphere.cpp"
)
target_include_directories(scenes_sphere PRIVATE ".")
target_compile_features(scenes_sphere PRIVATE cxx_std_23)
target_compile_options(scenes_sphere PRIVATE ${BASE_OPTIONS})
target_compile_definitions(scenes_sphere PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(scenes_sphere PUBLIC cbt_scene glm::glm)
# Main executable
add_executable(cuber "cuber.cpp")
target_include_directories(cuber PRIVATE ".")
target_compile_features(cuber PRIVATE cxx_std_23)
target_compile_options(cuber PRIVATE ${BASE_OPTIONS})
target_compile_definitions(cuber PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(cuber PRIVATE cbt_scene scenes_cube scenes_sphere asio::asio ${BASE_LIBRARIES})