From 1cf439ef03abf8bbd39a4de7e704443a915acd6f Mon Sep 17 00:00:00 2001 From: Nikola Petrov Date: Mon, 3 Feb 2025 14:24:55 +0100 Subject: [PATCH] Add Vapp --- CMakeLists.txt | 2 +- view/inc/Vapp.hpp | 13 +++++++++++++ view/src/Vapp.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ view/src/main.cpp | 34 +++++++++------------------------- 4 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 view/inc/Vapp.hpp create mode 100644 view/src/Vapp.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ffd2e..d532a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ target_include_directories(server PRIVATE server/inc shared/inc) add_executable(view view/src/main.cpp - + view/src/Vapp.cpp shared/src/canvas/BackGround.cpp shared/src/canvas/BackGroundColors.cpp shared/src/canvas/Canvas.cpp diff --git a/view/inc/Vapp.hpp b/view/inc/Vapp.hpp new file mode 100644 index 0000000..e11900c --- /dev/null +++ b/view/inc/Vapp.hpp @@ -0,0 +1,13 @@ + + +class Vapp +{ +public: + void init(); + void update(); + void draw(); + void deinit(); + +private: + bool showDemoWindow; +}; \ No newline at end of file diff --git a/view/src/Vapp.cpp b/view/src/Vapp.cpp new file mode 100644 index 0000000..c4d46e8 --- /dev/null +++ b/view/src/Vapp.cpp @@ -0,0 +1,43 @@ +#include + +#include "Vapp.hpp" +#include "values/Dna.hpp" + +#include +#include +#include + +void Vapp::init() +{ + // TraceLog(LOG_INFO, "%d / %d = %d", sizeof(Dna), sizeof(int64_t), sizeof(Dna) / sizeof(int64_t)); +} + +void Vapp::update() +{ +} + +void Vapp::draw() +{ + ClearBackground(RAYWHITE); + + ImGui::DockSpaceOverViewport(0, NULL, ImGuiDockNodeFlags_PassthruCentralNode); + + if (ImGui::BeginMainMenuBar()) + { + if (ImGui::BeginMenu("Window")) + { + if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow)) + showDemoWindow = !showDemoWindow; + + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); + } + + if (showDemoWindow) + ImGui::ShowDemoWindow(&showDemoWindow); +} + +void Vapp::deinit() +{ +} diff --git a/view/src/main.cpp b/view/src/main.cpp index 4027cc1..461643c 100644 --- a/view/src/main.cpp +++ b/view/src/main.cpp @@ -2,50 +2,34 @@ #include #include #include +#include "Vapp.hpp" int main(int argc, char *argv[]) { int screenWidth = 800; int screenHeight = 800; - SetConfigFlags(FLAG_WINDOW_RESIZABLE); + Vapp app; + InitWindow(screenWidth, screenHeight, "VIEW"); SetTargetFPS(60); rlImGuiSetup(true); - + app.init(); bool showDemoWindow = true; ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable; - while (!WindowShouldClose()) + while (!WindowShouldClose()) { + app.update(); BeginDrawing(); rlImGuiBegin(); - - ClearBackground(RAYWHITE); - - ImGui::DockSpaceOverViewport(0, NULL, ImGuiDockNodeFlags_PassthruCentralNode); - - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("Window")) - { - if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow)) - showDemoWindow = !showDemoWindow; - - ImGui::EndMenu(); - } - ImGui::EndMainMenuBar(); - } - - if (showDemoWindow) - ImGui::ShowDemoWindow(&showDemoWindow); - + app.draw(); rlImGuiEnd(); EndDrawing(); } - + app.deinit(); rlImGuiShutdown(); - CloseWindow(); + CloseWindow(); return 0; } \ No newline at end of file