This commit is contained in:
wcjbr
2026-08-16 13:34:42 +08:00
parent d36fd6d2ee
commit 07aeced2e4
17 changed files with 40 additions and 40 deletions
+9 -9
View File
@@ -1,25 +1,25 @@
cmake_minimum_required(VERSION 3.10.0) cmake_minimum_required(VERSION 3.10.0)
project(opencge VERSION 0.1.0 LANGUAGES C CXX) project(Boundard VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_library(opencge STATIC add_library(boundard STATIC
src/opencge.cpp src/boundard.cpp
src/game.cpp src/game.cpp
src/render.cpp src/render.cpp
src/config.cpp src/config.cpp
src/engine.cpp src/engine.cpp
) )
target_include_directories(opencge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(boundard PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_features(opencge PUBLIC cxx_std_17) target_compile_features(boundard PUBLIC cxx_std_17)
find_package(glfw3 REQUIRED) find_package(glfw3 REQUIRED)
find_package(Vulkan REQUIRED) find_package(Vulkan REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP REQUIRED IMPORTED_TARGET jsoncpp) pkg_check_modules(JSONCPP REQUIRED IMPORTED_TARGET jsoncpp)
target_link_libraries(opencge PUBLIC glfw Vulkan::Vulkan PkgConfig::JSONCPP) target_link_libraries(boundard PUBLIC glfw Vulkan::Vulkan PkgConfig::JSONCPP)
add_executable(square_example examples/square/main.cpp) add_executable(square_example examples/square/main.cpp)
target_link_libraries(square_example PRIVATE opencge) target_link_libraries(square_example PRIVATE boundard)
add_executable(opencge_engine src/engine_main.cpp) add_executable(boundard_engine src/engine_main.cpp)
target_link_libraries(opencge_engine PRIVATE opencge) target_link_libraries(boundard_engine PRIVATE boundard)
+5 -5
View File
@@ -1,13 +1,13 @@
#include <cmath> #include <cmath>
#include <openceg.hpp> #include <boundard.hpp>
namespace { namespace {
void register_square_behaviors() { void register_square_behaviors() {
auto& behaviors = openceg::BehaviorRegistry::getInstance(); auto& behaviors = boundard::BehaviorRegistry::getInstance();
behaviors.register_init("square_init", [](openceg::Actor& actor) { behaviors.register_init("square_init", [](boundard::Actor& actor) {
actor.set_position({0.0F, 0.0F}); actor.set_position({0.0F, 0.0F});
actor.set_facing({1.0F, 0.0F}); actor.set_facing({1.0F, 0.0F});
if (actor.mesh() != nullptr) { if (actor.mesh() != nullptr) {
@@ -17,7 +17,7 @@ void register_square_behaviors() {
behaviors.register_tick( behaviors.register_tick(
"square_tick", "square_tick",
[](openceg::Actor& actor, float dt, const openceg::render::InputMap& input) { [](boundard::Actor& actor, float dt, const boundard::render::InputMap& input) {
const float t = actor.age(); const float t = actor.age();
actor.set_facing({ actor.set_facing({
std::cos(t * 1.5F), std::cos(t * 1.5F),
@@ -45,5 +45,5 @@ void register_square_behaviors() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
register_square_behaviors(); register_square_behaviors();
return openceg::run_engine(argc, argv, "examples/square/config.ceg"); return boundard::run_engine(argc, argv, "examples/square/config.ceg");
} }
+3 -3
View File
@@ -9,11 +9,11 @@
#include <game.hpp> #include <game.hpp>
#include <mesh.hpp> #include <mesh.hpp>
namespace openceg::render { namespace boundard::render {
class InputMap; class InputMap;
} }
namespace openceg { namespace boundard {
class Actor { class Actor {
private: private:
@@ -109,4 +109,4 @@ class Actor {
void set_mesh(std::shared_ptr<Mesh> mesh) { mesh_ = std::move(mesh); } void set_mesh(std::shared_ptr<Mesh> mesh) { mesh_ = std::move(mesh); }
}; };
} // namespace openceg } // namespace boundard
+3 -3
View File
@@ -7,11 +7,11 @@
#include <actor.hpp> #include <actor.hpp>
namespace openceg::render { namespace boundard::render {
class InputMap; class InputMap;
} }
namespace openceg { namespace boundard {
using ActorInitHandler = std::function<void(Actor&)>; using ActorInitHandler = std::function<void(Actor&)>;
using ActorTickHandler = std::function<void(Actor&, float, const render::InputMap&)>; using ActorTickHandler = std::function<void(Actor&, float, const render::InputMap&)>;
@@ -62,4 +62,4 @@ class BehaviorRegistry {
std::unordered_map<std::string, ActorTickHandler> tick_handlers_; std::unordered_map<std::string, ActorTickHandler> tick_handlers_;
}; };
} // namespace openceg } // namespace boundard
+2 -2
View File
@@ -5,7 +5,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace openceg { namespace boundard {
struct WindowConfig { struct WindowConfig {
int width = 800; int width = 800;
@@ -51,4 +51,4 @@ class ConfigLoader {
std::string last_error_; std::string last_error_;
}; };
} // namespace openceg } // namespace boundard
+2 -2
View File
@@ -1,9 +1,9 @@
#pragma once #pragma once
namespace openceg { namespace boundard {
// 通用引擎入口:读取 config.ceg,实例化场景并驱动 Actor 的 init/tick。 // 通用引擎入口:读取 config.ceg,实例化场景并驱动 Actor 的 init/tick。
// 具体游戏行为通过 BehaviorRegistry 注册,因此引擎本身不内置任何游戏逻辑。 // 具体游戏行为通过 BehaviorRegistry 注册,因此引擎本身不内置任何游戏逻辑。
int run_engine(int argc, char** argv, const char* default_config_path = "config.ceg"); int run_engine(int argc, char** argv, const char* default_config_path = "config.ceg");
} // namespace openceg } // namespace boundard
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
namespace openceg { namespace boundard {
class Game { class Game {
private: private:
size_t id_cnt; size_t id_cnt;
@@ -18,4 +18,4 @@ class Game {
void launch(); void launch();
size_t new_id(); size_t new_id();
}; };
} // namespace openceg } // namespace boundard
+2 -2
View File
@@ -7,7 +7,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace openceg { namespace boundard {
// 渲染组件:描述 Actor 的几何形状、颜色和纹理占位。 // 渲染组件:描述 Actor 的几何形状、颜色和纹理占位。
class Mesh { class Mesh {
@@ -48,4 +48,4 @@ class Mesh {
std::array<float, 4> color_{1.0F, 1.0F, 1.0F, 1.0F}; std::array<float, 4> color_{1.0F, 1.0F, 1.0F, 1.0F};
}; };
} // namespace openceg } // namespace boundard
+2 -2
View File
@@ -13,7 +13,7 @@
#include <actor.hpp> #include <actor.hpp>
namespace openceg::render { namespace boundard::render {
struct InputEvent { struct InputEvent {
enum class Type { enum class Type {
@@ -136,4 +136,4 @@ class RenderLoop {
std::vector<Actor*> actors_; std::vector<Actor*> actors_;
}; };
} // namespace openceg::render } // namespace boundard::render
+1
View File
@@ -0,0 +1 @@
#include <boundard.hpp>
+2 -2
View File
@@ -8,7 +8,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace openceg { namespace boundard {
namespace { namespace {
std::string lowercase(std::string value) { std::string lowercase(std::string value) {
@@ -320,4 +320,4 @@ const std::string& ConfigLoader::last_error() const {
return last_error_; return last_error_;
} }
} // namespace openceg } // namespace boundard
+3 -3
View File
@@ -7,9 +7,9 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <openceg.hpp> #include <boundard.hpp>
namespace openceg { namespace boundard {
int run_engine(int argc, char** argv, const char* default_config_path) { int run_engine(int argc, char** argv, const char* default_config_path) {
std::string config_path = default_config_path != nullptr ? default_config_path : "config.ceg"; std::string config_path = default_config_path != nullptr ? default_config_path : "config.ceg";
@@ -114,4 +114,4 @@ int run_engine(int argc, char** argv, const char* default_config_path) {
return 0; return 0;
} }
} // namespace openceg } // namespace boundard
+1 -1
View File
@@ -1,5 +1,5 @@
#include <engine.hpp> #include <engine.hpp>
int main(int argc, char** argv) { int main(int argc, char** argv) {
return openceg::run_engine(argc, argv); return boundard::run_engine(argc, argv);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
#include <game.hpp> #include <game.hpp>
namespace openceg { namespace boundard {
Game::Game() { id_cnt = 0; } Game::Game() { id_cnt = 0; }
Game::~Game() = default; Game::~Game() = default;
-1
View File
@@ -1 +0,0 @@
#include <openceg.hpp>
+2 -2
View File
@@ -12,7 +12,7 @@
#include <stdexcept> #include <stdexcept>
#include <vector> #include <vector>
namespace openceg::render { namespace boundard::render {
namespace { namespace {
@@ -1337,4 +1337,4 @@ void Renderer::Impl::destroy() {
initialized = false; initialized = false;
} }
} // namespace openceg::render } // namespace boundard::render