gl_newbie
09-30-2004, 10:29 PM
Hello, all.
In my programm I used display lists. First of all I built display list:
void Render::BuildGLList()
{
//here I have collection of objects, each of them
//draws itself
}
//for example, FaceSet - one type of objects to draw
//I cannot use simply GL_QUADS or something
//like this, because faces in the set can
//be different, for example one face with 3
//vertices, the other with 4 or 5
void FaceSet::Draw()
{
// each object has its color
glMaterialfv(GL_FRONT, GL_DIFFUSE, .....);
glMaterialfv(GL_FRONT, GL_AMBIENT, .....);
glMaterialfv(GL_FRONT, GL_SPECULAR, .....);
glMaterialfv(GL_FRONT, GL_EMISSION, .....);
for(int i = 0; i < numPols; ++i)
{
glBegin(GL_POLYGON);
for(int j = 0, j < polDesc[i].size(); ++j)
{
// here calls to glVertex
}
glEnd();
}
}After that, I simply call glCallList and I can draw scene from different viewpoints etc - it works not too slow. But It takes a lot of time to built display list and re-build it if scene is modified. So, I want to use gl vertex arrays.
1.Problem.
Due to RedBook glVertexPointer etc are not compiled in display list and executed immideatly.
2.
I tried to modify FaceSet::Draw method to use vertex arrays, now it works very fast, but... I have problem with glMaterialfv calls - my objects are not lit in a right way, they are very strange.
What should I do? I want to use vertex arrays, because display list's building is VERY FAST with them.
In my programm I used display lists. First of all I built display list:
void Render::BuildGLList()
{
//here I have collection of objects, each of them
//draws itself
}
//for example, FaceSet - one type of objects to draw
//I cannot use simply GL_QUADS or something
//like this, because faces in the set can
//be different, for example one face with 3
//vertices, the other with 4 or 5
void FaceSet::Draw()
{
// each object has its color
glMaterialfv(GL_FRONT, GL_DIFFUSE, .....);
glMaterialfv(GL_FRONT, GL_AMBIENT, .....);
glMaterialfv(GL_FRONT, GL_SPECULAR, .....);
glMaterialfv(GL_FRONT, GL_EMISSION, .....);
for(int i = 0; i < numPols; ++i)
{
glBegin(GL_POLYGON);
for(int j = 0, j < polDesc[i].size(); ++j)
{
// here calls to glVertex
}
glEnd();
}
}After that, I simply call glCallList and I can draw scene from different viewpoints etc - it works not too slow. But It takes a lot of time to built display list and re-build it if scene is modified. So, I want to use gl vertex arrays.
1.Problem.
Due to RedBook glVertexPointer etc are not compiled in display list and executed immideatly.
2.
I tried to modify FaceSet::Draw method to use vertex arrays, now it works very fast, but... I have problem with glMaterialfv calls - my objects are not lit in a right way, they are very strange.
What should I do? I want to use vertex arrays, because display list's building is VERY FAST with them.