Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fb4348d
- finish the base class Unit
CoraBlack Feb 12, 2026
19b5a92
complete the comment of unit.hpp and re-format code about unit class
CoraBlack Feb 12, 2026
824527b
- update test/scene/test_unit.cpp
CoraBlack Feb 12, 2026
d4d2011
Merge branch 'PenguinsCampCN:dev' into feature/scene
CoraBlack Feb 14, 2026
928fe1d
Merge pull request #6 from CoraBlack/feature/scene
CoraBlack Feb 14, 2026
32c5ea3
Merge pull request #12 from AntarcticaCamp/dev
CoraBlack Feb 18, 2026
b58670a
iterator add
17-qxm Feb 19, 2026
0e5c7ec
coding style change
17-qxm Feb 19, 2026
0c83bf4
Merge pull request #16 from 17-qxm/scene/unit
CoraBlack Feb 19, 2026
bc8e159
Revert "iterator add"
CoraBlack Feb 19, 2026
2f10b45
Merge pull request #17 from AntarcticaCamp/revert-16-scene/unit
CoraBlack Feb 19, 2026
484f642
coding style change about auto use
17-qxm Feb 19, 2026
e7c8717
now cache would not update every begin() or end()
17-qxm Feb 19, 2026
b8c8537
Merge branch 'scene/unit' into scene/unit
17-qxm Feb 19, 2026
1bde6ee
fix the header file problem
17-qxm Feb 21, 2026
9ea508b
find some auto not use problem and fixed it
17-qxm Feb 21, 2026
b7a08b1
Merge pull request #18 from 17-qxm/scene/unit
CoraBlack Feb 21, 2026
5f21883
Unit test additions and some duplicate items and bug cleanup
17-qxm Feb 21, 2026
c522a32
Apply suggestion from @Copilot
CoraBlack Feb 22, 2026
20021a4
Apply suggestions from code review
CoraBlack Feb 22, 2026
a90d275
apply suggestions needed
17-qxm Feb 22, 2026
ceed052
Merge branch 'scene/unit' of https://github.com/17-qxm/libgkit into s…
17-qxm Feb 22, 2026
441fa8b
Merge pull request #19 from 17-qxm/scene/unit
CoraBlack Feb 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ file(GLOB_RECURSE CORE_SRC
"./application/*.cpp"
"./graphic/*.cpp"
# "./input/*.cpp"
"./scene/*.cpp"
"./resource/*cpp"
"./utils/*.cpp"
"./*.cpp"
Expand Down
24 changes: 22 additions & 2 deletions src/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_log.h>

gkit::Application::Application() noexcept {
gkit::Application::Application() noexcept : root(), windows() {
SDL_InitFlags flags = SDL_INIT_AUDIO |
SDL_INIT_EVENTS |
SDL_INIT_GAMEPAD |
Expand All @@ -18,4 +18,24 @@ gkit::Application::Application() noexcept {

gkit::Application::~Application() noexcept {
SDL_Quit();
}
}


auto gkit::Application::set_root(std::unique_ptr<scene::Unit>&& root_ptr) noexcept -> void {
if (root_ptr == nullptr) return;
this->root = std::move(root_ptr);
}


auto gkit::Application::run() -> void {
this->root->ready_handler();
this->running.store(true);
while (this->running.load()) {
this->root->process_handler();
}
}


auto gkit::Application::stop() -> void {
this->running.store(false);
}
13 changes: 7 additions & 6 deletions src/core/graphic/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_video.h>

gkit::Window::Window(std::string title, int width, int height) noexcept
: window_ptr(SDL_CreateWindow(title.c_str(), width, height, SDL_WINDOW_RESIZABLE), SDL_DestroyWindow)
gkit::graphic::Window::Window(std::string title, int width, int height) noexcept
: gkit::scene::Unit()
, window_ptr(SDL_CreateWindow(title.c_str(), width, height, SDL_WINDOW_RESIZABLE), SDL_DestroyWindow)
, renderer_ptr(SDL_CreateRenderer(this->window_ptr.get(), nullptr), SDL_DestroyRenderer) {

if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
SDL_Log("SDL_INIT_VIDEO initialize failed, error: %s", SDL_GetError());
}
}

gkit::Window::Window(std::string title, int width, int height, std::vector<SDL_WindowFlags> flags) noexcept
: gkit::Window::Window(title, width, height) {
gkit::graphic::Window::Window(std::string title, int width, int height, std::vector<SDL_WindowFlags> flags) noexcept
: gkit::graphic::Window::Window(title, width, height) {
SDL_WindowFlags win_flags = 0x00ul;
for (auto flag : flags) {
win_flags |= flag;
Expand All @@ -23,10 +24,10 @@ gkit::Window::Window(std::string title, int width, int height, std::vector<SDL_W
this->window_ptr.reset(SDL_CreateWindow(title.c_str(), width, height, win_flags));
}

void gkit::Window::hide() noexcept {
void gkit::graphic::Window::hide() noexcept {
SDL_HideWindow(this->window_ptr.get());
}

void gkit::Window::show() noexcept {
void gkit::graphic::Window::show() noexcept {
SDL_ShowWindow(this->window_ptr.get());
}
16 changes: 16 additions & 0 deletions src/core/include/application.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
#pragma once

#include "graphic/window.hpp"
#include "scene/unit.hpp"
#include <atomic>
#include <memory>
#include <vector>

namespace gkit {

class Application {
public:
explicit Application() noexcept;
virtual ~Application() noexcept;

public:
auto run() -> void;
auto stop() -> void;

auto set_root(std::unique_ptr<scene::Unit>&& root_ptr) noexcept -> void;

private:
std::unique_ptr<scene::Unit> root;
std::vector<std::unique_ptr<gkit::graphic::Window>> windows;

std::atomic<bool> running = false;
}; // class Application

} // namespace gkit
4 changes: 4 additions & 0 deletions src/core/include/gkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// Graphic
#include <graphic/window.hpp>

// Scene
#include <scene/unit.hpp>
#include <scene/object.hpp>

// Resource
#include <resource/resource.hpp>
#include <resource/texture.hpp>
Expand Down
5 changes: 3 additions & 2 deletions src/core/include/graphic/window.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once

#include "scene/unit.hpp"
#include <SDL3/SDL.h>
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_video.h>
#include <string>
#include <memory>
#include <vector>

namespace gkit {
namespace gkit::graphic {

class Window {
class Window : gkit::scene::Unit{
public:
Window(std::string title, int width, int height) noexcept;
Window(std::string title, int width, int height, std::vector<SDL_WindowFlags> flags) noexcept;
Expand Down
13 changes: 13 additions & 0 deletions src/core/include/scene/object.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "unit.hpp"
namespace gkit::scene {
/**
* @brief This is the basic unit of game composition
*/
class Object : protected gkit::scene::Unit {
public:
Object() = default;
virtual ~Object();
};
}
Loading