updated TSE to be able to use SDL3

This commit is contained in:
2026-03-23 19:01:34 +01:00
parent f637f0ec08
commit 6edcaa9c11
9 changed files with 174 additions and 67 deletions

View File

@@ -12,8 +12,10 @@
"${workspaceFolder}/TSE/TSE_Math/src", "${workspaceFolder}/TSE/TSE_Math/src",
"${workspaceFolder}/TSE/TSE_GlfwImpl/include", "${workspaceFolder}/TSE/TSE_GlfwImpl/include",
"${workspaceFolder}/TSE/TSE_GlfwImpl/src", "${workspaceFolder}/TSE/TSE_GlfwImpl/src",
"${workspaceFolder}/TSE/TSE_GlfwOpenGlImpl/include", "${workspaceFolder}/TSE/TSE_OpenGlImpl/include",
"${workspaceFolder}/TSE/TSE_GlfwOpenGlImpl/src", "${workspaceFolder}/TSE/TSE_OpenGlImpl/src",
"${workspaceFolder}/TSE/TSE_Sdl3Impl/include",
"${workspaceFolder}/TSE/TSE_Sdl3Impl/src",
"${workspaceFolder}/TSE/TSE_Editor/src" "${workspaceFolder}/TSE/TSE_Editor/src"
], ],
"defines": [], "defines": [],

6
.vscode/tasks.json vendored
View File

@@ -33,7 +33,8 @@
"-DCMAKE_C_COMPILER=clang", "-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++", "-DCMAKE_CXX_COMPILER=clang++",
"-DCMAKE_LINKER=lld-link", "-DCMAKE_LINKER=lld-link",
"-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_BUILD_TYPE=Debug",
"-DUSE_SDL3=ON"
], ],
"group": { "group": {
"kind": "build", "kind": "build",
@@ -55,7 +56,8 @@
"-DCMAKE_C_COMPILER=clang", "-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++", "-DCMAKE_CXX_COMPILER=clang++",
"-DCMAKE_LINKER=lld-link", "-DCMAKE_LINKER=lld-link",
"-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_BUILD_TYPE=Release",
"-DUSE_SDL3=ON"
], ],
"group": { "group": {
"kind": "build", "kind": "build",

View File

@@ -4,6 +4,28 @@ cmake_minimum_required(VERSION 3.31)
#project name #project name
project(TSE-RTS) project(TSE-RTS)
# backend selection
option(USE_GLFW "Build with GLFW backend" OFF)
option(USE_SDL3 "Build with SDL3 backend" OFF)
# default backend: GLFW
if(NOT USE_GLFW AND NOT USE_SDL3)
set(USE_GLFW ON)
endif()
# forbid enabling both at once
if(USE_GLFW AND USE_SDL3)
message(FATAL_ERROR "USE_GLFW and USE_SDL3 cannot both be ON. Select exactly one backend.")
endif()
if(USE_GLFW)
message(STATUS "Window backend: GLFW")
endif()
if(USE_SDL3)
message(STATUS "Window backend: SDL3")
endif()
#cpp settings #cpp settings
find_program(CLANG_C NAMES clang) find_program(CLANG_C NAMES clang)
find_program(CLANG_CXX NAMES clang++) find_program(CLANG_CXX NAMES clang++)
@@ -28,8 +50,15 @@ add_subdirectory(TSE/TSE_Base)
add_subdirectory(TSE/TSE_Math) add_subdirectory(TSE/TSE_Math)
add_subdirectory(TSE/TSE_Core) add_subdirectory(TSE/TSE_Core)
add_subdirectory(TSE/TSE_Editor) add_subdirectory(TSE/TSE_Editor)
add_subdirectory(TSE/TSE_OpenGlImpl)
if(USE_GLFW)
add_subdirectory(TSE/TSE_GlfwImpl) add_subdirectory(TSE/TSE_GlfwImpl)
add_subdirectory(TSE/TSE_GlfwOpenGlImpl) endif()
if(USE_SDL3)
add_subdirectory(TSE/TSE_Sdl3Impl)
endif()
#source files #source files
file(GLOB CPP_SOURCE file(GLOB CPP_SOURCE
@@ -43,28 +72,53 @@ file(GLOB CPP_SOURCE
"${PROJECT_SOURCE_DIR}/TSE-RTS/src/*/*/*/*.c" "${PROJECT_SOURCE_DIR}/TSE-RTS/src/*/*/*/*.c"
) )
#includes
include_directories(${PROJECT_SOURCE_DIR}/TSE-RTS/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE-RTS/include)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Math/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Core/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Base/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Base/include)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_Editor/src)
#includes Glfw
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwOpenGlImpl/src)
include_directories(${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwOpenGlImpl/include)
#project def #project def
add_executable(TSE-RTS ${CPP_SOURCE}) add_executable(TSE-RTS ${CPP_SOURCE})
# includes
target_include_directories(TSE-RTS PRIVATE
${PROJECT_SOURCE_DIR}/TSE-RTS/src
${PROJECT_SOURCE_DIR}/TSE-RTS/include
${PROJECT_SOURCE_DIR}/TSE/TSE_Math/src
${PROJECT_SOURCE_DIR}/TSE/TSE_Core/src
${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include
${PROJECT_SOURCE_DIR}/TSE/TSE_Base/src
${PROJECT_SOURCE_DIR}/TSE/TSE_Base/include
${PROJECT_SOURCE_DIR}/TSE/TSE_Editor/src
${PROJECT_SOURCE_DIR}/TSE/TSE_OpenGlImpl/src
${PROJECT_SOURCE_DIR}/TSE/TSE_OpenGlImpl/include
)
if(USE_GLFW)
target_include_directories(TSE-RTS PRIVATE
${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/src
${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include
)
endif()
if(USE_SDL3)
target_include_directories(TSE-RTS PRIVATE
${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/src
${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include
)
endif()
# compile definitions for active backend
if(USE_GLFW)
target_compile_definitions(TSE-RTS PRIVATE TSE_WINDOW_BACKEND_GLFW)
endif()
if(USE_SDL3)
target_compile_definitions(TSE-RTS PRIVATE TSE_WINDOW_BACKEND_SDL3)
endif()
# external libs
set(LIB_SOURCE "")
set(BACKEND_LIBS "")
set(BACKEND_TARGETS "")
if(WIN32) if(WIN32)
if(DEBUG) if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEBUGSPEC set(DEBUGSPEC
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.d.lib" "${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.d.lib"
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2dd.lib" "${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2dd.lib"
@@ -75,38 +129,67 @@ if (WIN32)
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2d.lib" "${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/box2d.lib"
) )
endif() endif()
set(LIB_SOURCE set(LIB_SOURCE
${DEBUGSPEC}
)
if(USE_GLFW)
list(APPEND LIB_SOURCE
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/glfw3.lib" "${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/glfw3.lib"
# "${PROJECT_SOURCE_DIR}/../TSE.Core/lib/freetype.lib"
"${DEBUGSPEC}"
)
else()
set(LIB_SOURCE
# "${PROJECT_SOURCE_DIR}/../TSE.Core/lib/libfreetype.a"
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libfreeimage.a"
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/libglfw3.a"
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libbox2d.a"
) )
list(APPEND BACKEND_TARGETS TSE_GlfwImpl)
endif() endif()
if(USE_SDL3)
list(APPEND LIB_SOURCE
"${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include/SDL3.lib"
)
list(APPEND BACKEND_TARGETS TSE_Sdl3Impl)
endif()
else()
set(LIB_SOURCE
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libfreeimage.a"
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/libbox2d.a"
)
if(USE_GLFW)
list(APPEND LIB_SOURCE
"${PROJECT_SOURCE_DIR}/TSE/TSE_GlfwImpl/include/libglfw3.a"
)
list(APPEND BACKEND_TARGETS TSE_GlfwImpl)
endif()
if(USE_SDL3)
list(APPEND LIB_SOURCE
"${PROJECT_SOURCE_DIR}/TSE/TSE_Sdl3Impl/include/libSDL3.a"
)
list(APPEND BACKEND_TARGETS TSE_Sdl3Impl)
endif()
endif()
# link
if(WIN32) if(WIN32)
target_link_libraries(TSE-RTS PUBLIC target_link_libraries(TSE-RTS PUBLIC
TSE_Base TSE_Base
TSE_Math TSE_Math
TSE_Core TSE_Core
TSE_GlfwImpl ${BACKEND_TARGETS}
TSE_GlfwOpenGlImpl TSE_OpenGlImpl
TSE_Editor TSE_Editor
${LIB_SOURCE}) ${LIB_SOURCE}
)
else() else()
target_link_libraries(TSE-RTS PUBLIC target_link_libraries(TSE-RTS PUBLIC
TSE_Editor TSE_Editor
TSE_GlfwOpenGlImpl TSE_OpenGlImpl
TSE_GlfwImpl ${BACKEND_TARGETS}
TSE_Core TSE_Core
TSE_Math TSE_Math
TSE_Base TSE_Base
${LIB_SOURCE}) ${LIB_SOURCE}
)
endif() endif()
# flags # flags

2
TSE

Submodule TSE updated: f859288689...a596028ed9

View File

@@ -1,7 +1,12 @@
#include <iostream> #include <iostream>
#include "GL/gl3w.h" #include "GL/gl3w.h"
#include "globalVars.hpp" #include "globalVars.hpp"
#include "WindowManager.hpp"
#if defined(TSE_GLFW)
#include "WindowGlfw.hpp" #include "WindowGlfw.hpp"
#elif defined(TSE_SDL3)
#include "WindowSdl3.hpp"
#endif
#include "OpenGLRenderingBackend.hpp" #include "OpenGLRenderingBackend.hpp"
#include "imgui/imgui.h" #include "imgui/imgui.h"
#include "shader/defaultShaderHandler.cpp" #include "shader/defaultShaderHandler.cpp"
@@ -21,7 +26,12 @@
#define USE_EDITOR #define USE_EDITOR
using namespace TSE; using namespace TSE;
#if defined(TSE_GLFW)
using namespace TSE::GLFW; using namespace TSE::GLFW;
#elif defined(TSE_SDL3)
using namespace TSE::SDL3;
#endif
using namespace TSE::OpenGL;
using namespace TSE::EDITOR; using namespace TSE::EDITOR;
IWindow* wnd = nullptr; IWindow* wnd = nullptr;
@@ -33,12 +43,22 @@ EditorSubsystem* editor;
void SetupWindow() void SetupWindow()
{ {
Color backColor(0.0f, 0.0f, 0.0f, 0.0f); Color backColor(0.0f, 0.0f, 0.0f, 0.0f);
#if defined(TSE_GLFW)
#ifdef USE_EDITOR #ifdef USE_EDITOR
wnd = new WindowGlfw(PROJECT_NAME, 800, 600, new OpenGLRenderingBackend(backColor, false, 8, true), WindowType::Maximized); wnd = new WindowGlfw(PROJECT_NAME, 800, 600, new OpenGLRenderingBackend(backColor, false, 8, true), WindowType::Maximized);
editor = new EditorSubsystem(); editor = new EditorSubsystem();
#else #else
wnd = new WindowGlfw(PROJECT_NAME, 1920, 1080, new OpenGLRenderingBackend(backColor, false, 8, false), WindowType::Fullscreen); wnd = new WindowGlfw(PROJECT_NAME, 1920, 1080, new OpenGLRenderingBackend(backColor, false, 8, false), WindowType::Fullscreen);
#endif #endif
#elif defined(TSE_SDL3)
#ifdef USE_EDITOR
wnd = new WindowSdl3(PROJECT_NAME, 800, 600, new OpenGLRenderingBackend(backColor, false, 8, true), WindowType::Maximized);
editor = new EditorSubsystem();
#else
wnd = new WindowSdl3(PROJECT_NAME, 1920, 1080, new OpenGLRenderingBackend(backColor, false, 8, false), WindowType::Fullscreen);
#endif
#endif
LoadBasicShaders(wnd->GetSize().x, wnd->GetSize().y); LoadBasicShaders(wnd->GetSize().x, wnd->GetSize().y);
TileMapShader::Init(wnd->GetSize().x, wnd->GetSize().y); TileMapShader::Init(wnd->GetSize().x, wnd->GetSize().y);
LastPassShader::Init(wnd->GetSize().x, wnd->GetSize().y); LastPassShader::Init(wnd->GetSize().x, wnd->GetSize().y);

View File

@@ -5,7 +5,7 @@
#include "LastPassShaderGLSL.hpp" #include "LastPassShaderGLSL.hpp"
using namespace TSE; using namespace TSE;
using namespace TSE::GLFW; using namespace TSE::OpenGL;
#define SHADER_VERTEX_INDEX 0 #define SHADER_VERTEX_INDEX 0
#define SHADER_UV_INDEX 1 #define SHADER_UV_INDEX 1
@@ -43,7 +43,7 @@ void LastPassShader::Init(float width, float height)
instance->Disable(); instance->Disable();
} }
LastPassShader::LastPassShader(std::vector<std::unique_ptr<TSE::GLFW::ShaderPart>> &&parts) : Shader(parts) LastPassShader::LastPassShader(std::vector<std::unique_ptr<TSE::OpenGL::ShaderPart>> &&parts) : Shader(parts)
{ {
PackageSize = SHADER_PACKAGE_SIZE; PackageSize = SHADER_PACKAGE_SIZE;
} }

View File

@@ -5,7 +5,7 @@
#include "shader/Shader.hpp" #include "shader/Shader.hpp"
#include "Types.hpp" #include "Types.hpp"
class LastPassShader : public TSE::GLFW::Shader class LastPassShader : public TSE::OpenGL::Shader
{ {
private: private:
static LastPassShader* instance; static LastPassShader* instance;
@@ -22,7 +22,7 @@ public:
static LastPassShader* Instance(); static LastPassShader* Instance();
static void Destroy(); static void Destroy();
static void Init(float width, float height); static void Init(float width, float height);
LastPassShader(std::vector<std::unique_ptr<TSE::GLFW::ShaderPart>>&& parts); LastPassShader(std::vector<std::unique_ptr<TSE::OpenGL::ShaderPart>>&& parts);
protected: protected:
void OnEnable() const override; void OnEnable() const override;

View File

@@ -5,7 +5,7 @@
#include "TileMapShaderGLSL.hpp" #include "TileMapShaderGLSL.hpp"
using namespace TSE; using namespace TSE;
using namespace TSE::GLFW; using namespace TSE::OpenGL;
#define SHADER_MESH_INDEX 0 #define SHADER_MESH_INDEX 0
#define SHADER_POS_INDEX 1 #define SHADER_POS_INDEX 1

View File

@@ -5,7 +5,7 @@
#include "shader/Shader.hpp" #include "shader/Shader.hpp"
#include "Types.hpp" #include "Types.hpp"
class TileMapShader : public TSE::GLFW::Shader class TileMapShader : public TSE::OpenGL::Shader
{ {
private: private:
static TileMapShader* instance; static TileMapShader* instance;
@@ -31,7 +31,7 @@ public:
static TileMapShader* Instance(); static TileMapShader* Instance();
static void Destroy(); static void Destroy();
static void Init(float width, float height); static void Init(float width, float height);
TileMapShader(std::vector<std::unique_ptr<TSE::GLFW::ShaderPart>>&& parts); TileMapShader(std::vector<std::unique_ptr<TSE::OpenGL::ShaderPart>>&& parts);
~TileMapShader(); ~TileMapShader();
void SetMesh(const void* verts, int vertCount, int stride, int floatCountPerVertex, int posOffsetBytes, GLenum primitive, const void* indices = nullptr, int indexCount = 0, GLenum indexType = GL_UNSIGNED_SHORT); void SetMesh(const void* verts, int vertCount, int stride, int floatCountPerVertex, int posOffsetBytes, GLenum primitive, const void* indices = nullptr, int indexCount = 0, GLenum indexType = GL_UNSIGNED_SHORT);