DDraw primary/secondary surfaces question

Started by
4 comments, last by Rah 24 years ago
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
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
--------> http://www.larswolter.de <---------
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
______________Martin EstevaolpSoftware
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
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
______________Martin EstevaolpSoftware
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.
___________________________Freeware development:ruinedsoft.com

This topic is closed to new replies.

Advertisement