glColor不实际改变OpenGL的颜色 [英] glColor not actually changing OpenGL's color

查看:225
本文介绍了glColor不实际改变OpenGL的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特别恼人的问题。在某些情况下,对glColor的调用似乎被忽略,导致对象显示的颜色不正确。

I am having a particularly annoying problem. In certain situations, calls to glColor appear to be ignored, resulting in objects being displayed with the incorrect color.

显示此问题的Qt项目可以找到此处

A Qt project which shows this problem can be found here.

当您运行该程序时,看到屏幕上是两个盒状的对象,从一个角度来看。左边的对象通过调用 glCallList(boxModel1); 来呈现,右边的对象通过调用 glCallList(boxModel2) code>。

When you run the program, all you see on the screen is two box-like objects, viewed from an angle. The object on the left is rendered by calling glCallList(boxModel1); and the object on the right is rendered by calling glCallList(boxModel2);. The two display lists are created by obviously-titled methods.

对于 boxModel1 boxModel2 ,我使用一个名为 squareModel 的显示列表来渲染框的两侧。我这样做是因为虽然在这种情况下的平方模型是微不足道的,在我的实际程序中的 squareModel 是更复杂,与改变法线等。

For both boxModel1 and boxModel2, I use a single display list called squareModel to render the sides of the boxes. I do this because while the square model in this case is trivial, the squareModel in my actual program is much more complex, with altered normals and etc.

问题与 createManyRectangles 方法有关。当它调用一个足够小的数字(我为2715),颜色正常显示:一个蓝色的盒子和一个红色的盒子。

The problem has something to do with the createManyRectangles method. When it is called with a small enough number (2715 for me), the colors appear normally: a blue box and a red box. When the number is high (2716 for me), the colors are ignored, and both boxes are rendered white.

任何人都可以对这里发生的事情有所了解吗?

Can anyone shed some light on what is happening here?

推荐答案

尝试使用 glIntercept 。这允许您记录每个OpenGL调用。比较您在2715和2716个矩形之间获得的输出。

Try to run your program with glIntercept. This allows you to record every OpenGL call made. Compare the output you get between the 2715 and 2716 number of rectangles. If there are any differences, it should lead you in the right direction.

因为你实际的OpenGL调用似乎确定,它可能是一个驱动程序问题,你提到。你可以尝试不同的环境(视频卡,pc等),因为图腾指出,他没有遇到你的问题。也许你可以给你的环境一些信息?

Since your actual OpenGL calls seem ok, it could be a driver problem as you mentioned. You could try different environments (video card, pc, etc) since as totem pointed out, he didn't experience your problem. Perhaps you could give some info on your environment?

尝试渲染没有显示列表的矩形,看看是否有帮助。在您将使用 glCallList 的地方,重做OpenGL调用的顺序。如果解决了这个问题,你会知道应用程序或驱动程序中的显示列表管理有问题。

Try rendering your rectangles without display lists to see if that helps. Where you would use glCallList, redo the sequence of OpenGL calls instead. If that solves the problem, you will know there is a problem with the display lists management in your app or in the driver.

此外,如果显示列表是问题,你真的需要使用显示列表吗?他们越来越少地使用一段时间,现在赞成维也纳国际组织。也许你可以解决你的显示列表问题。

Also, in case display lists turn out to be the problem, do you really need to use display lists? They have been less and less used for a while now in favor of VBOs. Perhaps you can "solve" your display list problem with that.

这篇关于glColor不实际改变OpenGL的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆