made Editor non reliant on GLFW aka i added an IRenderTexture interface of use in non renderer specific aplications

This commit is contained in:
2026-01-18 18:49:15 +01:00
parent 23e7707122
commit a453612b9a
17 changed files with 87 additions and 49 deletions

View File

@@ -118,12 +118,12 @@ TSE::Vector2 TSE::Texture::size() const
return Size;
}
float TSE::Texture::width() const
float TSE::Texture::Width() const
{
return Size.x;
}
float TSE::Texture::height() const
float TSE::Texture::Height() const
{
return Size.y;
}
@@ -181,9 +181,9 @@ void TSE::Texture::SetPixel(const int &x, const int &y, const Color &c)
void TSE::Texture::GetPixel(const int &x, const int &y, Color &c) const
{
if(x >= width() || x < 0 ||y >= height() || y < 0)
if(x >= Width() || x < 0 ||y >= Height() || y < 0)
{
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(width()) + ";" + std::to_string(height()) );
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(Width()) + ";" + std::to_string(Height()) );
return;
}
byte* pixel = getPixelPointer(x,y);
@@ -201,9 +201,9 @@ void TSE::Texture::GetPixel(const int &x, const int &y, Color &c) const
void TSE::Texture::Fill(const Color &c)
{
for (int x = 0; x < width(); x++)
for (int x = 0; x < Width(); x++)
{
for (int y = 0; y < height(); y++)
for (int y = 0; y < Height(); y++)
{
SetPixelNoApply(x,y,c);
}
@@ -214,9 +214,9 @@ void TSE::Texture::Fill(const Color &c)
void TSE::Texture::SetPixelNoApply(const int &x, const int &y, const Color &c)
{
if(x >= width() || x < 0 ||y >= height() || y < 0)
if(x >= Width() || x < 0 ||y >= Height() || y < 0)
{
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(width()) + ";" + std::to_string(height()) );
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(Width()) + ";" + std::to_string(Height()) );
return;
}
@@ -244,9 +244,9 @@ void TSE::Texture::SetPixelNoApply(const int &x, const int &y, const Color &c)
void TSE::Texture::AddPixelNoApply(const int &x, const int &y, const Color &c)
{
if(x >= width() || x < 0 ||y >= height() || y < 0)
if(x >= Width() || x < 0 ||y >= Height() || y < 0)
{
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(width()) + ";" + std::to_string(height()) );
TSE_WARNING("trying to access pixel outside of texture.\n pixel: (" + std::to_string(x) + ";" + std::to_string(y) + ")\nTexture size: (" + std::to_string(Width()) + ";" + std::to_string(Height()) );
return;
}
@@ -307,7 +307,7 @@ TSE::byte *TSE::Texture::getPixelPointer(const int &x, const int &y) const
int alphaoffset = y * 2;
if(bpp() > 24)
alphaoffset = 0;
int offset = ((y * width() + x) * (bpp() / 8) + alphaoffset);
int offset = ((y * Width() + x) * (bpp() / 8) + alphaoffset);
return imagePtr + offset;
}

View File

@@ -32,8 +32,8 @@ namespace TSE
uint bpp() const;
Vector2 size() const override;
float width() const override;
float height() const override;
float Width() const override;
float Height() const override;
byte Chanels() const;
byte* GetImagePtr() const;
void SetPixel(const Vector2& pos, const Color& c);

View File

@@ -0,0 +1,23 @@
#pragma once
#include "IResizeNotifiable.hpp"
#include "IRenderTarget.hpp"
#include "ITexture.hpp"
namespace TSE
{
class IRenderTextureCreator;
class IRenderTexture : public IRenderTarget, public ITexture, public IResizeNotifiable
{
public:
inline static IRenderTextureCreator* factory = nullptr;
virtual void SetSize(Vector2 v) = 0;
};
class IRenderTextureCreator
{
public:
virtual IRenderTexture* CreateTextureHeap(Vector2 v) = 0;
};
} // namespace TSE

View File

@@ -9,8 +9,8 @@ namespace TSE
public:
virtual ~ITexture() = default;
virtual Vector2 size() const = 0;
virtual float width() const = 0;
virtual float height() const = 0;
virtual float Width() const = 0;
virtual float Height() const = 0;
virtual uint GetTextureId() const = 0;
};
} // namespace TSE