Sprite sheets, atlases, game UI, time of day, weather presets, headless captures
- BillboardInstance: per-instance uv sub-rect, feet anchor, turn, dithered alpha, flash; BillboardBatch::sharedTexture; Texture createEmpty/update/cellUV/cellAnchor/nearest - SpriteAtlas: fixed-cell runtime atlas with gutters - hd2d::ui: Octopath-style panels, fonts (Cinzel, EB Garamond), dialogue box with typewriter + portraits + choices, menus, nameplates, toasts, ImGui theme - DayCycle (dawn/day/dusk/night keyframes, sun + moon arcs), Weather overcast/mist/ lightning, night-aware presets, stars and moon in the sky - Hidden-window offscreen captures (Window visible=false, Renderer output FBO, OffscreenTarget); --screenshot never opens a window - Camera::worldToScreen; CMake usable via add_subdirectory (HD2D_BUILD_DEMO, HD2D_ENGINE_ASSET_DIR)
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
cmake_minimum_required(VERSION 3.21) # PROJECT_IS_TOP_LEVEL
|
||||
project(hd2d LANGUAGES C CXX)
|
||||
|
||||
# Usable standalone or from a parent project via
|
||||
# `add_subdirectory(path/to/Vibe-HD-2D hd2d)`; link `hd2d` and load engine
|
||||
# shaders from `HD2D_ENGINE_ASSET_DIR` (compile definition and cache variable).
|
||||
# The engine provides the `imgui` target (Dear ImGui + GLFW/OpenGL3
|
||||
# backends) unless the parent already defines one.
|
||||
option(HD2D_BUILD_DEMO "Build the demo" ${PROJECT_IS_TOP_LEVEL})
|
||||
set(HD2D_ENGINE_ASSET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets" CACHE INTERNAL "Engine shaders and assets")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
@@ -14,21 +24,27 @@ include(FetchContent)
|
||||
# System packages are preferred; anything missing is fetched.
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
|
||||
|
||||
find_package(glfw3 3.3 QUIET)
|
||||
if(NOT glfw3_FOUND)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(glfw GIT_REPOSITORY https://github.com/glfw/glfw.git GIT_TAG 3.4)
|
||||
FetchContent_MakeAvailable(glfw)
|
||||
if(NOT TARGET PkgConfig::EPOXY)
|
||||
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
|
||||
endif()
|
||||
|
||||
find_package(glm QUIET)
|
||||
if(NOT glm_FOUND)
|
||||
FetchContent_Declare(glm GIT_REPOSITORY https://github.com/g-truc/glm.git GIT_TAG 1.0.1)
|
||||
FetchContent_MakeAvailable(glm)
|
||||
if(NOT TARGET glfw)
|
||||
find_package(glfw3 3.3 QUIET)
|
||||
if(NOT glfw3_FOUND)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(glfw GIT_REPOSITORY https://github.com/glfw/glfw.git GIT_TAG 3.4)
|
||||
FetchContent_MakeAvailable(glfw)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET glm::glm)
|
||||
find_package(glm QUIET)
|
||||
if(NOT glm_FOUND)
|
||||
FetchContent_Declare(glm GIT_REPOSITORY https://github.com/g-truc/glm.git GIT_TAG 1.0.1)
|
||||
FetchContent_MakeAvailable(glm)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(STB_INCLUDE_DIR stb_image.h PATH_SUFFIXES stb)
|
||||
@@ -45,17 +61,19 @@ if(NOT CGLTF_INCLUDE_DIR)
|
||||
set(CGLTF_INCLUDE_DIR ${cgltf_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(imgui GIT_REPOSITORY https://github.com/ocornut/imgui.git GIT_TAG v1.91.9b)
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
add_library(imgui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp)
|
||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends)
|
||||
target_link_libraries(imgui PUBLIC glfw OpenGL::GL)
|
||||
if(NOT TARGET imgui) # a parent project may provide its own
|
||||
FetchContent_Declare(imgui GIT_REPOSITORY https://github.com/ocornut/imgui.git GIT_TAG v1.91.9b)
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
add_library(imgui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp)
|
||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends)
|
||||
target_link_libraries(imgui PUBLIC glfw OpenGL::GL)
|
||||
endif()
|
||||
|
||||
# --- Engine -----------------------------------------------------------------
|
||||
file(GLOB_RECURSE HD2D_ENGINE_SOURCES CONFIGURE_DEPENDS engine/src/*.cpp)
|
||||
@@ -63,7 +81,9 @@ add_library(hd2d STATIC ${HD2D_ENGINE_SOURCES})
|
||||
target_include_directories(hd2d PUBLIC engine/include)
|
||||
target_include_directories(hd2d SYSTEM PRIVATE ${STB_INCLUDE_DIR} ${CGLTF_INCLUDE_DIR}) # silence third-party warnings
|
||||
target_link_libraries(hd2d PUBLIC glfw glm::glm PkgConfig::EPOXY imgui OpenGL::GL)
|
||||
target_compile_definitions(hd2d PUBLIC GLM_FORCE_RADIANS GLM_ENABLE_EXPERIMENTAL)
|
||||
target_compile_features(hd2d PUBLIC cxx_std_20)
|
||||
target_compile_definitions(hd2d PUBLIC GLM_FORCE_RADIANS GLM_ENABLE_EXPERIMENTAL
|
||||
HD2D_ENGINE_ASSET_DIR="${HD2D_ENGINE_ASSET_DIR}")
|
||||
if(MSVC)
|
||||
target_compile_options(hd2d PRIVATE /W4)
|
||||
else()
|
||||
@@ -71,7 +91,9 @@ else()
|
||||
endif()
|
||||
|
||||
# --- Demo -------------------------------------------------------------------
|
||||
add_executable(hd2d_demo demo/main.cpp demo/DemoScene.cpp)
|
||||
target_link_libraries(hd2d_demo PRIVATE hd2d)
|
||||
# Assets/shaders are loaded relative to this directory at runtime.
|
||||
target_compile_definitions(hd2d_demo PRIVATE HD2D_ASSET_DIR="${CMAKE_SOURCE_DIR}/assets")
|
||||
if(HD2D_BUILD_DEMO)
|
||||
add_executable(hd2d_demo demo/main.cpp demo/DemoScene.cpp)
|
||||
target_link_libraries(hd2d_demo PRIVATE hd2d)
|
||||
# Assets/shaders are loaded relative to this directory at runtime.
|
||||
target_compile_definitions(hd2d_demo PRIVATE HD2D_ASSET_DIR="${HD2D_ENGINE_ASSET_DIR}")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user