Complete reformatting of the code following the KDE Frameworks formatting style

This commit is contained in:
2020-10-16 11:50:41 +02:00
parent 5b8060d9b8
commit 23e5f549ca
29 changed files with 694 additions and 579 deletions

View File

@@ -3,11 +3,11 @@
#include "VertexArray.h"
#include "defines.h"
VertexArray::VertexArray(void *vertexData, void *indexData, uint32_t numVertices, uint32_t numIndices) {
VertexArray::VertexArray(void *vertexData, void *indexData, uint32_t numVertices, uint32_t numIndices)
{
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, numVertices * sizeof(Vertex), vertexData, GL_STATIC_DRAW);
@@ -15,31 +15,34 @@ VertexArray::VertexArray(void *vertexData, void *indexData, uint32_t numVertices
glGenBuffers(1, &EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices * sizeof(uint32_t), indexData, GL_STATIC_DRAW);
// Position
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(struct Vertex, position));
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *) offsetof(struct Vertex, position));
// Normal vectors
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(struct Vertex, normalVec));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *) offsetof(struct Vertex, normalVec));
// UV Texture Mapping
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(struct Vertex, textureCoords));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *) offsetof(struct Vertex, textureCoords));
// This will also unbind the vertex buffer and index buffer
glBindVertexArray(0);
}
VertexArray::~VertexArray() {
VertexArray::~VertexArray()
{
glDeleteBuffers(1, &VBO);
}
void VertexArray::bind() {
void VertexArray::bind()
{
glBindVertexArray(VAO);
}
void VertexArray::unbind() {
void VertexArray::unbind()
{
glBindVertexArray(0);
}