Jump to content
  • Advertisement
Sign in to follow this  
yadaddy

OpenGL problem with depth + blending

This topic is 4690 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I'm relatively new to OpenGL. I want to do the following. I use glOrtho, because i want z-ordered objects. Imagine you have a background at a far layer and you want to draw a moving item in front of it. I do not want to clear the whole scene, redraw the background and then the moved item, i just want to clear the "moving item"-layer and leave the background unchanged (for example, the opengl pipeline draws it for me automatically, and not i manually). How can I do it? I have tried with displaylists (save background and paint it every move again), but this costs time and makes my program slow. Imagine I want to do something like the desktop of your system: background == the items moving item == mouse-selection-box But on desktop i dont have many items to repaint, in my programm this are far much more: many circles, lines (could be 100000 of such primitives or even more) with alpha-blending. So if you move your mouse, you see, that the background is updated slowly and the mouse-selection-box is hanging and stacking. So how can I solve this solution? I need only to have my mouse-selection-box redrawn and not the whole scene. thx. yadaddy.

Share this post


Link to post
Share on other sites
Advertisement
Well if you are sure you really can't redraw the scene each time (sounds like a strange scene, what is it you are actually rendering?), then you could render to texture:
Basically you create another draw buffer in memory with a texture attached to it, then you render the background to this buffer. Then in the main buffer you draw a textured quad covering the entire screen with the texture, and your selection box over the top.
Also you could go old-school and use inverted colors on your selection box:
if you apply an XOR to all pixels the selection box is drawn over then you will get a box which will (almost) always show up regardless of the background color. But the clever bit is that you can remove the box by simple XORing over it again.

Share this post


Link to post
Share on other sites
Use your front and back buffer. You swap buffers in one of two ways. Either you copy the back buffer to the front or switch which is considered front and back. If you copy the buffer then just draw the mouse cursor on the front buffer after the swap. If you switch buffers then copy the region of the of previous mouse cursor from back to front, swap and draw the mouse cursor on the front buffer in the new position.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!