VBO and lighting
Hi there - im trying to render some cubes that are imported via 3ds model class - and im putting the cubes in a VBO - sorry for the long code ( i dont know how to put conde in the message).... When putting lighing in the scene - the scene becomes darker - but no visible light like :P - i think im doing something wrong with the normals - becouse when i change the code from DrawDinamicVBO -(this code: glNormalPointer(GL_FLOAT,0, (char*)NULL); ) to glNormalPointer(GL_FLOAT,0, model.normalvector); i can see the light render but with very many artefacts.
I also move the objects in the scene during rendering (not translate - actual moving of the vertex)
Thanks!
///////////FUNCTIONS TO CREATE AND RENDER VBO
void GL_Game::CreateDYNAMIC_VBO(CModel &model)
{
for(int i = 0; i<MAX_VERTICES; i++)
{
g_DiceManager.actorManager.playerCoordinates = model.VertexVector;
g_DiceManager.actorManager.DefaultPlayerCoordinates = model.VertexVector;
}
//Vertex
glGenBuffersARB(1, &model.playerVBuffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerVBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, model.k*3*sizeof(float), g_DiceManager.actorManager.playerCoordinates, GL_STREAM_DRAW_ARB);
//Texture
glGenBuffersARB(1, &model.playerTBuffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerTBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, model.k*2*sizeof(float), model.TextureVector, GL_STATIC_DRAW_ARB);
//Normal
glGenBuffersARB(1, &model.playerNBuffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerNBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, model.k*3*sizeof(float), model.NormalsVector, GL_STREAM_DRAW_ARB);
}
void GL_Game::DrawDYNAMIC_VBO(CModel& model)
{
glBindTexture(GL_TEXTURE_2D, model.texID);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerVBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, model.k*3*sizeof(float), g_DiceManager.actorManager.playerCoordinates, GL_STREAM_DRAW_ARB);
glVertexPointer(3,GL_FLOAT,0,(char*)NULL);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerNBuffer);
glNormalPointer(GL_FLOAT,0, (char*)NULL);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model.playerTBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, (char *) NULL );
glDrawArrays(RENDER_MODE,0, model.k);
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement