triangle has now colors
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user