mesh->VAO = 0;
mesh->VBO = 0;
mesh->remove = false;
- mesh->vertices = (GLfloat *) vertices;
+ mesh->vertices = vertices;
mesh->count = count;
return mesh;
}
#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wpedantic"
+#pragma GCC diagnostic ignored "-Wpedantic"
void mesh_transform(Mesh *mesh)
{
glBindVertexArray(mesh->VAO);
glBindBuffer(GL_ARRAY_BUFFER, mesh->VBO);
- glBufferData(GL_ARRAY_BUFFER, mesh->count * 6, mesh->vertices, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, mesh->count * sizeof(Vertex), mesh->vertices, GL_STATIC_DRAW);
- GLsizei stride = 6 * sizeof(GLfloat);
-
- glVertexAttribPointer(0, 3, GL_FLOAT, false, stride, (GLvoid *)(0 * sizeof(GLfloat)));
+ glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *)(0 * sizeof(GLfloat)));
glEnableVertexAttribArray(0);
- glVertexAttribPointer(1, 3, GL_FLOAT, false, stride, (GLvoid *)(3 * sizeof(GLfloat)));
+ glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(Vertex), (GLvoid *)(3 * sizeof(GLfloat)));
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#include "shaders.h"
#include "types.h"
+typedef struct
+{
+ GLfloat x, y, z;
+ GLfloat r, g, b;
+} __attribute__((packed, aligned(4))) Vertex;
+
typedef struct
{
v3f pos, rot, scale;
mat4x4 transform;
GLuint VAO, VBO;
bool remove;
- GLfloat *vertices;
+ Vertex *vertices;
GLsizei count;
} Mesh;
-typedef struct
-{
- GLfloat x, y, z;
- GLfloat r, g, b;
-} __attribute__((packed, aligned(4))) Vertex;
-
Mesh *mesh_create(Vertex *vertices, GLsizei count);
void mesh_delete(Mesh *mesh);
void mesh_transform(Mesh *mesh);