简体   繁体   English

OpenGL显示清单

[英]OpenGL Display Lists

Can someone please explain to me how to modify a display list in OpenGL once its compiled? 有人可以向我解释一下一旦编译后如何在OpenGL中修改显示列表? 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(...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM