Help needed on glNormalsPointer

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Help needed on glNormalsPointer

Postby mortefer » Mon Dec 22, 2008 5:05 pm

hello guys,

i've got a little problem here. The situation is:
i'm drawing a shape using glDrawArrays(GL_TRIANGLE_STRIP,...)
as an example when drawing 2 triangles i have 4 vertexes.

Next i want to shade it. i set up an array of normals to use with glNormalPointer.
For 4 vertexes in vertex array how much normals must i have in normals array? is it 4 (one per each vertex in array) or 6 (one per each vertex in every triangle)?

Any help will be appreciated.
mortefer
Experienced Developer
Experienced Developer
 
Posts: 54
Joined: Sat Dec 20, 2008 11:24 am

Top

Postby mortefer » Mon Dec 22, 2008 6:49 pm

Okay solution found :)
There should be exactly 1 normal in normal array for a vertex in a vertex array, i.e. if i have 4 vertices i should have 4 normals.

Going further i want to share with you a problem that i had and successfully solved (this might help someone).
i was drawing some polygons using
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 100, 50); //notice that the offset is 100
before drawing i was applying normals array and guess what? lighting was really bad. the thing was that i had to shift normals array for the same offset that i use for drawing (in my case i just left first 100 items in the normals array empty, and filled normals starting from 100).

That solved everything, lighting now works great.
mortefer
Experienced Developer
Experienced Developer
 
Posts: 54
Joined: Sat Dec 20, 2008 11:24 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests