glutPostRedisplay() 可以仅重绘某些对象吗?

发布于 2024-12-02 17:44:41 字数 303 浏览 1 评论 0原文

我有一个分形对象,它是用其变量的随机值创建的。我正在使用 C++ 和 OpenGL。但现在,由于我打算使用 glutTimerFunc 来为场景中的其他对象设置动画,因此我需要调用 glutPostRedisplay() 来重绘场景。然而,这会影响完全基于随机值的分形对象,因为 glutPostRedisplay() 会重新播种新的随机值,然后整个对象会改变外观。

如何让 OpenGL 只重新绘制某些对象而不是所有对象?我想过创建一个单独的函数来首先生成随机值数组,然后将该数组传递给绘制分形对象的函数。但该数组可能会非常混乱,因为使用了几个不同的随机值。有更好的方法吗?

I have a fractal object that is created with random values to its variables. I'm using C++ and OpenGL. But now, as I intend to use the glutTimerFunc to animate other objects on the scene, I need to call for glutPostRedisplay() to redraw the scene. However, this would affect the fractal object that was totally based on random values because the glutPostRedisplay() would re-seed for new random values and then the whole object changes outlook.

How can I make OpenGL to re-draw only certain objects and not everything? I have thought of creating a separate function to first generate an array of random values and then pass the array to the function that draws the fractal object. But the array could be very confusing because there several different random values used. Could there be a better way to this?

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

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

发布评论

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

评论(1

放低过去 2024-12-09 17:44:41

OpenGL 不知道什么是“对象”。它只知道你给它什么。如果您使用分形生成顶点,那么您需要保留足够的信息以便稍后重新生成分形,或者需要将生成后的数据保留在某个地方。

我假设您有一些随机数生成算法来制作分形,是吗?嗯,他们通常通过种子数来工作。因此,您可以简单地在生成分形之前获取种子,然后在后续渲染中设置该种子,直到需要更改分形为止。

或者,您可以将分形渲染到屏幕外缓冲区,然后将其传输到屏幕。这将需要使用帧缓冲区对象。

OpenGL does not know what an "object" is. It knows only what you give it. If you are generating vertices with fractals, then you need to either retain sufficient information to regenerate the fractals later, or you need to keep the post-generation data lying around somewhere.

I assume you have some random number generation algorithm for making your fractals, yes? Well, they usually work by seed numbers. So you could simply get the seed before generating the fractal, then set that seed on subsequent renders until it is time to change the fractal.

Alternatively, you could render the fractal to an off-screen buffer, that you then blit to the screen. This will require use of Framebuffer Objects.

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