first commit of some basics

This commit is contained in:
2026-01-17 09:13:59 +01:00
parent f9bc556ad9
commit c770c62400
41 changed files with 13610 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
#pragma once
namespace TSE
{
enum WindowType
{
Unnknown = 0,
Windowed = 1,
Fullscreen = 2,
FullscreenWindowed = 3,
Maximized = 4,
};
} // namespace TSE

View 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

View 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

View 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;
}
}
}

View 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

View 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

View 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();
}

View 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