From ae9a83cca5e69c1e5abeca3c5f47270e4d6e684f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 9 May 2011 19:37:19 -0400 Subject: [PATCH] remove color vertex attribute --- lighting/test.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lighting/test.cc b/lighting/test.cc index ae0aee0..d27f293 100644 --- a/lighting/test.cc +++ b/lighting/test.cc @@ -15,13 +15,13 @@ using namespace std; #define STRIDE(a, b) ((unsigned long)(b) - (unsigned long)(a)) #define OFFSET(a, b) ((const GLvoid *)STRIDE((a), (b))) -const GLfloat data[][3][3] = { - {{-1.0, -0.6, 0.0}, {1, 0, 0}, {0, 0, 1}}, - {{-0.2, -0.6, 0.0}, {0, 1, 0}, {0, 0, 1}}, - {{-0.6, 0.6, 0.0}, {0, 0, 1}, {0, 0, 1}}, - {{0.2, -0.6, 0.0}, {1, 0, 0}, {0, 0.7071, 0.7071}}, - {{1.0, -0.6, 0.0}, {0, 1, 0}, {0, 0.7071, 0.7071}}, - {{0.6, 0.6, -10.0}, {0, 0, 1}, {0, 0.7071, 0.7071}} +const GLfloat data[][2][3] = { + {{-1.0, -0.6, 0.0}, {0, 0, 1}}, + {{-0.2, -0.6, 0.0}, {0, 0, 1}}, + {{-0.6, 0.6, 0.0}, {0, 0, 1}}, + {{0.2, -0.6, 0.0}, {0, 0.7071, 0.7071}}, + {{1.0, -0.6, 0.0}, {0, 0.7071, 0.7071}}, + {{0.6, 0.6, -10.0}, {0, 0.7071, 0.7071}} }; const GLushort indices[] = { 0, 1, 2, 3, 4, 5 @@ -30,7 +30,6 @@ GLuint program, vs, fs, data_vbo, index_vbo; GLint ambient_loc, diffuse_loc, specular_loc, shininess_loc; enum Locations { LOC_POSITION, - LOC_COLOR, LOC_NORMAL }; @@ -155,7 +154,6 @@ bool init(int width, int height) glAttachShader(program, fs); glBindAttribLocation(program, LOC_POSITION, "pos"); - glBindAttribLocation(program, LOC_COLOR, "color"); glBindAttribLocation(program, LOC_NORMAL, "normal"); glLinkProgram(program); @@ -196,14 +194,11 @@ void display(void) glBindBuffer(GL_ARRAY_BUFFER, data_vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_vbo); glEnableVertexAttribArray(LOC_POSITION); - glEnableVertexAttribArray(LOC_COLOR); glEnableVertexAttribArray(LOC_NORMAL); glVertexAttribPointer(LOC_POSITION, 3, GL_FLOAT, GL_FALSE, STRIDE(&data[0], &data[1]), OFFSET(&data[0], &data[0][0])); - glVertexAttribPointer(LOC_COLOR, 3, GL_FLOAT, GL_FALSE, - STRIDE(&data[0], &data[1]), OFFSET(&data[0], &data[0][1])); glVertexAttribPointer(LOC_NORMAL, 3, GL_FLOAT, GL_FALSE, - STRIDE(&data[0], &data[1]), OFFSET(&data[0], &data[0][2])); + STRIDE(&data[0], &data[1]), OFFSET(&data[0], &data[0][1])); glDrawElements(GL_TRIANGLES, sizeof(indices)/sizeof(indices[0]), GL_UNSIGNED_SHORT, OFFSET(&indices, &indices[0])); SDL_GL_SwapBuffers();