Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rah

DDraw primary/secondary surfaces question

This topic is 6618 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, In my program I''m currently making, I will be requiring a lot of access manually to the data stored on the secondary surface, and so will be creating it in system memory. Ok now for the question... What is the best way to handle this? Should I still create a primary/backbuffer (both in vid ram), draw everything to an offscreen (sysmem) surface every frame, blit this to the back buffer and THEN flip? Seems slightly wasteful. I realise that just a straight blit from an offscreen (sysmem) surface to the primary (vidmem) surface seems more straight forward, but I''m worried about the flicker posiblities. Any clues on the best way to achieve this? I''m also planning on supporting windowed mode which makes this a little more complex Thanks, Russ

Share this post


Link to post
Share on other sites
Advertisement
hi

I am using Fullscreen Blits, for some special Effects, and there is no Flickering. And if you are Blitting, then making it workin in windowed mode is simple. You only have to blit to the Rectangle from the Window, instead of the entire Screen.
And you do not need to recreate all the Surfaces maybe the Backbuffer, but you can let the blitting Function scale the Data, so that it fits the Window.

By the Way try to create the Surface in NonLocalvideomemory (means AGP Memory) thenn the GPU and the CPU have good access to it.

Lars

Edited by - Lars W. on 4/12/00 1:43:47 PM

Share this post


Link to post
Share on other sites
Hey, why don''t you just create an offscreen surface for "offscreen stuff" like sprites, etc., a secondary surface to blit to, and a primary surface for the final flip. I''ve found that this way is very effective and efficient, no flicker either.

Martin

Share this post


Link to post
Share on other sites
Hi,

Yeah I thought about that, but just thought it seemed a little inefficient (the final flip seems redundant as it could of been blitted directly from the sysmem surface to the primary surface.

I basically just wanted to know if a blit from an offscreen surface (equal size) will result in ''flicker'' effects? Does DDraw automatically wait for the vsync before a blit to the primary, or would waiting for the vertical blank be advised?

Thanks,
Russ

Share this post


Link to post
Share on other sites
Hmm...well, with my limited experience of DirectX, I''d have to say that the blit-to-secondary-surface-and-flip-to-primary-surface method is anything but redundant. By the way, this system is called double buffering, and is useful because while one frame of the game is being displayed on the screen, the next frame is being drawn to the secondary surface. Doing it this way creates fast and smooth frame shifts.

With your method, blitting straight from offscreen surfaces to the primary is not so good. The frame shifts are much slower.

When surface->Blt() is called, ddraw automatically waits for a vertical blank. I think so anyway...correct me anyone?

Hope I helped,
Martin

Share this post


Link to post
Share on other sites
quote:
Original post by Rah
Yeah I thought about that, but just thought it seemed a little inefficient (the final flip seems redundant as it could of been blitted directly from the sysmem surface to the primary surface.

I basically just wanted to know if a blit from an offscreen surface (equal size) will result in ''flicker'' effects? Does DDraw automatically wait for the vsync before a blit to the primary, or would waiting for the vertical blank be advised?

Thanks,
Russ


You cannot write to a surface and display it at the same time without flicker, so you cannot just blt all gfx to the primary buffer.

BTW, the surface->Flip() command is faster than anything you can imagine because all it does is switch pointers. In the final parameter for Flip() you can specify a flag (DDFLIP_WAITVSYNC I think) to make sure that the surfaces are only switched when it''s synced so you do not get tear.

You were right in your initial concern for blting directly to the primary, and that it would give you flicker.

As a general rule, if you are in fullscreen mode (just do an if test after rendering all to a back buffer) call Flip(), but if you aren''t, then just lpddsprimary->Blt(backsurface).

Hope this helps.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!