summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/CMakeLists.txt1
-rw-r--r--kurator/src/Session.cpp16
-rw-r--r--kurator/src/Session.h4
-rw-r--r--kurator/src/Window.cpp31
-rw-r--r--kurator/src/Window.h17
-rw-r--r--kurator/src/main.cpp10
6 files changed, 63 insertions, 16 deletions
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
index 0250b9d..cf37f69 100644
--- a/kurator/CMakeLists.txt
+++ b/kurator/CMakeLists.txt
@@ -7,6 +7,7 @@ add_executable(
src/Skybox.cpp
src/SkyboxTest.cpp
src/Title.cpp
+ src/Window.cpp
)
target_link_libraries(
${PROJECT_NAME}
diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp
index 07b19f1..9bb5de3 100644
--- a/kurator/src/Session.cpp
+++ b/kurator/src/Session.cpp
@@ -19,14 +19,16 @@ Session::set(std::shared_ptr<Scene> _scene)
void
-Session::loop()
+Session::run()
{
- if (!scene)
- return;
- scene->update(GetFrameTime());
- BeginDrawing();
- scene->draw();
- EndDrawing();
+ while (!window.should_close()) {
+ if (!scene)
+ return;
+ scene->update(GetFrameTime());
+ BeginDrawing();
+ scene->draw();
+ EndDrawing();
+ }
}
diff --git a/kurator/src/Session.h b/kurator/src/Session.h
index cc8a4ee..43f5747 100644
--- a/kurator/src/Session.h
+++ b/kurator/src/Session.h
@@ -3,6 +3,7 @@
#include <memory>
#include "Scene.h"
+#include "Window.h"
namespace kurator
@@ -13,8 +14,9 @@ class Session
{
public:
void set(std::shared_ptr<Scene> _scene);
- void loop();
+ void run();
private:
+ Window window;
std::shared_ptr<Scene> scene;
};
diff --git a/kurator/src/Window.cpp b/kurator/src/Window.cpp
new file mode 100644
index 0000000..5711243
--- /dev/null
+++ b/kurator/src/Window.cpp
@@ -0,0 +1,31 @@
+#include "Window.h"
+
+#include <raylib.h>
+
+
+namespace kurator
+{
+
+
+Window::Window()
+{
+ InitWindow(800, 600, "Kurator");
+ SetWindowState(FLAG_WINDOW_RESIZABLE);
+ SetTargetFPS(60);
+}
+
+
+Window::~Window()
+{
+ CloseWindow();
+}
+
+
+bool
+Window::should_close() const
+{
+ return WindowShouldClose();
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/Window.h b/kurator/src/Window.h
new file mode 100644
index 0000000..2d1e58b
--- /dev/null
+++ b/kurator/src/Window.h
@@ -0,0 +1,17 @@
+#pragma once
+
+
+namespace kurator
+{
+
+
+class Window
+{
+public:
+ Window();
+ ~Window();
+ bool should_close() const;
+};
+
+
+} // namespace kurator
diff --git a/kurator/src/main.cpp b/kurator/src/main.cpp
index 112be1a..1a4c325 100644
--- a/kurator/src/main.cpp
+++ b/kurator/src/main.cpp
@@ -1,7 +1,5 @@
#include <memory>
-#include <raylib.h>
-
#include "Session.h"
#include "Title.h"
@@ -9,11 +7,7 @@
int
main(int, char*[])
{
- InitWindow(800, 600, "Kurator");
auto session = std::make_shared<kurator::Session>();
- auto title = std::make_shared<kurator::Title>(session);
- session->set(title);
- while (!WindowShouldClose())
- session->loop();
- CloseWindow();
+ session->set(std::make_shared<kurator::Title>(session));
+ session->run();
}