开发者

Possible for glutPostRedisplay() to redraw only certain objects?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜