glPushName + glPopName 堆栈上溢和下溢

发布于 2024-08-24 14:22:47 字数 308 浏览 7 评论 0原文

谁能解释一下如何使用 glPushName 和 glPopName。我喜欢使用它们而不是 glLoadName,但我总是会遇到 GL_STACK_OVERFLOW 和 GL_STACK_UNDERFLOW 错误。 (先低于,后溢出)。

示例代码也会对我有帮助。

注意#1: 我的 Rendering/selection_rednering 代码由多个 glBegin(...)/glEnd() 块组成(如果这是任何问题)加上各种旋转和变换。

注意#2: 我知道 GL 选择/拾取已被弃用,但我必须在不久前使用 OpenGL2.1 开发的应用程序中实现它。

Can anybody explain me how to use glPushName and glPopName. I like to use them instead of glLoadName, but I laways get GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors. (First, under then overflow).

Example code would help me too.

Note #1:
My Rendering/selection_rednering code consists of multiple glBegin(...)/glEnd() blocks, if this is any problem plus various Rotations and Transformations.

Note #2:
I know that GL selection / picking is deprecated, but I have to implement it within a Application which was developed a with OpenGL2.1 a while ago.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凶凌 2024-08-31 14:22:47

在这种情况下,我只是愚蠢,因为堆栈溢出是由于执行过多的 glPushMatrix 引起的,因为该堆栈的容量非常低(在我的特殊硬件情况下为 3)。绘图模式工作得很好,但我有一个额外的矩阵用于拾取模式。

如何使用 glPopName /glPushName(name)

glPushName(obj->name());
glBegin(...);
//draw it;
glEnd();

glPushName(obj->child->name());
glBegin(...);
//draw child it;
glEnd();

glPopName();
glPopName(); //important, or yoou will get a stackoverflow after some time

In this case I was just dumb, because that stackoverflow was caused by doing to much glPushMatrix, as that stack has a very low capacity (3 in my special hardware case). Drawing mode worked just fine, but I have an additional Matrix used for picking mode.

How to use glPopName /glPushName(name)

glPushName(obj->name());
glBegin(...);
//draw it;
glEnd();

glPushName(obj->child->name());
glBegin(...);
//draw child it;
glEnd();

glPopName();
glPopName(); //important, or yoou will get a stackoverflow after some time
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文