Skip to content

Commit

Permalink
Feature/remove scene (#30)
Browse files Browse the repository at this point in the history
* remove scene class.

* convert main scence class to functions.
  • Loading branch information
wutipong authored Jan 26, 2024
1 parent d63e124 commit 3fac6c6
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 262 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ add_executable(font-render-tester
"src/main_scene.cpp"
"src/main_scene.hpp"
"src/main.cpp"
"src/scene.cpp"
"src/scene.hpp"
"src/settings.cpp"
"src/settings.hpp"
"src/text_renderer.cpp"
Expand Down
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "context.hpp"
#include "io_util.hpp"
#include "main_scene.hpp"
#include "scene.hpp"
#include <IconsForkAwesome.h>
#include <SDL2/SDL.h>
#include <imgui.h>
#include <imgui_impl_sdl2.h>
#include <imgui_impl_sdlrenderer2.h>
#include <memory>
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/spdlog.h>


static constexpr char imguiIni[] = "imgui.ini";
static constexpr char logfile[] = "log.txt";

Expand Down Expand Up @@ -77,7 +78,7 @@ int main(int argc, char **argv) {
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
ImGui_ImplSDLRenderer2_Init(renderer);

if (!Scene::ChangeScene<MainScene>(ctx)) {
if (!SceneInit(ctx)) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"Unable to initialize the new scene", window);

Expand All @@ -99,19 +100,19 @@ int main(int argc, char **argv) {

ImGui::NewFrame();

Scene::Current()->DoUI(ctx);
SceneDoUI(ctx);

ImGui::EndFrame();
ImGui::Render();

Scene::TickCurrent(renderer, ctx);
SceneTick(renderer, ctx);

ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData());
SDL_RenderPresent(renderer);
SDL_Delay(1);
}

Scene::Current()->CleanUp(ctx);
SceneCleanUp(ctx);

ImGui_ImplSDLRenderer2_Shutdown();
ImGui_ImplSDL2_Shutdown();
Expand Down
Loading

0 comments on commit 3fac6c6

Please sign in to comment.