made Editor non reliant on GLFW aka i added an IRenderTexture interface of use in non renderer specific aplications
This commit is contained in:
@@ -118,12 +118,12 @@ TSE::Vector2 TSE::Texture::size() const
|
|||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TSE::Texture::width() const
|
float TSE::Texture::Width() const
|
||||||
{
|
{
|
||||||
return Size.x;
|
return Size.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TSE::Texture::height() const
|
float TSE::Texture::Height() const
|
||||||
{
|
{
|
||||||
return Size.y;
|
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
|
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;
|
return;
|
||||||
}
|
}
|
||||||
byte* pixel = getPixelPointer(x,y);
|
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)
|
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);
|
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)
|
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;
|
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)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ TSE::byte *TSE::Texture::getPixelPointer(const int &x, const int &y) const
|
|||||||
int alphaoffset = y * 2;
|
int alphaoffset = y * 2;
|
||||||
if(bpp() > 24)
|
if(bpp() > 24)
|
||||||
alphaoffset = 0;
|
alphaoffset = 0;
|
||||||
int offset = ((y * width() + x) * (bpp() / 8) + alphaoffset);
|
int offset = ((y * Width() + x) * (bpp() / 8) + alphaoffset);
|
||||||
return imagePtr + offset;
|
return imagePtr + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace TSE
|
|||||||
|
|
||||||
uint bpp() const;
|
uint bpp() const;
|
||||||
Vector2 size() const override;
|
Vector2 size() const override;
|
||||||
float width() const override;
|
float Width() const override;
|
||||||
float height() const override;
|
float Height() const override;
|
||||||
byte Chanels() const;
|
byte Chanels() const;
|
||||||
byte* GetImagePtr() const;
|
byte* GetImagePtr() const;
|
||||||
void SetPixel(const Vector2& pos, const Color& c);
|
void SetPixel(const Vector2& pos, const Color& c);
|
||||||
|
|||||||
23
TSE_Core/src/interfaces/IRenderTexture.hpp
Normal file
23
TSE_Core/src/interfaces/IRenderTexture.hpp
Normal 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
|
||||||
@@ -9,8 +9,8 @@ namespace TSE
|
|||||||
public:
|
public:
|
||||||
virtual ~ITexture() = default;
|
virtual ~ITexture() = default;
|
||||||
virtual Vector2 size() const = 0;
|
virtual Vector2 size() const = 0;
|
||||||
virtual float width() const = 0;
|
virtual float Width() const = 0;
|
||||||
virtual float height() const = 0;
|
virtual float Height() const = 0;
|
||||||
virtual uint GetTextureId() const = 0;
|
virtual uint GetTextureId() const = 0;
|
||||||
};
|
};
|
||||||
} // namespace TSE
|
} // namespace TSE
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ include_directories(${PROJECT_SOURCE_DIR}/../TSE_Base/include)
|
|||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Math/src)
|
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Math/src)
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Core/src)
|
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Core/src)
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Core/include)
|
include_directories(${PROJECT_SOURCE_DIR}/../TSE_Core/include)
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_GlfwImpl/src)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_GlfwImpl/include)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_GlfwOpenGlImpl/src)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/../TSE_GlfwOpenGlImpl/include)
|
|
||||||
|
|
||||||
#project def
|
#project def
|
||||||
if(Lib)
|
if(Lib)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
||||||
{
|
{
|
||||||
rt = new TSE::GLFW::RenderTexture({100,100});
|
rt = IRenderTexture::factory->CreateTextureHeap({100,100});
|
||||||
sv = SceneView(rt);
|
sv = SceneView(rt);
|
||||||
|
|
||||||
controller.AddGuiElement("Scene", &sv);
|
controller.AddGuiElement("Scene", &sv);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "UI/windows/HirearchieView.hpp"
|
#include "UI/windows/HirearchieView.hpp"
|
||||||
#include "UI/windows/PropertiesView.hpp"
|
#include "UI/windows/PropertiesView.hpp"
|
||||||
#include "UI/windows/SceneView.hpp"
|
#include "UI/windows/SceneView.hpp"
|
||||||
#include "RenderTexture.hpp"
|
#include "interfaces/IRenderTexture.hpp"
|
||||||
|
|
||||||
namespace TSE::EDITOR
|
namespace TSE::EDITOR
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace TSE::EDITOR
|
|||||||
HirearchieView hv = HirearchieView(nullptr);
|
HirearchieView hv = HirearchieView(nullptr);
|
||||||
PropertiesView pv;
|
PropertiesView pv;
|
||||||
CameraView camv;
|
CameraView camv;
|
||||||
TSE::GLFW::RenderTexture* rt;
|
TSE::IRenderTexture* rt;
|
||||||
SceneView sv;
|
SceneView sv;
|
||||||
Layer editorLayer;
|
Layer editorLayer;
|
||||||
|
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ namespace TSE::EDITOR
|
|||||||
ImVec2 field_size = ImVec2(field_width, 60);
|
ImVec2 field_size = ImVec2(field_width, 60);
|
||||||
|
|
||||||
Rect r = element->GetUVRect();
|
Rect r = element->GetUVRect();
|
||||||
float ymultiplyer = (element->GetTexture()->height() * r.height()) / (element->GetTexture()->width() * r.width());
|
float ymultiplyer = (element->GetTexture()->Height() * r.height()) / (element->GetTexture()->Width() * r.width());
|
||||||
|
|
||||||
ImVec2 texSize (field_size.y - 2, (field_size.y - 2) * ymultiplyer);
|
ImVec2 texSize (field_size.y - 2, (field_size.y - 2) * ymultiplyer);
|
||||||
|
|
||||||
@@ -916,7 +916,7 @@ namespace TSE::EDITOR
|
|||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
float available_width = ImGui::GetContentRegionAvail().x;
|
float available_width = ImGui::GetContentRegionAvail().x;
|
||||||
float ymultiplyer = (element->GetTexture()->height() * r.height()) / (element->GetTexture()->width() * r.width());
|
float ymultiplyer = (element->GetTexture()->Height() * r.height()) / (element->GetTexture()->Width() * r.width());
|
||||||
|
|
||||||
ImVec2 texSize (available_width, (available_width) * ymultiplyer);
|
ImVec2 texSize (available_width, (available_width) * ymultiplyer);
|
||||||
ImGui::Image(element->GetTexture()->GetTextureId(), texSize, {r.p1.x,r.p2.y}, {r.p2.x,r.p1.y});
|
ImGui::Image(element->GetTexture()->GetTextureId(), texSize, {r.p1.x,r.p2.y}, {r.p2.x,r.p1.y});
|
||||||
@@ -931,7 +931,7 @@ namespace TSE::EDITOR
|
|||||||
|
|
||||||
ImVec2 field_size = ImVec2(field_width, 60);
|
ImVec2 field_size = ImVec2(field_width, 60);
|
||||||
|
|
||||||
float ymultiplyer = element->height() / element->width();
|
float ymultiplyer = element->Height() / element->Width();
|
||||||
|
|
||||||
ImVec2 texSize (field_size.y - 2, (field_size.y - 2) * ymultiplyer);
|
ImVec2 texSize (field_size.y - 2, (field_size.y - 2) * ymultiplyer);
|
||||||
|
|
||||||
@@ -963,8 +963,8 @@ namespace TSE::EDITOR
|
|||||||
if(debug)
|
if(debug)
|
||||||
{
|
{
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::TextDisabled(("Width: " + std::to_string(element->width())).c_str());
|
ImGui::TextDisabled(("Width: " + std::to_string(element->Width())).c_str());
|
||||||
ImGui::TextDisabled(("Height: " + std::to_string(element->height())).c_str());
|
ImGui::TextDisabled(("Height: " + std::to_string(element->Height())).c_str());
|
||||||
ImGui::TextDisabled(("BPP: " + std::to_string(element->bpp())).c_str());
|
ImGui::TextDisabled(("BPP: " + std::to_string(element->bpp())).c_str());
|
||||||
ImGui::TextDisabled(("Chanels: " + std::to_string(element->Chanels())).c_str());
|
ImGui::TextDisabled(("Chanels: " + std::to_string(element->Chanels())).c_str());
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@@ -972,7 +972,7 @@ namespace TSE::EDITOR
|
|||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
float available_width = ImGui::GetContentRegionAvail().x;
|
float available_width = ImGui::GetContentRegionAvail().x;
|
||||||
float ymultiplyer = element->height() / element->width();
|
float ymultiplyer = element->Height() / element->Width();
|
||||||
|
|
||||||
ImVec2 texSize (available_width, (available_width) * ymultiplyer);
|
ImVec2 texSize (available_width, (available_width) * ymultiplyer);
|
||||||
ImGui::Image(element->GetTextureId(), texSize, {0,1}, {1,0});
|
ImGui::Image(element->GetTextureId(), texSize, {0,1}, {1,0});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
TSE::EDITOR::CameraView::CameraView() : GuiWindow("Camera", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
|
TSE::EDITOR::CameraView::CameraView() : GuiWindow("Camera", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
|
||||||
{
|
{
|
||||||
fb = new TSE::GLFW::RenderTexture({100,100});
|
fb = IRenderTexture::factory->CreateTextureHeap({100,100});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::EDITOR::CameraView::Define()
|
void TSE::EDITOR::CameraView::Define()
|
||||||
@@ -19,9 +19,9 @@ void TSE::EDITOR::CameraView::Define()
|
|||||||
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
||||||
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
||||||
{
|
{
|
||||||
ImGui::Image(fb->GetTextureId(), {fb->width(), fb->height()},{0,1}, {1,0});
|
ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
|
||||||
auto vec2 = ImGui::GetWindowSize();
|
auto vec2 = ImGui::GetWindowSize();
|
||||||
if(fb->width() != vec2.x || fb->height() != vec2.y)
|
if(fb->Width() != vec2.x || fb->Height() != vec2.y)
|
||||||
{
|
{
|
||||||
fb->SetSize({vec2.x, vec2.y});
|
fb->SetSize({vec2.x, vec2.y});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI/base/GuiWindow.h"
|
#include "UI/base/GuiWindow.h"
|
||||||
#include "RenderTexture.hpp"
|
#include "interfaces/IRenderTexture.hpp"
|
||||||
#include "BehaviourScripts/Camera.hpp"
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
|
|
||||||
namespace TSE::EDITOR
|
namespace TSE::EDITOR
|
||||||
@@ -10,7 +10,7 @@ namespace TSE::EDITOR
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Camera* currentCamera = nullptr;
|
Camera* currentCamera = nullptr;
|
||||||
TSE::GLFW::RenderTexture* fb;
|
TSE::IRenderTexture* fb;
|
||||||
public:
|
public:
|
||||||
CameraView();
|
CameraView();
|
||||||
void Define() override;
|
void Define() override;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "SceneView.hpp"
|
#include "SceneView.hpp"
|
||||||
|
|
||||||
TSE::EDITOR::SceneView::SceneView(TSE::GLFW::RenderTexture *frameBuffer) : GuiWindow("Scene", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
|
TSE::EDITOR::SceneView::SceneView(TSE::IRenderTexture *frameBuffer) : GuiWindow("Scene", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
|
||||||
{
|
{
|
||||||
fb = frameBuffer;
|
fb = frameBuffer;
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,9 @@ void TSE::EDITOR::SceneView::Define()
|
|||||||
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
||||||
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
||||||
{
|
{
|
||||||
ImGui::Image(fb->GetTextureId(), {fb->width(), fb->height()},{0,1}, {1,0});
|
ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
|
||||||
auto vec2 = ImGui::GetWindowSize();
|
auto vec2 = ImGui::GetWindowSize();
|
||||||
if(fb->width() != vec2.x || fb->height() != vec2.y)
|
if(fb->Width() != vec2.x || fb->Height() != vec2.y)
|
||||||
{
|
{
|
||||||
fb->SetSize({vec2.x, vec2.y});
|
fb->SetSize({vec2.x, vec2.y});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI/base/GuiWindow.h"
|
#include "UI/base/GuiWindow.h"
|
||||||
#include "RenderTexture.hpp"
|
#include "interfaces/IRenderTexture.hpp"
|
||||||
|
|
||||||
namespace TSE::EDITOR
|
namespace TSE::EDITOR
|
||||||
{
|
{
|
||||||
class SceneView : public GuiWindow
|
class SceneView : public GuiWindow
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
TSE::GLFW::RenderTexture* fb;
|
TSE::IRenderTexture* fb;
|
||||||
public:
|
public:
|
||||||
SceneView(TSE::GLFW::RenderTexture* frameBuffer);
|
SceneView(TSE::IRenderTexture* frameBuffer);
|
||||||
void Define() override;
|
void Define() override;
|
||||||
};
|
};
|
||||||
} // namespace TSE::EDITOR
|
} // namespace TSE::EDITOR
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "TextureHelperOpenGL.hpp"
|
#include "TextureHelperOpenGL.hpp"
|
||||||
#include "interfaces/IRenderer.hpp"
|
#include "interfaces/IRenderer.hpp"
|
||||||
#include "BehaviourScripts/Camera.hpp"
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
|
#include "RenderTextureCreatorOpenGL.hpp"
|
||||||
|
|
||||||
TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync)
|
TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync)
|
||||||
: OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ }
|
: OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ }
|
||||||
@@ -36,6 +37,7 @@ TSE::GLFW::OpenGLRenderingBackend::~OpenGLRenderingBackend()
|
|||||||
|
|
||||||
void TSE::GLFW::OpenGLRenderingBackend::InitPreWindow()
|
void TSE::GLFW::OpenGLRenderingBackend::InitPreWindow()
|
||||||
{
|
{
|
||||||
|
IRenderTexture::factory = new RenderTextureCreatorOpenGL();
|
||||||
Texture::helper = new TextureHelperOpenGL();
|
Texture::helper = new TextureHelperOpenGL();
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR);
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ void TSE::GLFW::RenderTexture::SetSize(Vector2 v)
|
|||||||
buffer.Resize(v);
|
buffer.Resize(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float TSE::GLFW::RenderTexture::width() const
|
float TSE::GLFW::RenderTexture::Width() const
|
||||||
{
|
{
|
||||||
return buffer.GetSize().x;
|
return buffer.GetSize().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TSE::GLFW::RenderTexture::height() const
|
float TSE::GLFW::RenderTexture::Height() const
|
||||||
{
|
{
|
||||||
return buffer.GetSize().y;
|
return buffer.GetSize().y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
#include "interfaces/IRenderTarget.hpp"
|
#include "interfaces/IRenderTarget.hpp"
|
||||||
#include "interfaces/ITexture.hpp"
|
#include "interfaces/ITexture.hpp"
|
||||||
#include "interfaces/IResizeNotifiable.hpp"
|
#include "interfaces/IResizeNotifiable.hpp"
|
||||||
|
#include "interfaces/IRenderTexture.hpp"
|
||||||
|
|
||||||
namespace TSE::GLFW
|
namespace TSE::GLFW
|
||||||
{
|
{
|
||||||
class RenderTexture : public IRenderTarget, public ITexture, public IResizeNotifiable
|
class RenderTexture : public IRenderTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FrameBuffer buffer;
|
FrameBuffer buffer;
|
||||||
@@ -15,9 +16,9 @@ namespace TSE::GLFW
|
|||||||
RenderTexture(Vector2 v);
|
RenderTexture(Vector2 v);
|
||||||
|
|
||||||
Vector2 size() const override;
|
Vector2 size() const override;
|
||||||
void SetSize(Vector2 v);
|
void SetSize(Vector2 v) override;
|
||||||
float width() const override;
|
float Width() const override;
|
||||||
float height() const override;
|
float Height() const override;
|
||||||
uint GetTextureId() const override;
|
uint GetTextureId() const override;
|
||||||
|
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|||||||
16
TSE_GlfwOpenGlImpl/src/RenderTextureCreatorOpenGL.hpp
Normal file
16
TSE_GlfwOpenGlImpl/src/RenderTextureCreatorOpenGL.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "interfaces/IRenderTexture.hpp"
|
||||||
|
#include "RenderTexture.hpp"
|
||||||
|
|
||||||
|
namespace TSE::GLFW
|
||||||
|
{
|
||||||
|
class RenderTextureCreatorOpenGL : public IRenderTextureCreator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline IRenderTexture* CreateTextureHeap(Vector2 v) override
|
||||||
|
{
|
||||||
|
return new RenderTexture(v);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} // namespace name
|
||||||
@@ -18,19 +18,19 @@ void TSE::GLFW::TextureHelperOpenGL::Apply(Texture *tex)
|
|||||||
if(tex->Chanels() == 1)
|
if(tex->Chanels() == 1)
|
||||||
{
|
{
|
||||||
if (tex->bpp() == 8)
|
if (tex->bpp() == 8)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->width(), tex->height(), 0, GL_RED, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->Width(), tex->Height(), 0, GL_RED, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
||||||
}
|
}
|
||||||
if(tex->Chanels() == 3)
|
if(tex->Chanels() == 3)
|
||||||
{
|
{
|
||||||
if(tex->bpp() == 24)
|
if(tex->bpp() == 24)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->width(), tex->height(), 0, GL_BGR, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->Width(), tex->Height(), 0, GL_BGR, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
||||||
}
|
}
|
||||||
else if(tex->Chanels() == 4)
|
else if(tex->Chanels() == 4)
|
||||||
{
|
{
|
||||||
if(tex->bpp() == 32)
|
if(tex->bpp() == 32)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->width(), tex->height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->Width(), tex->Height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
||||||
if (tex->bpp() == 8) //need to decode it with bitwise operations in shader
|
if (tex->bpp() == 8) //need to decode it with bitwise operations in shader
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->width(), tex->height(), 0, GL_RED, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, tex->Width(), tex->Height(), 0, GL_RED, GL_UNSIGNED_BYTE, tex->GetImagePtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|||||||
Reference in New Issue
Block a user