added project loader

This commit is contained in:
2026-05-14 23:16:16 -04:00
parent 2dd5f3a648
commit 0ceea230cf
10 changed files with 134 additions and 30 deletions

View File

@@ -15,6 +15,8 @@
#include "FreeCameraController.h"
#include "InputManager.h"
#include "ModelManager.h"
#include "ProjectManifest.h"
#include "ProjectManifestFile.h"
#include "Scene.h"
#include "ShaderManager.h"
#include "ShaderProgram.h"
@@ -26,6 +28,8 @@
#include "ui/UISceneGraph.h"
#include "ui/UISceneViewer.h"
const char* B_ENGINE_VERSION = "v0.0.3";
GLFWwindow* gWindow = nullptr;
int gWindowWidth = 1920;
int gWindowHeight = 1080;
@@ -37,6 +41,8 @@ float gAspectRatio = 0.f;
float gMouseSensitivity = 0.1f;
std::unique_ptr<ProjectManifest> gCurrentProject {nullptr};
Camera gCamera {};
Scene gScene{};
EditorContext gEditorCtx{};
@@ -58,13 +64,14 @@ void load_default_models();
void loop();
void create_entity(entt::entity parent);
void open_project(std::string_view _path);
auto xAxis = glm::vec3{1.f, 0.f, 0.f};
auto yAxis = glm::vec3{0.f, 1.f, 0.f};
auto zAxis = glm::vec3{0.f, 0.f, 1.f};
int main() {
spdlog::info("b_engine v0.0.3 start");
spdlog::info("b_engine {} start", B_ENGINE_VERSION);
init_glfw();
@@ -83,8 +90,9 @@ int main() {
load_default_models();
UIManager::init(gWindow);
UIMenuBar* menuBar = UIManager::add_ui_panel<UIMenuBar>("menu_bar");
auto* menuBar = UIManager::add_ui_panel<UIMenuBar>("menu_bar");
menuBar->create_entity = create_entity;
menuBar->open_project = open_project;
UIManager::add_ui_panel<UISceneViewer>("scene_viewer");
UIManager::add_ui_panel<UISceneGraph>("scene_graph");
UIManager::add_ui_panel<UIEntityInspector>("entity_inspector");
@@ -142,7 +150,8 @@ void init_glfw()
void create_main_window()
{
gWindow = glfwCreateWindow(gWindowWidth, gWindowHeight, "b_engine v0.0.3", nullptr, nullptr);
std::string title = fmt::format("b_engine {}", B_ENGINE_VERSION);
gWindow = glfwCreateWindow(gWindowWidth, gWindowHeight, title.c_str(), nullptr, nullptr);
if (!gWindow) {
spdlog::error("failed to create glfw window");
std::exit(1);
@@ -272,10 +281,12 @@ void loop() {
}
void create_entity(entt::entity parent) {
auto entity = gScene.create_game_object(parent);
auto& drawable = gScene.attach_component<Components::Drawable>(entity);
drawable.model = ModelManager::models["vette"];
auto& transform = gScene.fetch_component<Components::Transform>(entity);
transform.scale = {0.1, 0.1, 0.1};
transform.dirty = true;
gScene.create_game_object(parent);
}
void open_project(std::string_view _path) {
gCurrentProject = ProjectManifestFile::load(_path);
const std::string title = fmt::format("project \"{}\" | b_engine {}", gCurrentProject->name, B_ENGINE_VERSION);
glfwSetWindowTitle(gWindow, title.c_str());
}