- 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.
65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
enum class VertexAttributeType {
|
|
Float = 0,
|
|
Int,
|
|
UnsignedInt,
|
|
Short,
|
|
UnsignedShort,
|
|
Byte,
|
|
UnsignedByte,
|
|
Double,
|
|
HalfFloat,
|
|
Fixed,
|
|
Int2101010Rev,
|
|
UnsignedInt2101010Rev,
|
|
UnsignedInt10F11F11FRev
|
|
};
|
|
|
|
enum class VertexAttributeNormalized {
|
|
False = 0,
|
|
True
|
|
};
|
|
|
|
struct VertexAttribute {
|
|
unsigned int index;
|
|
int count;
|
|
VertexAttributeType type;
|
|
VertexAttributeNormalized normalized;
|
|
size_t stride;
|
|
size_t offset;
|
|
};
|
|
|
|
class OpenGLVertexArray {
|
|
public:
|
|
OpenGLVertexArray();
|
|
~OpenGLVertexArray();
|
|
|
|
bool Initialize();
|
|
void AddVertexBuffer(unsigned int buffer, const VertexAttribute& attribute);
|
|
void SetIndexBuffer(unsigned int buffer, unsigned int type);
|
|
void Shutdown();
|
|
|
|
void Bind() const;
|
|
void Unbind() const;
|
|
|
|
unsigned int GetID() const { return m_vao; }
|
|
unsigned int GetIndexBuffer() const { return m_indexBuffer; }
|
|
unsigned int GetIndexCount() const { return m_indexCount; }
|
|
|
|
private:
|
|
unsigned int m_vao;
|
|
unsigned int m_indexBuffer;
|
|
unsigned int m_indexCount;
|
|
int m_vertexBufferCount;
|
|
};
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|