triangle has now colors

This commit is contained in:
2026-04-13 01:32:31 +02:00
parent 64b27a6b84
commit 0c74cf691f
7 changed files with 46 additions and 18 deletions

View File

@@ -12,8 +12,12 @@ struct VertexBuffer {
glBindBuffer(GL_ARRAY_BUFFER, bufferId);
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(Vertex), data, GL_STATIC_DRAW);
// POSITION
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), offsetof(struct Vertex,x));
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex,x));
// COLOR
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex,r));
glBindVertexArray(0);
};

View File

@@ -15,5 +15,6 @@ typedef float float32;
typedef double float64;
struct Vertex {
float32 x, y, z;
float32 x, y, z; // position
float32 r, g, b, a; // color
};