Fixed glVertexBuffer
- Fixed glVertexBuffer multiplying count by size of float instead of stride
      * = Fixed TintedTexture for OpenGL
			
			
This commit is contained in:
		
							parent
							
								
									367bce3596
								
							
						
					
					
						commit
						cc41ce24d5
					
				
					 7 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
					@ -13,5 +13,6 @@ out vec2 vso_TexCoord;
 | 
				
			||||||
void main()
 | 
					void main()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	gl_Position = u_ViewProjection * a_Position;
 | 
						gl_Position = u_ViewProjection * a_Position;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vso_TexCoord = a_TexCoord;
 | 
						vso_TexCoord = a_TexCoord;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ cbuffer cb_ViewProjection : register(b0)
 | 
				
			||||||
	row_major matrix  viewProjection;
 | 
						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;
 | 
						VertexOut vso;
 | 
				
			||||||
	vso.Position = mul(float4(InPosition), viewProjection);
 | 
						vso.Position = mul(float4(InPosition), viewProjection);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ namespace Light {
 | 
				
			||||||
		switch (GraphicsContext::GetGraphicsAPI())
 | 
							switch (GraphicsContext::GetGraphicsAPI())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		case GraphicsAPI::OpenGL:
 | 
							case GraphicsAPI::OpenGL:
 | 
				
			||||||
			return CreateRef<glVertexBuffer>(vertices, count);
 | 
								return CreateRef<glVertexBuffer>(vertices, stride, count);
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		case GraphicsAPI::DirectX: LT_WIN(
 | 
							case GraphicsAPI::DirectX: LT_WIN(
 | 
				
			||||||
			return CreateRef<dxVertexBuffer>(vertices, stride, count, std::static_pointer_cast<dxSharedContext>(sharedContext));)
 | 
								return CreateRef<dxVertexBuffer>(vertices, stride, count, std::static_pointer_cast<dxSharedContext>(sharedContext));)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ namespace Light {
 | 
				
			||||||
	Renderer::Renderer(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
 | 
						Renderer::Renderer(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
 | 
				
			||||||
		: m_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext),
 | 
							: m_QuadRenderer(LT_MAX_QUAD_RENDERER_VERTICES, sharedContext),
 | 
				
			||||||
		  m_TextureRenderer(LT_MAX_TEXTURE_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_ViewProjectionBuffer(nullptr),
 | 
				
			||||||
		  m_RenderCommand(nullptr),
 | 
							  m_RenderCommand(nullptr),
 | 
				
			||||||
		  m_Blender(nullptr),
 | 
							  m_Blender(nullptr),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,8 +6,9 @@
 | 
				
			||||||
#include "RendererPrograms/TextureRendererProgram.h"
 | 
					#include "RendererPrograms/TextureRendererProgram.h"
 | 
				
			||||||
#include "RendererPrograms/TintedTextureRendererProgram.h"
 | 
					#include "RendererPrograms/TintedTextureRendererProgram.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define LT_MAX_QUAD_RENDERER_VERTICES    1028u * 4u
 | 
					#define LT_MAX_QUAD_RENDERER_VERTICES              1028u * 4u
 | 
				
			||||||
#define LT_MAX_TEXTURE_RENDERER_VERTICES 1028u * 4u
 | 
					#define LT_MAX_TEXTURE_RENDERER_VERTICES           1028u * 4u
 | 
				
			||||||
 | 
					#define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES    1028u * 4u
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct GLFWwindow;
 | 
					struct GLFWwindow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,11 +39,11 @@ namespace Light {
 | 
				
			||||||
	//==================== CONSTANT_BUFFER ====================//
 | 
						//==================== CONSTANT_BUFFER ====================//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//==================== VERTEX_BUFFER ====================//
 | 
						//==================== VERTEX_BUFFER ====================//
 | 
				
			||||||
	glVertexBuffer::glVertexBuffer(float* vertices, unsigned int count)
 | 
						glVertexBuffer::glVertexBuffer(float* vertices, unsigned int stride, unsigned int count)
 | 
				
			||||||
		: m_BufferID(NULL)
 | 
							: m_BufferID(NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		glCreateBuffers(1, &m_BufferID);
 | 
							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()
 | 
						glVertexBuffer::~glVertexBuffer()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,7 @@ namespace Light {
 | 
				
			||||||
		unsigned int m_BufferID;
 | 
							unsigned int m_BufferID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		glVertexBuffer(float* vertices, unsigned int count);
 | 
							glVertexBuffer(float* vertices, unsigned int stride, unsigned int count);
 | 
				
			||||||
		~glVertexBuffer();
 | 
							~glVertexBuffer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void Bind() override;
 | 
							void Bind() override;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue