Skip to content
This repository was archived by the owner on Aug 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1fff785
feat: refactor to be an engine
RickaPrincy Dec 30, 2025
5e4123c
chore: uniform utility
RickaPrincy Dec 30, 2025
bb93890
feat: multiple_view
RickaPrincy Dec 30, 2025
af3f187
chore: extends gl utilities
RickaPrincy Dec 31, 2025
3197dad
wip: feat: color_shape
RickaPrincy Dec 31, 2025
200162e
fix: colored_shape
RickaPrincy Jan 2, 2026
3483afc
refactor: separate 2d & 3d
RickaPrincy Jan 18, 2026
2bd0d6e
wip: feat: polygon_shape with texture or color
RickaPrincy Jan 18, 2026
4dd1b6c
fix: polygon with texture
RickaPrincy Jan 18, 2026
2d2ec69
wip: msdf-atlas-gen
RickaPrincy Jan 18, 2026
41ac0b2
wip: load ascii charset
RickaPrincy Jan 21, 2026
f2a346d
wip: msdf_font with load char
RickaPrincy Jan 24, 2026
b83ed64
wip: feat: test rendering glyphs
RickaPrincy Jan 24, 2026
e56b0fc
wip: fix: vao of msdf
RickaPrincy Jan 24, 2026
ce87db1
wip: fix getting glyph
RickaPrincy Jan 25, 2026
9892b57
refactor: color
RickaPrincy Jan 25, 2026
9e3f8d3
refactor: text_shape
RickaPrincy Jan 25, 2026
7a16788
fix: dynamic atlas
RickaPrincy Jan 27, 2026
c62808d
wip: feat: text in pixel
RickaPrincy Jan 31, 2026
ee3d89b
wip: feat: integrate imgui
RickaPrincy Feb 1, 2026
b477683
chore: disable dpi
RickaPrincy Feb 1, 2026
faba4dd
wip: active dpi only from imgui side
RickaPrincy Feb 1, 2026
8cf4abe
wip: feat: configure engine package
RickaPrincy Feb 1, 2026
a947238
feat: first page
RickaPrincy Feb 7, 2026
d1b7c30
feat: setup nfd
RickaPrincy Feb 7, 2026
27be765
refactor: move gl_texture
RickaPrincy Feb 7, 2026
6e6de79
wip: feat: project loading
RickaPrincy May 17, 2026
916f22f
feat: project_editor_view
RickaPrincy May 17, 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
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "external/msdf-atlas-gen"]
path = external/msdf-atlas-gen
url = https://github.com/Chlumsky/msdf-atlas-gen.git
[submodule "external/imgui"]
path = external/imgui
url = https://github.com/ocornut/imgui.git
[submodule "external/nfd-extended"]
path = external/nfd-extended
url = https://github.com/btzy/nativefiledialog-extended.git
2 changes: 2 additions & 0 deletions .templates/sdlkConfig.hpp.in
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#pragma once

#define SDLK_VERSION "@SDLK_VERSION@"
68 changes: 37 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,69 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# SDL2
find_package(Freetype REQUIRED)
find_package(glm CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(SDL2_image CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_path(EARCUT_HPP_INCLUDE_DIRS "mapbox/earcut.hpp")

find_package(Freetype REQUIRED)

set(SDLK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SDLK_IS_MAIN_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SDLK_IS_MAIN_PROJECT ON)
endif()
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SDLK_IS_MAIN_PROJECT ON)
endif ()

# target names
set(SDLK_LIB_NAME sdlk)
set(SDLK_LIB_VERSION ${PROJECT_VERSION})
set(SDLK_LIB_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})

set(SDLK_ENGINE_NAME sdlk_engine)
set(SDLK_ENGINE_VERSION ${PROJECT_VERSION})
set(SDLK_ENGINE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})

set(SDLK_VERSION ${PROJECT_VERSION})
set(SDLK_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})

# list of options
option(BUILD_SHARED_LIBS "Build rcli as a shared library" ON)
option(SDLK_LIB_BUILD "Build sdlk lib" ON)
option(BUILD_SHARED_LIBS "Build sdlk as a shared library" ON)
option(SDLK_LIB_INSTALL "Install sdlk lib" OFF)
option(SDLK_BUILD_EXAMPLE "Build sdlk example" OFF)
option(SDLK_BUILD_EXAMPLES "Build sdlk example" ON)

option(SDLK_ENGINE_BUILD "Build sdlk engine lib" ON)
option(SDLK_ENGINE_INSTALL "Install sdlk engine lib" OFF)

# configure build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif ()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SDLK_TEST OFF)
set(SDLK_BUILD_EXAMPLE OFF)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(SDLK_TEST OFF)
set(SDLK_BUILD_EXAMPLES OFF)
endif ()

if(SDLK_IS_MAIN_PROJECT)
configure_file(${SDLK_SOURCE_DIR}/.templates/PKGBUILD.in
${SDLK_SOURCE_DIR}/PKGBUILD @ONLY)
if (SDLK_IS_MAIN_PROJECT)
configure_file(${SDLK_SOURCE_DIR}/.templates/PKGBUILD.in
${SDLK_SOURCE_DIR}/PKGBUILD @ONLY)

configure_file(${SDLK_SOURCE_DIR}/.templates/install.sh.in
${SDLK_SOURCE_DIR}/install.sh @ONLY)
configure_file(${SDLK_SOURCE_DIR}/.templates/install.sh.in
${SDLK_SOURCE_DIR}/install.sh @ONLY)

configure_file(${SDLK_SOURCE_DIR}/.templates/create-release.sh.in
${SDLK_SOURCE_DIR}/create-release.sh @ONLY)
configure_file(${SDLK_SOURCE_DIR}/.templates/create-release.sh.in
${SDLK_SOURCE_DIR}/create-release.sh @ONLY)

configure_file(
${SDLK_SOURCE_DIR}/.templates/${SDLK_LIB_NAME}Config.hpp.in
${SDLK_SOURCE_DIR}/include/${SDLK_LIB_NAME}/${SDLK_LIB_NAME}Config.hpp
@ONLY)
endif()
configure_file(
${SDLK_SOURCE_DIR}/.templates/${SDLK_LIB_NAME}Config.hpp.in
${SDLK_SOURCE_DIR}/include/${SDLK_LIB_NAME}/${SDLK_LIB_NAME}Config.hpp
@ONLY)
endif ()

add_subdirectory(external/nfd-extended)
add_subdirectory(external/msdf-atlas-gen)
add_subdirectory(sources)

if(SDLK_BUILD_EXAMPLE)
add_subdirectory(examples)
endif()
add_subdirectory(examples)

# CPack configuration
set(CPACK_PACKAGE_VENDOR "RickaPrincy <rckprincy@gmail.com>")
Expand Down
8 changes: 5 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"MSDF_ATLAS_USE_SKIA": "OFF",
"MSDF_ATLAS_USE_VCPKG": "ON",
"CMAKE_TOOLCHAIN_FILE": "/home/ricka/Apk/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
Expand All @@ -15,7 +17,7 @@
"displayName": "Build with vcpkg (Debug)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"SDLK_BUILD_EXAMPLE": "ON"
"SDLK_BUILD_EXAMPLES": "ON"
}
},
{
Expand All @@ -24,7 +26,7 @@
"displayName": "Build with vcpkg (Release)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"SDLK_BUILD_EXAMPLE": "OFF"
"SDLK_BUILD_EXAMPLES": "OFF"
}
}
],
Expand Down
38 changes: 38 additions & 0 deletions cmake/sdlk_resources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function(set_sdlk_resources TARGET)
set(options)
set(oneValueArgs DESTINATION)
set(multiValueArgs FILES DIRECTORIES)

cmake_parse_arguments(SDLK
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)

if (NOT SDLK_DESTINATION)
set(SDLK_DESTINATION "resources")
endif()

foreach(file ${SDLK_FILES})
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${file}
$<TARGET_FILE_DIR:${TARGET}>/${SDLK_DESTINATION}/user/${file}
)
endforeach()

foreach(dir ${SDLK_DIRECTORIES})
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${dir}
$<TARGET_FILE_DIR:${TARGET}>/${SDLK_DESTINATION}/user/${dir}
)
endforeach()

add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${SDLK_ENGINE_RESOURCE_DIR}
$<TARGET_FILE_DIR:${TARGET}>/${SDLK_DESTINATION}/engine
)
endfunction()
4 changes: 3 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
add_executable(example main.cpp)
add_executable(example main.cpp
../include/sdlk/core/imgui/imgui_drawer_utils.hpp
../include/sdlk/extra/nfd_wrapper.hpp)

target_include_directories(example PRIVATE ${SDLK_SOURCE_DIR}/include)

Expand Down
102 changes: 59 additions & 43 deletions examples/main.cpp
Original file line number Diff line number Diff line change
@@ -1,60 +1,76 @@
#include <SDL2/SDL_events.h>

#include <iostream>
#include <sdlk/core/app.hpp>
#include <sdlk/core/component.hpp>
#include <sdlk/core/events/types.hpp>
#include <sdlk/core/freetype_font.hpp>
#include <sdlk/core/shape.hpp>
#include <sdlk/core/types.hpp>
#include <sdlk/core/components/2d/fonts/msdf_font.hpp>
#include <sdlk/core/components/2d/shape/polygon_shape.hpp>
#include <sdlk/core/components/2d/shape/rectangle_shape.hpp>
#include <sdlk/core/components/2d/shape/text_shape.hpp>
#include <sdlk/core/components/component.hpp>

using namespace sdlk;

static constexpr int WINDOW_WIDTH = 1000;
static constexpr int WINDOW_HEIGHT = 1000;
auto home() -> std::shared_ptr<renderable>;
auto text_hello_world() -> std::shared_ptr<renderable>;
auto rectangle_with_texture() -> std::shared_ptr<renderable>;
auto rectangle_with_uniform_color() -> std::shared_ptr<renderable>;
auto rectangle_with_vertex_color() -> std::shared_ptr<renderable>;

auto main(int argc, char** argv) -> int
auto main(const int argc, char** argv) -> int
{
app myapp("Hello World", WINDOW_WIDTH, WINDOW_HEIGHT);
app rc_engine("RC_Engine", 1200, 800);

rc_engine.add_view("home", home());

auto image = texture::from_file("./resources/assets/images/image.png");
textured_shape shape(
std::move(polygon(quad::make(image->get_width() / 2, image->get_height() / 2))),
quad::make(image->get_width() / 2, image->get_height() / 2),
image);
rc_engine.add_event_listener(
event_type::key_up, [&](const SDL_Event& event) { std::cout << "Clicked \n"; });

textured_shape shape2(
std::move(polygon(quad::make(image->get_width() / 2, image->get_height() / 2))),
quad::make(image->get_width() / 2, image->get_height() / 2),
image);
return rc_engine.run("home", argc, argv);
}

shape2.translate({ 40.f, 50.f });
auto home() -> std::shared_ptr<renderable>
{
auto home = std::make_shared<component>();

colored_shape test(polygon({
{ 0, 0 },
{ 50, 0 },
{ 50, 50 },
{ 0, 50 },
}),
{ 255, 0, 0, 255 },
true);
home->add_child(rectangle_with_uniform_color());
home->add_child(text_hello_world());

auto font = freetype_font::make("./resources/assets/font/arial.ttf");
return home;
}

auto text_hello_world() -> std::shared_ptr<renderable>
{
auto font = msdf_font::make("./resources/assets/fonts/arial.ttf");
return std::make_shared<sdlk2d::text_shape>(U"Hello World helloé",
sdlk2d::text_style{ .m_size = 20.0f, .m_fg_color = color::white() },
font);
}

text_shape blibli("hello world", font, { 255, 0, 0, 255 });
auto rectangle_with_uniform_color() -> std::shared_ptr<renderable>
{
return std::make_shared<sdlk2d::rectangle_shape>(
sdlk2d::type::point{ 0.0f, 0.0f }, 100.0f, 100.0f, color::red());
}

myapp.add_renderable(&shape);
myapp.add_renderable(&shape2);
myapp.add_renderable(&test);
myapp.add_renderable(&blibli);
auto rectangle_with_vertex_color() -> std::shared_ptr<renderable>
{
sdlk2d::type::polygon triangle_with_color = { sdlk2d::type::vertex(
{ -1.0f, -1.0f }, color::blue()),
sdlk2d::type::vertex({ 0.0f, 1.0f }, color::red()),
sdlk2d::type::vertex({ 1.0f, -1.0f }, color::green()) };
return std::make_shared<sdlk2d::polygon_shape>(triangle_with_color);
}

myapp.add_event_listener(
event_type::key_down, [&](const SDL_Event& event) { shape.translate({ 50, 50 }); });
auto rectangle_with_texture() -> std::shared_ptr<renderable>
{
const auto texture = gl_texture::from_file("./resources/assets/images/image.png");

myapp.add_event_listener(event_type::mouse_button_down,
[&](const SDL_Event& event) { shape.translate({ 100, 100 }); });
sdlk2d::type::polygon rect_with_uv = { sdlk2d::type::vertex(
{ 0.5f, 1.0f }, glm::vec2{ 0.0f, 0.0f }),
sdlk2d::type::vertex({ 1.0f, 1.0f }, glm::vec2{ 1.0f, 0.0f }),
sdlk2d::type::vertex({ 1.0f, 0.5f }, glm::vec2{ 1.0f, 1.0f }),

myapp.add_event_listener(
event_type::mouse_button_up, [&](const SDL_Event&) { shape.scale(1.1f); });
sdlk2d::type::vertex({ 0.5f, 1.0f }, glm::vec2{ 0.0f, 0.0f }),
sdlk2d::type::vertex({ 1.0f, 0.5f }, glm::vec2{ 1.0f, 1.0f }),
sdlk2d::type::vertex({ 0.5f, 0.5f }, glm::vec2{ 0.0f, 1.0f }) };

return myapp.run(argc, argv);
}
return std::make_shared<sdlk2d::polygon_shape>(rect_with_uv, texture);
}
Binary file modified examples/resources/assets/images/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions external/imgui
Submodule imgui added at 5166be
1 change: 1 addition & 0 deletions external/msdf-atlas-gen
Submodule msdf-atlas-gen added at 77804c
1 change: 1 addition & 0 deletions external/nfd-extended
Submodule nfd-extended added at fc168e
Loading
Loading