PDA

View Full Version : Display List



guju
05-17-2002, 12:14 AM
I want to show my vertices with GLUspheres, to make them better visible. Therefore i created a display list.
void MyGLWidget::drawCircle (GLfloat x,GLfloat y,GLfloat z) {
glPushMatrix();
glTranslatef(x,y,z);
glCallList(circleList);
glPopMatrix();
}
The display list is created during the init:
void MyGLWidget::createCircleList (void) {
GLUquadricObj *nodeSphere=gluNewQuadric();
float radius = 15.0f;
int slices = 10;
int stacks = 10;
circleList = glGenLists(1);
glNewList (circleList, GL_COMPILE);
gluSphere(nodeSphere,radius,slices,stacks);
glEndList();
}
For each node i call the following code:
for(int i=0;i<numVertices;i++){
glBegin (GL_POINTS);
glVertex3f(vertices[i*3],vertices[i*3+1],vertices[i*3+2]);
if (bigVertices) {
drawCircle (vertices[i*3],vertices[i*3+1],vertices[i*3+2]);
}
glEnd();
}
But the speres are not drawen on the nodes?? What is wrong defined, or is there a better way to define visble nodes!

Thanks for your help
Juergen

Robbo
05-17-2002, 03:52 AM
Slight misunderstanding on how this all works! I'll try and help here:

void MyGLWidget::drawCircle (GLfloat x,GLfloat y,GLfloat z) {
glPushMatrix();
glTranslatef(x,y,z);
glCallList(circleList);
glPopMatrix();
}
void MyGLWidget::createCircleList (void) {

GLUquadricObj *nodeSphere=gluNewQuadric();
float radius = 15.0f;
int slices = 10;
int stacks = 10;
circleList = glGenLists(1);
glNewList (circleList, GL_COMPILE);
gluSphere(nodeSphere,radius,slices,stacks);
glEndList();
}

For each node:

if ( bigVertices)
{
for(int i=0;i<numVertices;i++)
{
DrawCircle(vertices[i*3],vertices [i*3+1],vertices[i*3+2]);
}
}
else
{
glBegin ( GL_POINTS);
for(int i=0;i<numVertices;i++)
{
glVertex3f(vertices[i*3],vertices[i*3+1],vertices[i*3+2]);
}
glEnd ();
}


Also, I didn't see you delete that quadric object after use? (memory leak?).

guju
05-17-2002, 04:03 AM
Hi Robbo!
Thanks for your reply! I made the changes like you sayed, but i can not see any spheres? Nothing is displayed at the vertex positions!
Juergen

Robbo
05-17-2002, 04:10 AM
Just out of curiosity, how exactly are your vertices being stored?

I note:

Vertices [i*3]
Vertices [i*3+1]
Vertices [i*3+2]

I am assuming your vertices are something like:

float Vertices [SOME LARGE NUMBER];

Try printing out or debugging say the first 5 or so vertex values (ie. floats 0 to 14) and paste them in here so we can have a look. They might be incorrect - .

Robbo
05-17-2002, 04:11 AM
Of course, you can always change the point size of the GL_POINTS in OpenGL.

guju
05-17-2002, 08:33 AM
I am sorry but the error was the too big radius !!
sorry
juergen