🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

about drawing the same background

Started by
4 comments, last by zcx0607 15 years, 8 months ago
Hi, all ,I want to draw : in some frames ,the same background (for example, a red polygon) and a small yellow polygon whose poistion related to the pointer. every frames I just want to draw the small yellow polygon,but how to story the buackground.Counld you give me a code segment ? thanks
Advertisement
Basically you dont draw the background, but you clear the screen (better: the color buffer which represents the image being drawn to the screen) with a certain color.
This happens with glClear(GL_COLOR_BUFFER_BIT); and you can choose the color for the clearing operation with glClearColor(float r, float g, float b, float alpha).
I do not konw what is your meaning.
the background is complex,not just a polygon.
Please don't double post. You can edit your original post to add in the new question, or better yet you can reply to this thread with your new question. You can edit the other post to delete it.

You can't really store a background in OpenGL. It is probably best to draw it again each frame.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Of course you can store the background, but you have to render to a FBO or two.
Render the background and the rest into each own fbo, then combine then into the backbuffer.

alternatively render only the background into a fbo and then just after clearing you render that fbo to the backbuffer.
about gl + X window
hi,all. I have an idea.
I save an image (I will use the image in the next frame) from color buffer to accumulation buffer
but, if I keep the window still, the image in the accumulation buffer can be copied to color buffer.
if I resize or move the window , accumulation buffer does not work ( no image is copied to color buffer )

what is wrong?

This topic is closed to new replies.

Advertisement