testbed: work in progress (if only I had more time these days...)
This commit is contained in:
@@ -48,6 +48,8 @@ target_sources(
|
||||
PRIVATE
|
||||
application/application.cpp
|
||||
application/context.cpp
|
||||
system/imgui_system.cpp
|
||||
system/rendering_system.cpp
|
||||
testbed.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||
|
||||
@@ -4,23 +4,28 @@
|
||||
#include <application/context.h>
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
#include <backends/imgui_impl_sdlrenderer3.h>
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <imgui.h>
|
||||
#include <system/imgui_system.h>
|
||||
#include <system/rendering_system.h>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void application::update() {
|
||||
void application::update(entt::registry ®istry) {
|
||||
ImGui_ImplSDLRenderer3_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// update...
|
||||
static_cast<void>(registry);
|
||||
}
|
||||
|
||||
void application::draw(const context &context) const {
|
||||
void application::draw(entt::registry ®istry, const context &context) const {
|
||||
SDL_SetRenderDrawColor(context, 0u, 0u, 0u, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(context);
|
||||
|
||||
// draw...
|
||||
rendering_system(registry, context);
|
||||
imgui_system(registry);
|
||||
|
||||
ImGui::Render();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
@@ -59,12 +64,14 @@ application::~application() {
|
||||
}
|
||||
|
||||
int application::run() {
|
||||
entt::registry registry{};
|
||||
context context{};
|
||||
|
||||
quit = false;
|
||||
|
||||
while(!quit) {
|
||||
update();
|
||||
draw(context);
|
||||
update(registry);
|
||||
draw(registry, context);
|
||||
input();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <entt/entity/fwd.hpp>
|
||||
|
||||
struct SDL_Renderer;
|
||||
|
||||
@@ -10,8 +11,8 @@ struct config;
|
||||
struct context;
|
||||
|
||||
class application {
|
||||
void update();
|
||||
void draw(const context &) const;
|
||||
void update(entt::registry &);
|
||||
void draw(entt::registry &, const context &) const;
|
||||
void input();
|
||||
|
||||
public:
|
||||
|
||||
16
testbed/system/imgui_system.cpp
Normal file
16
testbed/system/imgui_system.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <imgui.h>
|
||||
#include <system/imgui_system.h>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void imgui_system(entt::registry ®istry) {
|
||||
ImGui::Begin("testbed");
|
||||
|
||||
// ...
|
||||
static_cast<void>(registry);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace testbed
|
||||
9
testbed/system/imgui_system.h
Normal file
9
testbed/system/imgui_system.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <entt/entity/fwd.hpp>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void imgui_system(entt::registry &);
|
||||
|
||||
} // namespace testbed
|
||||
13
testbed/system/rendering_system.cpp
Normal file
13
testbed/system/rendering_system.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <application/context.h>
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <system/rendering_system.h>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
void rendering_system(entt::registry ®istry, const context &ctx) {
|
||||
// render...
|
||||
static_cast<void>(registry);
|
||||
static_cast<void>(ctx);
|
||||
}
|
||||
|
||||
} // namespace testbed
|
||||
11
testbed/system/rendering_system.h
Normal file
11
testbed/system/rendering_system.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <entt/entity/fwd.hpp>
|
||||
|
||||
namespace testbed {
|
||||
|
||||
struct context;
|
||||
|
||||
void rendering_system(entt::registry &, const context &);
|
||||
|
||||
} // namespace testbed
|
||||
Reference in New Issue
Block a user