glfreak
05-21-2010, 09:02 AM
What's the differenc ebetween using Vertex Buffer Objects for OpenGL 2.1 and OpenGL 3.1?
Can I use the same method for both core versions?
Alfonse Reinheart
05-21-2010, 02:33 PM
What's the differenc ebetween using Vertex Buffer Objects for OpenGL 2.1 and OpenGL 3.1?
Nothing.
glfreak
05-22-2010, 01:07 AM
The difference is that Nothing is shown on screen :)
ATI [censored] card
glVertexAttribPointer
and non-fixed pipeline = BLANK SCREEN
glfreak
05-22-2010, 11:43 AM
Here's code
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
GLenum glErr = glGetError();
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct VertexLayout), NULL, GL_STATIC_DRAW);
glErr = glGetError();
struct VertexLayout *vertices = (struct VertexLayout *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
glErr = glGetError();
vertices[0].pos[0] = -1; vertices[0].pos[1] = -1; vertices[0].pos[2] = -10; vertices[0].pos[3] = 1;
vertices[0].color[0] = 1; vertices[0].color[1] = 1; vertices[0].color[2] = 1; vertices[0].color[3] = 1;
vertices[1].pos[0] = 1; vertices[1].pos[1] = -1; vertices[1].pos[2] = -10; vertices[1].pos[3] = 1;
vertices[1].color[0] = 1; vertices[1].color[1] = 1; vertices[1].color[2] = 1; vertices[1].color[3] = 1;
vertices[2].pos[0] = 1; vertices[2].pos[1] = 1; vertices[2].pos[2] = -10; vertices[2].pos[3] = 1;
vertices[2].color[0] = 0; vertices[2].color[1] = 1; vertices[2].color[2] = 1; vertices[2].color[3] = 1;
vertices[3].pos[0] = -1; vertices[3].pos[1] = 1; vertices[3].pos[2] = -10; vertices[3].pos[3] = 1;
vertices[3].color[0] = 0; vertices[3].color[1] = 1; vertices[3].color[2] = 1; vertices[3].color[3] = 1;
glUnmapBuffer(GL_ARRAY_BUFFER);
glErr = glGetError();
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(struct VertexLayout), 0);
glErr = glGetError();
struct VertexLayout v;
unsigned int colorStart = ((char *)&v.color[0] - (char *)&v.pos[0]);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(struct VertexLayout), (char *)colorStart);
glErr = glGetError();
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glErr = glGetError();
I then call DrawArrays(GL_TRIANGLE_FAN, 0, 4);
The shape renders fine (square) but in white color.
When I change the vertices color attribute it does not change.
The shader works fine, and I verified it with non VBO using glBeing/End and VertexAttrib, the correct color shows.
Am I missing something here?
glfreak
05-22-2010, 04:25 PM
okay guys, my mistake...it was shader error :D
got it!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.