Fixed glVertexBuffer

- Fixed glVertexBuffer multiplying count by size of float instead of stride
      * = Fixed TintedTexture for OpenGL
This commit is contained in:
Light 2021-08-06 07:44:48 +04:30
parent 367bce3596
commit cc41ce24d5
7 changed files with 10 additions and 8 deletions

View file

@ -13,5 +13,6 @@ out vec2 vso_TexCoord;
void main()
{
gl_Position = u_ViewProjection * a_Position;
vso_TexCoord = a_TexCoord;
}

View file

@ -10,7 +10,7 @@ cbuffer cb_ViewProjection : register(b0)
row_major matrix viewProjection;
}
VertexOut main(float4 InPosition : POSITION, float4 InTint : TINT,float2 InTexChoord : TEXCOORD)
VertexOut main(float4 InPosition : POSITION, float4 InTint : TINT, float2 InTexChoord : TEXCOORD)
{
VertexOut vso;
vso.Position = mul(float4(InPosition), viewProjection);

View file

@ -37,7 +37,7 @@ namespace Light {
switch (GraphicsContext::GetGraphicsAPI())
{
case GraphicsAPI::OpenGL:
return CreateRef<glVertexBuffer>(vertices, count);
return CreateRef<glVertexBuffer>(vertices, stride, count);
case GraphicsAPI::DirectX: LT_WIN(
return CreateRef<dxVertexBuffer>(vertices, stride, count, std::static_pointer_cast<dxSharedContext>(sharedContext));)

View file

@ -22,7 +22,7 @@ namespace Light {
Renderer::Renderer(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
: m_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext),
m_TextureRenderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext),
m_TintedTextureRenderer(LT_MAX_TEXTURE_RENDERER_VERTICES, sharedContext),
m_TintedTextureRenderer(LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES, sharedContext),
m_ViewProjectionBuffer(nullptr),
m_RenderCommand(nullptr),
m_Blender(nullptr),

View file

@ -6,8 +6,9 @@
#include "RendererPrograms/TextureRendererProgram.h"
#include "RendererPrograms/TintedTextureRendererProgram.h"
#define LT_MAX_QUAD_RENDERER_VERTICES 1028u * 4u
#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u
#define LT_MAX_QUAD_RENDERER_VERTICES 1028u * 4u
#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u
#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES 1028u * 4u
struct GLFWwindow;

View file

@ -39,11 +39,11 @@ namespace Light {
//==================== CONSTANT_BUFFER ====================//
//==================== VERTEX_BUFFER ====================//
glVertexBuffer::glVertexBuffer(float* vertices, unsigned int count)
glVertexBuffer::glVertexBuffer(float* vertices, unsigned int stride, unsigned int count)
: m_BufferID(NULL)
{
glCreateBuffers(1, &m_BufferID);
glNamedBufferData(m_BufferID, count * sizeof(float), vertices, GL_DYNAMIC_DRAW);
glNamedBufferData(m_BufferID, stride * count, vertices, GL_DYNAMIC_DRAW);
}
glVertexBuffer::~glVertexBuffer()

View file

@ -30,7 +30,7 @@ namespace Light {
unsigned int m_BufferID;
public:
glVertexBuffer(float* vertices, unsigned int count);
glVertexBuffer(float* vertices, unsigned int stride, unsigned int count);
~glVertexBuffer();
void Bind() override;