Can someone please explain to me how to modify a display list in OpenGL once its compiled? How can I enforce, for example a matrix transformation on it?
Thanks in advance.
Display lists are immutable; you cannot alter them once created. That's pretty much the point of them.
If you want to have geometry built into a display list that can be rendered at a place defined by a matrix, you simply don't put matrix commands in the display list. Just put the drawing stuff in a display list. When you want to render that geometry, do the setup work (including matrix stuff) and then execute the display list.
Your current code looks something like this:
//Every frame
glRotatef(...);
glTranslatef(...);
///More setup work.
glBegin(...);
glVertex/TexCoord/Color/etc(...);
...
glEnd();
Your display list-based code should look like this:
//Initialization. Done once.
glBeginList(...);
glBegin(...);
glVertex/TexCoord/Color/etc(...);
...
glEnd();
glEndList();
//Every frame
glRotatef(...);
glTranslatef(...);
...
glCallList(...);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.