diff options
Diffstat (limited to 'gltest.c')
-rw-r--r-- | gltest.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -11,6 +11,7 @@ #include "linmath.h" #include "loadgl.h" #include "shaders.h" +#include "nelem.h" enum { WIDTH = 800, @@ -35,11 +36,15 @@ int main(int argc, char **argv) int ret; GLuint ebo, vbo, vao, prog; GLint ucolor; - vec3 verts[] = { - { 0.5f, 0.5f, 0.0f }, - { 0.5f, -0.5f, 0.0f }, - { -0.5f, -0.5f, 0.0f }, - { -0.5f, 0.5f, 0.0f }, + struct vertex { + vec3 pos; + vec3 col; + vec2 uv; + } verts[] = { + {{ 0.5, 0.5, 0.0 }, { 1.0, 0.0, 0.0 }, { 1.0, 1.0 }}, + {{ 0.5, -0.5, 0.0 }, { 0.0, 1.0, 0.0 }, { 1.0, 0.0 }}, + {{ -0.5, -0.5, 0.0 }, { 0.0, 0.0, 1.0 }, { 0.0, 0.0 }}, + {{ -0.5, 0.5, 0.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0 }}, }; GLuint idxs[] = { 0, 1, 3, @@ -77,8 +82,12 @@ int main(int argc, char **argv) gl_buf_bind(GL_ELEMENT_ARRAY_BUFFER, ebo); gl_buf_data(GL_ELEMENT_ARRAY_BUFFER, sizeof idxs, idxs, GL_STATIC_DRAW); - gl_va_define(0, 3, GL_FLOAT, GL_FALSE, sizeof *verts, 0); + gl_va_define(0, NELEM(verts[0].pos), GL_FLOAT, GL_FALSE, sizeof *verts, (void *)offsetof(struct vertex, pos)); gl_va_enable(0); + gl_va_define(1, NELEM(verts[0].col), GL_FLOAT, GL_FALSE, sizeof *verts, (void *)offsetof(struct vertex, col)); + gl_va_enable(1); + gl_va_define(2, NELEM(verts[0].uv), GL_FLOAT, GL_FALSE, sizeof *verts, (void *)offsetof(struct vertex, uv)); + gl_va_enable(2); prog = glprog_load(2, (struct shdrdat []){ { GL_VERTEX_SHADER, shader_vert_data, shader_vert_size }, |