first commit of some basics
This commit is contained in:
56
TSE_Core/CMakeLists.txt
Normal file
56
TSE_Core/CMakeLists.txt
Normal file
@@ -0,0 +1,56 @@
|
||||
#cmake version
|
||||
cmake_minimum_required(VERSION 3.31)
|
||||
|
||||
#project name
|
||||
project(TSE_Core)
|
||||
|
||||
#cpp settings
|
||||
find_program(CLANG_C NAMES clang)
|
||||
find_program(CLANG_CXX NAMES clang++)
|
||||
|
||||
if(CLANG_C AND CLANG_CXX)
|
||||
message(STATUS "foung Clang, using as Compiler")
|
||||
set(CMAKE_C_COMPILER ${CLANG_C} CACHE STRING "C Compiler" FORCE)
|
||||
set(CMAKE_CXX_COMPILER ${CLANG_CXX} CACHE STRING "C++ Compiler" FORCE)
|
||||
else()
|
||||
message(STATUS "Clang not found, using Standard-Compiler")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
#project output settings
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/lib/Debug")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/lib/Release")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/lib/Debug")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/lib/Release")
|
||||
|
||||
#source files
|
||||
file(GLOB CPP_SOURCE_TSE
|
||||
"${PROJECT_SOURCE_DIR}/src/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*/*/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/src/*.c"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*.c"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*/*.c"
|
||||
"${PROJECT_SOURCE_DIR}/src/*/*/*/*.c"
|
||||
)
|
||||
|
||||
#includes
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Math/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Base/src)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Base/include)
|
||||
|
||||
#project def
|
||||
if(Lib)
|
||||
add_library(TSE_Core SHARED ${CPP_SOURCE_TSE})
|
||||
else()
|
||||
add_library(TSE_Core STATIC ${CPP_SOURCE_TSE})
|
||||
endif()
|
||||
|
||||
#flags
|
||||
target_compile_options(TSE_Core PRIVATE -march=native)
|
||||
|
||||
13
TSE_Core/src/enums/WindowType.hpp
Normal file
13
TSE_Core/src/enums/WindowType.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
enum WindowType
|
||||
{
|
||||
Unnknown = 0,
|
||||
Windowed = 1,
|
||||
Fullscreen = 2,
|
||||
FullscreenWindowed = 3,
|
||||
Maximized = 4,
|
||||
};
|
||||
} // namespace TSE
|
||||
16
TSE_Core/src/interfaces/IRenderTarget.hpp
Normal file
16
TSE_Core/src/interfaces/IRenderTarget.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "IResizable.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class IRenderTarget : public IResizable
|
||||
{
|
||||
public:
|
||||
int UnitScaler = 32;
|
||||
|
||||
virtual void Update();
|
||||
virtual void Bind();
|
||||
virtual void Unbind();
|
||||
};
|
||||
} // namespace TSE
|
||||
29
TSE_Core/src/interfaces/IRenderingBackend.hpp
Normal file
29
TSE_Core/src/interfaces/IRenderingBackend.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "Color.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class IWindow;
|
||||
|
||||
class IRenderingBackend
|
||||
{
|
||||
protected:
|
||||
Color backgroundColor;
|
||||
bool vsync;
|
||||
int samples = 0;
|
||||
bool useseImGui = false;
|
||||
|
||||
public:
|
||||
IWindow* window = nullptr;
|
||||
|
||||
virtual void InitPreWindow() = 0;
|
||||
virtual bool InitPostWindow() = 0;
|
||||
|
||||
virtual void onResize(int width, int height) = 0;
|
||||
virtual void onUpdate() const = 0;
|
||||
virtual void onClear() const = 0;
|
||||
virtual void onClearDepthBuffer() const = 0;
|
||||
|
||||
};
|
||||
} // namespace TSE
|
||||
25
TSE_Core/src/interfaces/IResizable.cpp
Normal file
25
TSE_Core/src/interfaces/IResizable.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "IResizable.hpp"
|
||||
|
||||
void TSE::IResizable::AddResizeNotifiable(IResizeNotifiable *obj)
|
||||
{
|
||||
std::list<IResizeNotifiable*>::iterator it;
|
||||
for (it = objectsToResize.begin(); it != objectsToResize.end(); ++it)
|
||||
{
|
||||
if((*it) == obj){
|
||||
return; //return if already in list
|
||||
}
|
||||
}
|
||||
objectsToResize.push_back(obj);
|
||||
}
|
||||
|
||||
void TSE::IResizable::RemoveResizeNotifiable(IResizeNotifiable *obj)
|
||||
{
|
||||
std::list<IResizeNotifiable*>::iterator it;
|
||||
for (it = objectsToResize.begin(); it != objectsToResize.end(); ++it)
|
||||
{
|
||||
if((*it) == obj){
|
||||
objectsToResize.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
TSE_Core/src/interfaces/IResizable.hpp
Normal file
19
TSE_Core/src/interfaces/IResizable.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include "IResizeNotifiable.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class IResizable
|
||||
{
|
||||
protected:
|
||||
float width;
|
||||
float height;
|
||||
std::list<IResizeNotifiable*> objectsToResize;
|
||||
|
||||
public:
|
||||
void AddResizeNotifiable(IResizeNotifiable* obj);
|
||||
void RemoveResizeNotifiable(IResizeNotifiable* obj);
|
||||
};
|
||||
} // namespace TSE
|
||||
18
TSE_Core/src/interfaces/IResizeNotifiable.hpp
Normal file
18
TSE_Core/src/interfaces/IResizeNotifiable.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class IResizable;
|
||||
|
||||
class IResizeNotifiable
|
||||
{
|
||||
public:
|
||||
/// @brief gets called, when a Resizable gets resized as an event.
|
||||
/// @param width the new width
|
||||
/// @param height the new height
|
||||
/// @param resizable the resizable that got changed
|
||||
virtual void OnResize(float width, float height, IResizable* resizable);
|
||||
virtual ~IResizeNotifiable() = default;
|
||||
};
|
||||
} // namespace TSE
|
||||
16
TSE_Core/src/interfaces/IWindow.cpp
Normal file
16
TSE_Core/src/interfaces/IWindow.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "IWindow.hpp"
|
||||
#include "Debug.hpp"
|
||||
#include "LuaStateHandler.hpp"
|
||||
|
||||
TSE::IWindow* TSE::IWindow::lastWindow = nullptr;
|
||||
|
||||
bool TSE::IWindow::BaseInit() const
|
||||
{
|
||||
LuaStateHandler::InitLuaState();
|
||||
Debug::Init();
|
||||
}
|
||||
|
||||
TSE::IWindow::~IWindow()
|
||||
{
|
||||
Debug::Close();
|
||||
}
|
||||
25
TSE_Core/src/interfaces/IWindow.hpp
Normal file
25
TSE_Core/src/interfaces/IWindow.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "IRenderTarget.hpp"
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class IWindow : public IRenderTarget
|
||||
{
|
||||
public:
|
||||
static IWindow* lastWindow;
|
||||
string title;
|
||||
|
||||
protected:
|
||||
virtual bool Init() = 0;
|
||||
public:
|
||||
virtual void Clear() const = 0;
|
||||
virtual void Update() const = 0;
|
||||
virtual void ClearDepthBuffer() const = 0;
|
||||
virtual bool ShouldClose() const = 0;
|
||||
|
||||
bool BaseInit() const;
|
||||
~IWindow();
|
||||
};
|
||||
} // namespace TSE
|
||||
Reference in New Issue
Block a user