This commit is contained in:
Nikola Petrov 2025-02-03 14:24:55 +01:00
parent 3651d07750
commit 1cf439ef03
4 changed files with 66 additions and 26 deletions

View File

@ -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

13
view/inc/Vapp.hpp Normal file
View File

@ -0,0 +1,13 @@
class Vapp
{
public:
void init();
void update();
void draw();
void deinit();
private:
bool showDemoWindow;
};

43
view/src/Vapp.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <cinttypes>
#include "Vapp.hpp"
#include "values/Dna.hpp"
#include <rlImGui.h>
#include <imgui.h>
#include <raylib.h>
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()
{
}

View File

@ -2,50 +2,34 @@
#include <raylib.h>
#include <imgui.h>
#include <rlImGui.h>
#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;
}