first commit of some basics
This commit is contained in:
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