Hi,
I'm having some problems rendering a model when I use normals and add
lighting while using VBO's. When I turn off lighting I can see my model(I
see a white circle, and my model is a barrel). But when I enable lighting my
screen turns to black.
Here's my code(shortent) that loads the normals to a buffer and passes it to
OpenGL:
-- Begin Code --
m_normals = new GLfloat[m_NumFaces * NORMALS_PER_FACE * 3];
unsigned int cur_face = 0;
for(Lib3dsMesh * mesh = m_l3ds_file->meshes; mesh != NULL; mesh=mesh->next)
{
Lib3dsVector * normals = new Lib3dsVector[mesh->faces * VERTICES_PER_FACE];
lib3ds_mesh_calculate_normals(mesh, normals);
// [..]
for(unsigned int i = 0; i < mesh->faces; i++)
{
// [..]
for(unsigned int j = 0;j < 3;j++)
{
// [..]
memcpy(&m_normals[(cur_face * NORMALS_PER_FACE + j) * 3],
normals[i*NORMALS_PER_FACE + j], sizeof(GLfloat)*3);
}
cur_face++;
}
}
// [..]
glGenBuffers(1, &vbo_normals);
glBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * model->m_NumFaces *
NORMALS_PER_FACE * 3, model->m_normals, GL_STATIC_DRAW);
glEnableClientState( GL_NORMAL_ARRAY );
[..]
glBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
glNormalPointer(GL_FLOAT, 0, NULL);
glDrawArrays(GL_TRIANGLES, 0, model->m_NumFaces*VERTICES_PER_FACE);
[..]
glDisableClientState( GL_NORMAL_ARRAY );
-- End Code --
Does anyone know why I am not seeing anything? I just can't figure it out.
Thanks in advance,
Hylke
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel