fix: encapsulate OpenGL types in VertexAttribute to eliminate raw GL API usage in tests
- Add VertexAttributeType and VertexAttributeNormalized enums in OpenGLVertexArray.h - Add ToGLAttributeType() converter in OpenGLVertexArray.cpp - Remove glActiveTexture() call from quad test (already handled by texture.Bind()) - Remove #include <glad/glad.h> from triangle test - Update unit tests to use encapsulated enums All three OpenGL integration tests (minimal, triangle, quad) pass with 0% pixel difference.
This commit is contained in:
@@ -127,8 +127,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
VertexAttribute posAttr = {};
|
||||
posAttr.index = 0;
|
||||
posAttr.count = 4;
|
||||
posAttr.type = GL_FLOAT;
|
||||
posAttr.normalized = GL_FALSE;
|
||||
posAttr.type = VertexAttributeType::Float;
|
||||
posAttr.normalized = VertexAttributeNormalized::False;
|
||||
posAttr.stride = sizeof(Vertex);
|
||||
posAttr.offset = 0;
|
||||
vertexArray.AddVertexBuffer(vertexBuffer.GetID(), posAttr);
|
||||
@@ -136,8 +136,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
VertexAttribute texAttr = {};
|
||||
texAttr.index = 1;
|
||||
texAttr.count = 2;
|
||||
texAttr.type = GL_FLOAT;
|
||||
texAttr.normalized = GL_FALSE;
|
||||
texAttr.type = VertexAttributeType::Float;
|
||||
texAttr.normalized = VertexAttributeNormalized::False;
|
||||
texAttr.stride = sizeof(Vertex);
|
||||
texAttr.offset = sizeof(float) * 4;
|
||||
vertexArray.AddVertexBuffer(vertexBuffer.GetID(), texAttr);
|
||||
@@ -200,7 +200,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
pipelineState.Bind();
|
||||
vertexArray.Bind();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
texture.Bind(0);
|
||||
sampler.Bind(0);
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLSwapChain.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLCommandList.h"
|
||||
@@ -124,8 +122,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
VertexAttribute posAttr = {};
|
||||
posAttr.index = 0;
|
||||
posAttr.count = 4;
|
||||
posAttr.type = GL_FLOAT;
|
||||
posAttr.normalized = GL_FALSE;
|
||||
posAttr.type = VertexAttributeType::Float;
|
||||
posAttr.normalized = VertexAttributeNormalized::False;
|
||||
posAttr.stride = sizeof(Vertex);
|
||||
posAttr.offset = 0;
|
||||
vertexArray.AddVertexBuffer(vertexBuffer.GetID(), posAttr);
|
||||
@@ -133,8 +131,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
VertexAttribute colAttr = {};
|
||||
colAttr.index = 1;
|
||||
colAttr.count = 4;
|
||||
colAttr.type = GL_FLOAT;
|
||||
colAttr.normalized = GL_FALSE;
|
||||
colAttr.type = VertexAttributeType::Float;
|
||||
colAttr.normalized = VertexAttributeNormalized::False;
|
||||
colAttr.stride = sizeof(Vertex);
|
||||
colAttr.offset = sizeof(float) * 4;
|
||||
vertexArray.AddVertexBuffer(vertexBuffer.GetID(), colAttr);
|
||||
|
||||
@@ -54,8 +54,8 @@ TEST_F(OpenGLTestFixture, CommandList_Draw_VAO) {
|
||||
VertexAttribute attr;
|
||||
attr.index = 0;
|
||||
attr.count = 3;
|
||||
attr.type = GL_FLOAT;
|
||||
attr.normalized = false;
|
||||
attr.type = VertexAttributeType::Float;
|
||||
attr.normalized = VertexAttributeNormalized::False;
|
||||
attr.stride = sizeof(float) * 3;
|
||||
attr.offset = 0;
|
||||
vao.AddVertexBuffer(vbo.GetID(), attr);
|
||||
|
||||
@@ -25,8 +25,8 @@ TEST_F(OpenGLTestFixture, VertexArray_AddVertexBuffer) {
|
||||
VertexAttribute attr;
|
||||
attr.index = 0;
|
||||
attr.count = 3;
|
||||
attr.type = GL_FLOAT;
|
||||
attr.normalized = false;
|
||||
attr.type = VertexAttributeType::Float;
|
||||
attr.normalized = VertexAttributeNormalized::False;
|
||||
attr.stride = sizeof(float) * 3;
|
||||
attr.offset = 0;
|
||||
|
||||
@@ -84,16 +84,16 @@ TEST_F(OpenGLTestFixture, VertexArray_Bind_MultipleAttributes) {
|
||||
VertexAttribute attrPos;
|
||||
attrPos.index = 0;
|
||||
attrPos.count = 2;
|
||||
attrPos.type = GL_FLOAT;
|
||||
attrPos.normalized = false;
|
||||
attrPos.type = VertexAttributeType::Float;
|
||||
attrPos.normalized = VertexAttributeNormalized::False;
|
||||
attrPos.stride = sizeof(float) * 2;
|
||||
attrPos.offset = 0;
|
||||
|
||||
VertexAttribute attrColor;
|
||||
attrColor.index = 1;
|
||||
attrColor.count = 4;
|
||||
attrColor.type = GL_FLOAT;
|
||||
attrColor.normalized = false;
|
||||
attrColor.type = VertexAttributeType::Float;
|
||||
attrColor.normalized = VertexAttributeNormalized::False;
|
||||
attrColor.stride = sizeof(float) * 4;
|
||||
attrColor.offset = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user