|
|
@ -65,7 +65,6 @@ void Renderer<T>::initialize() |
|
|
|
template<typename T> |
|
|
|
template<typename T> |
|
|
|
void Renderer<T>::destroy() |
|
|
|
void Renderer<T>::destroy() |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete[] m_vertexBufferBase; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename T> |
|
|
|
template<typename T> |
|
|
@ -161,7 +160,7 @@ void Renderer<T>::flush() |
|
|
|
uploadElementBuffer(); |
|
|
|
uploadElementBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
// Upload vertex data to GPU
|
|
|
|
// Upload vertex data to GPU
|
|
|
|
m_vertexArray->at(0)->uploadData(m_vertexBufferBase, m_vertexIndex * sizeof(T)); |
|
|
|
m_vertexArray->at(0)->uploadData(m_vertexBufferBase.get(), m_vertexIndex * sizeof(T)); |
|
|
|
|
|
|
|
|
|
|
|
bind(); |
|
|
|
bind(); |
|
|
|
|
|
|
|
|
|
|
@ -180,7 +179,7 @@ void Renderer<T>::startBatch() |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_vertexIndex = 0; |
|
|
|
m_vertexIndex = 0; |
|
|
|
m_elementIndex = 0; |
|
|
|
m_elementIndex = 0; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase.get(); |
|
|
|
|
|
|
|
|
|
|
|
m_textureSlotIndex = 1; |
|
|
|
m_textureSlotIndex = 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -199,6 +198,10 @@ Renderer2D::Renderer2D(s) |
|
|
|
Renderer2D::initialize(); |
|
|
|
Renderer2D::initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renderer2D::~Renderer2D() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Renderer2D::initialize() |
|
|
|
void Renderer2D::initialize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Renderer::initialize(); |
|
|
|
Renderer::initialize(); |
|
|
@ -207,8 +210,8 @@ void Renderer2D::initialize() |
|
|
|
// CPU
|
|
|
|
// CPU
|
|
|
|
|
|
|
|
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
m_vertexBufferBase = new QuadVertex[maxVertices]; |
|
|
|
m_vertexBufferBase = std::make_unique<QuadVertex[]>(maxVertices); |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase.get(); |
|
|
|
|
|
|
|
|
|
|
|
// Set default quad vertex positions
|
|
|
|
// Set default quad vertex positions
|
|
|
|
m_vertexPositions[0] = { -1.0f, -1.0f, 0.0f, 1.0f }; |
|
|
|
m_vertexPositions[0] = { -1.0f, -1.0f, 0.0f, 1.0f }; |
|
|
@ -290,6 +293,10 @@ RendererCubemap::RendererCubemap(s) |
|
|
|
RendererCubemap::initialize(); |
|
|
|
RendererCubemap::initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RendererCubemap::~RendererCubemap() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RendererCubemap::initialize() |
|
|
|
void RendererCubemap::initialize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Renderer::initialize(); |
|
|
|
Renderer::initialize(); |
|
|
@ -298,8 +305,8 @@ void RendererCubemap::initialize() |
|
|
|
// CPU
|
|
|
|
// CPU
|
|
|
|
|
|
|
|
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
m_vertexBufferBase = new CubemapVertex[maxVertices]; |
|
|
|
m_vertexBufferBase = std::make_unique<CubemapVertex[]>(maxVertices); |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase.get(); |
|
|
|
|
|
|
|
|
|
|
|
// Set default cubemap vertex positions
|
|
|
|
// Set default cubemap vertex positions
|
|
|
|
|
|
|
|
|
|
|
@ -413,8 +420,8 @@ RendererFont::RendererFont(s) |
|
|
|
// CPU
|
|
|
|
// CPU
|
|
|
|
|
|
|
|
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
m_vertexBufferBase = new SymbolVertex[maxVertices]; |
|
|
|
m_vertexBufferBase = std::make_unique<SymbolVertex[]>(maxVertices); |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase.get(); |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------
|
|
|
|
// ---------------------------------
|
|
|
|
// GPU
|
|
|
|
// GPU
|
|
|
@ -440,6 +447,10 @@ RendererFont::RendererFont(s) |
|
|
|
ruc::info("RendererFont initialized"); |
|
|
|
ruc::info("RendererFont initialized"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RendererFont::~RendererFont() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RendererFont::drawSymbol(std::array<SymbolVertex, vertexPerQuad>& symbolQuad, std::shared_ptr<Texture> texture) |
|
|
|
void RendererFont::drawSymbol(std::array<SymbolVertex, vertexPerQuad>& symbolQuad, std::shared_ptr<Texture> texture) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Create a new batch if the quad limit has been reached
|
|
|
|
// Create a new batch if the quad limit has been reached
|
|
|
@ -485,8 +496,8 @@ Renderer3D::Renderer3D(s) |
|
|
|
// CPU
|
|
|
|
// CPU
|
|
|
|
|
|
|
|
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
// Create array for storing quads vertices
|
|
|
|
m_vertexBufferBase = new Vertex[maxVertices]; |
|
|
|
m_vertexBufferBase = std::make_unique<Vertex[]>(maxVertices); |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase; |
|
|
|
m_vertexBufferPtr = m_vertexBufferBase.get(); |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------
|
|
|
|
// ---------------------------------
|
|
|
|
// GPU
|
|
|
|
// GPU
|
|
|
@ -508,6 +519,10 @@ Renderer3D::Renderer3D(s) |
|
|
|
ruc::info("Renderer3D initialized"); |
|
|
|
ruc::info("Renderer3D initialized"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renderer3D::~Renderer3D() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Renderer3D::drawModel(std::span<const Vertex> vertices, std::span<const uint32_t> elements, const TransformComponent& transform, glm::vec4 color, std::shared_ptr<Texture> texture) |
|
|
|
void Renderer3D::drawModel(std::span<const Vertex> vertices, std::span<const uint32_t> elements, const TransformComponent& transform, glm::vec4 color, std::shared_ptr<Texture> texture) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// ruc::error("drawModel");
|
|
|
|
// ruc::error("drawModel");
|
|
|
@ -579,6 +594,10 @@ void Renderer3D::startBatch() |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RendererPostProcess::~RendererPostProcess() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RendererPostProcess::drawQuad(const TransformComponent& transform, std::shared_ptr<Texture> albedo, std::shared_ptr<Texture> position, std::shared_ptr<Texture> normal) |
|
|
|
void RendererPostProcess::drawQuad(const TransformComponent& transform, std::shared_ptr<Texture> albedo, std::shared_ptr<Texture> position, std::shared_ptr<Texture> normal) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nextBatch(); |
|
|
|
nextBatch(); |
|
|
@ -614,6 +633,10 @@ void RendererPostProcess::loadShader() |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RendererLightCube::~RendererLightCube() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RendererLightCube::loadShader() |
|
|
|
void RendererLightCube::loadShader() |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_shader = AssetManager::the().load<Shader>("assets/glsl/lightsource"); |
|
|
|
m_shader = AssetManager::the().load<Shader>("assets/glsl/lightsource"); |
|
|
|