updated TSE to be able to use SDL3
This commit is contained in:
6
.vscode/c_cpp_properties.json
vendored
6
.vscode/c_cpp_properties.json
vendored
@@ -12,8 +12,10 @@
|
||||
"${workspaceFolder}/TSE/TSE_Math/src",
|
||||
"${workspaceFolder}/TSE/TSE_GlfwImpl/include",
|
||||
"${workspaceFolder}/TSE/TSE_GlfwImpl/src",
|
||||
"${workspaceFolder}/TSE/TSE_GlfwOpenGlImpl/include",
|
||||
"${workspaceFolder}/TSE/TSE_GlfwOpenGlImpl/src",
|
||||
"${workspaceFolder}/TSE/TSE_OpenGlImpl/include",
|
||||
"${workspaceFolder}/TSE/TSE_OpenGlImpl/src",
|
||||
"${workspaceFolder}/TSE/TSE_Sdl3Impl/include",
|
||||
"${workspaceFolder}/TSE/TSE_Sdl3Impl/src",
|
||||
"${workspaceFolder}/TSE/TSE_Editor/src"
|
||||
],
|
||||
"defines": [],
|
||||
|
||||
6
.vscode/tasks.json
vendored
6
.vscode/tasks.json
vendored
@@ -33,7 +33,8 @@
|
||||
"-DCMAKE_C_COMPILER=clang",
|
||||
"-DCMAKE_CXX_COMPILER=clang++",
|
||||
"-DCMAKE_LINKER=lld-link",
|
||||
"-DCMAKE_BUILD_TYPE=Debug"
|
||||
"-DCMAKE_BUILD_TYPE=Debug",
|
||||
"-DUSE_SDL3=ON"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
@@ -55,7 +56,8 @@
|
||||
"-DCMAKE_C_COMPILER=clang",
|
||||
"-DCMAKE_CXX_COMPILER=clang++",
|
||||
"-DCMAKE_LINKER=lld-link",
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DUSE_SDL3=ON"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
|
||||
151
CMakeLists.txt
151
CMakeLists.txt
@@ -4,6 +4,28 @@ cmake_minimum_required(VERSION 3.31)
|
||||
#project name
|
||||
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
|
||||
find_program(CLANG_C 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_Core)
|
||||
add_subdirectory(TSE/TSE_Editor)
|
||||
add_subdirectory(TSE/TSE_OpenGlImpl)
|
||||
|
||||
if(USE_GLFW)
|
||||
add_subdirectory(TSE/TSE_GlfwImpl)
|
||||
add_subdirectory(TSE/TSE_GlfwOpenGlImpl)
|
||||
endif()
|
||||
|
||||
if(USE_SDL3)
|
||||
add_subdirectory(TSE/TSE_Sdl3Impl)
|
||||
endif()
|
||||
|
||||
#source files
|
||||
file(GLOB CPP_SOURCE
|
||||
@@ -43,28 +72,53 @@ file(GLOB CPP_SOURCE
|
||||
"${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
|
||||
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(DEBUG)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEBUGSPEC
|
||||
"${PROJECT_SOURCE_DIR}/TSE/TSE_Core/include/FreeImageLib.d.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"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(LIB_SOURCE
|
||||
${DEBUGSPEC}
|
||||
)
|
||||
|
||||
if(USE_GLFW)
|
||||
list(APPEND LIB_SOURCE
|
||||
"${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()
|
||||
|
||||
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)
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Base
|
||||
TSE_Math
|
||||
TSE_Core
|
||||
TSE_GlfwImpl
|
||||
TSE_GlfwOpenGlImpl
|
||||
${BACKEND_TARGETS}
|
||||
TSE_OpenGlImpl
|
||||
TSE_Editor
|
||||
${LIB_SOURCE})
|
||||
${LIB_SOURCE}
|
||||
)
|
||||
else()
|
||||
target_link_libraries(TSE-RTS PUBLIC
|
||||
TSE_Editor
|
||||
TSE_GlfwOpenGlImpl
|
||||
TSE_GlfwImpl
|
||||
TSE_OpenGlImpl
|
||||
${BACKEND_TARGETS}
|
||||
TSE_Core
|
||||
TSE_Math
|
||||
TSE_Base
|
||||
${LIB_SOURCE})
|
||||
${LIB_SOURCE}
|
||||
)
|
||||
endif()
|
||||
|
||||
# flags
|
||||
|
||||
2
TSE
2
TSE
Submodule TSE updated: f859288689...a596028ed9
@@ -1,7 +1,12 @@
|
||||
#include <iostream>
|
||||
#include "GL/gl3w.h"
|
||||
#include "globalVars.hpp"
|
||||
#include "WindowManager.hpp"
|
||||
#if defined(TSE_GLFW)
|
||||
#include "WindowGlfw.hpp"
|
||||
#elif defined(TSE_SDL3)
|
||||
#include "WindowSdl3.hpp"
|
||||
#endif
|
||||
#include "OpenGLRenderingBackend.hpp"
|
||||
#include "imgui/imgui.h"
|
||||
#include "shader/defaultShaderHandler.cpp"
|
||||
@@ -21,7 +26,12 @@
|
||||
#define USE_EDITOR
|
||||
|
||||
using namespace TSE;
|
||||
#if defined(TSE_GLFW)
|
||||
using namespace TSE::GLFW;
|
||||
#elif defined(TSE_SDL3)
|
||||
using namespace TSE::SDL3;
|
||||
#endif
|
||||
using namespace TSE::OpenGL;
|
||||
using namespace TSE::EDITOR;
|
||||
|
||||
IWindow* wnd = nullptr;
|
||||
@@ -33,12 +43,22 @@ EditorSubsystem* editor;
|
||||
void SetupWindow()
|
||||
{
|
||||
Color backColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
#if defined(TSE_GLFW)
|
||||
#ifdef USE_EDITOR
|
||||
wnd = new WindowGlfw(PROJECT_NAME, 800, 600, new OpenGLRenderingBackend(backColor, false, 8, true), WindowType::Maximized);
|
||||
editor = new EditorSubsystem();
|
||||
#else
|
||||
wnd = new WindowGlfw(PROJECT_NAME, 1920, 1080, new OpenGLRenderingBackend(backColor, false, 8, false), WindowType::Fullscreen);
|
||||
#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);
|
||||
TileMapShader::Init(wnd->GetSize().x, wnd->GetSize().y);
|
||||
LastPassShader::Init(wnd->GetSize().x, wnd->GetSize().y);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "LastPassShaderGLSL.hpp"
|
||||
|
||||
using namespace TSE;
|
||||
using namespace TSE::GLFW;
|
||||
using namespace TSE::OpenGL;
|
||||
|
||||
#define SHADER_VERTEX_INDEX 0
|
||||
#define SHADER_UV_INDEX 1
|
||||
@@ -43,7 +43,7 @@ void LastPassShader::Init(float width, float height)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "shader/Shader.hpp"
|
||||
#include "Types.hpp"
|
||||
|
||||
class LastPassShader : public TSE::GLFW::Shader
|
||||
class LastPassShader : public TSE::OpenGL::Shader
|
||||
{
|
||||
private:
|
||||
static LastPassShader* instance;
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
static LastPassShader* Instance();
|
||||
static void Destroy();
|
||||
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:
|
||||
void OnEnable() const override;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "TileMapShaderGLSL.hpp"
|
||||
|
||||
using namespace TSE;
|
||||
using namespace TSE::GLFW;
|
||||
using namespace TSE::OpenGL;
|
||||
|
||||
#define SHADER_MESH_INDEX 0
|
||||
#define SHADER_POS_INDEX 1
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "shader/Shader.hpp"
|
||||
#include "Types.hpp"
|
||||
|
||||
class TileMapShader : public TSE::GLFW::Shader
|
||||
class TileMapShader : public TSE::OpenGL::Shader
|
||||
{
|
||||
private:
|
||||
static TileMapShader* instance;
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
static TileMapShader* Instance();
|
||||
static void Destroy();
|
||||
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();
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user