PDA

View Full Version : Normals in Vertex Buffer Object

yalmar
10-12-2007, 10:55 AM
Hi folks,

I have a small problem with VBOs,

for example, if we want to render a simple BOX the VBO syntax requires something like

GLfloat vertices[] = {1,1,1, -1,1,1, -1,-1,1, 1,-1,1,
1,-1,-1, -1,-1,-1, -1,1,-1, 1,1,-1};

GLfloat normals[] = {0.577, 0.577, 0.577, -0.577, 0.577, 0.577, -0.577, -0.577, 0.577, 0.577, -0.577, 0.577,
0.577, -0.577, -0.577, -0.577, -0.577, -0.577, -0.577, 0.577, -0.577, 0.577, 0.577, -0.577};

GLfloat colors[] = {1,1,1, 1,1,0, 1,0,0, 1,0,1,
0,0,1, 0,0,0, 0,1,0, 0,1,1};

GLushort indices[] = {0, 1, 2, 0, 2, 3,
0, 3, 4, 0, 4, 7,
0, 7, 6, 0, 6, 1,
1, 6, 5, 1, 5, 2,
5, 4, 3, 5, 3, 2,
4, 5, 6, 4, 6, 7};observe that, for each vertex there is a normal, i want to use an only normal for each facet (triangle). Is it possible?

Yalmar

Korval
10-12-2007, 11:06 AM
observe that, for each vertex there is a normal, i want to use an only normal for each facet (triangle).You can use flat shading. That will only use the first normal passed for a particular triangle.

yalmar
10-12-2007, 11:57 AM
Thanks for answer my question Korval, do you have any example? or some reference where i can see how to use that.

Thanks again,

oc2k1
10-12-2007, 12:48 PM
Vertices with different normal are different vertices.... so a simple box requires 24, because for each of the 8 vertexposition 3 different normals exist. The index is for that type of primitive needless.

yalmar
10-12-2007, 01:07 PM
Sorry, I understand now,

simple, right?

Thanks Korval,