We help IT Professionals succeed at work.

glNewList glCallList in opengl

mschwab1225
mschwab1225 asked
on
I have to write a program.  I'm using Microsoft visual c++.  When you resize the window everything clears.  I was told that if you used glNewList and glCallList, you could redraw the window.  I did it but I cannot get it to work.  
Comment
Watch Question

Commented:
can u be more specific ?
Commented:
When using OpenGL, you need to redraw the scene on every frame, this includes redrawing when the canvas is reshown.  

If there is no animation (ie. every frame is the same), you can put your draw commands in a list and then instead of executing the commands straight off, you call the list in stead.

Creating the list should look something like:

int listname;
glGenLists(1, &listname);
glNewList(listname, GL_COMPILE);
/* do all the draw stuff */
glEndList();  /* All the drawing is now saved in a list */

...

Then at every redraw:
glCallList(listname);

Note that this only works well for static scenes.  Most of the time, you can just simply redraw the scene every time anyways, so it's not really necessary to use lists for this purpose.

If you want more details, I'll suggest the book "OpenGL Programming Guide".  Definitely worth a read if you're going to use OpenGL for serious work.
glNewList() and glCallList() just create and execute display lists.  They have nothing at all to do with redrawing the scene (except for the fact that they may actually contain some of the drawing operations).

When the window is resized you will want to redimension the viewing frustrum accordingly to keep things in perspective.  The you will want to swap the buffers and keep going.

Commented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "cd.smith" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force-accepted by
Netminder
CS Moderator