Jump to content
  • Advertisement
Sign in to follow this  
amtri

OpenGL Drawing to front buffer

This topic is 4194 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

Hi there, Is there a Direct3D equivalent to the OpenGL calls glDrawBuffer(GL_FRONT) and glDrawBuffer(GL_BACK)? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The closest thing I know of is the GetBackBuffer() method which retrieves device's backbuffer which you can modify as you please.

But still , even if there is such way to modify the front buffer manually it is extremely not recommended. There is a reason why you have back and front buffers.

Let DirectX do the dirty work for swapping the buffers for you to achieve a clean and smooth rendering as possible.

Share this post


Link to post
Share on other sites
Ideally you won't be directly manipulating any part of the implicit/explicit swap-chain.

Retrieving and swapping 'pointers' to the elements is required for some RtT operations and that's absolutely fine - but as soon as you want to start reading/writing the raw data you're going to be killing your performance [oh]

hth
Jack

Share this post


Link to post
Share on other sites
Given that everybody seems to be of the opinion that I should draw to the back buffer, then I need one more pointer: all of a sudden I may decide that I need to draw to the front buffer. Since this is not possible, I will need to copy the front buffer to the back buffer, add to the back buffer, then present the back buffer.

How do I copy the front to the back buffer?

Thanks again.

Share this post


Link to post
Share on other sites
I think the method is to render to texture the entire scene. Then render a fullscreen quad with that texture.

Share this post


Link to post
Share on other sites
I thought it would be best if I could give an example of why I thought of writing to the front buffer in the first place.

The problem I have is that my scene is VERY large: maybe 10 million triangles or more. I know it will take time to draw it, but it's ok.

Now suppose I want to zoom into an area, and need to draw a rectangle picked with the mouse for the zoom area. All I want to do is to add the rectangle (or whatever shape I desire) to the front buffer without having to redraw everything. In other words, there is no z-buffering to be done at this point; just simply draw the rectangle on top of what I have.

Does that ring a bell with somebody?

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by amtri
I thought it would be best if I could give an example of why I thought of writing to the front buffer in the first place.

The problem I have is that my scene is VERY large: maybe 10 million triangles or more. I know it will take time to draw it, but it's ok.

Now suppose I want to zoom into an area, and need to draw a rectangle picked with the mouse for the zoom area. All I want to do is to add the rectangle (or whatever shape I desire) to the front buffer without having to redraw everything. In other words, there is no z-buffering to be done at this point; just simply draw the rectangle on top of what I have.

Does that ring a bell with somebody?

Thanks.
Render the whole scene to a texture, then render one quad per frame after that, with the texture applied to the quad. Then you can draw whatever you want on top of it (A selection rectangle for instance).

Share this post


Link to post
Share on other sites
Evil Steve,

It's a good idea, but I would have to do it all the time since I never know when I'm going to need to write to the front buffer.

So I compromised: I count on the hardware's speed and create my device with the option of copying the back buffer into the front buffer. This means both are equal until the next image primitive is drawn.

As long as everything remains synchronized - i.e., the flag to draw to the front buffer is triggered before any new entities are drawn - then the front and back buffers are equal. Then I draw and immediately Present.

It works.

Thanks all!

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!