remove color vertex attribute

This commit is contained in:
Josh Holtrop 2011-05-09 19:37:19 -04:00
parent 921ea83b01
commit ae9a83cca5

View File

@ -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();