Update vs flip

Hello.

I am very new to SDL and this is my first post to this list, so pardon
me if this question is silly or, otherwise, common knowledge among
this community.

I have a limited experience with DirectX, having done some simple
explorarions with DirectDraw. The basic procedure I would follow to
"draw" was:

  1. initialize DirectDraw;
  2. set the video mode;
  3. create the the primary surface (the video’s frame buffer);
  4. and get an “attached surface” from the primary surface
    (the back buffer)

The “attached surface” would have the same characteristics as the
primary one (same dimensions, same color depth, etc.). From that point
on, the back buffer would be the target of the blits to compose a
scene and it would be swapped with the primary surface at each [game]
loop.

It would be possible, as well, not to have made use of a back buffer
at all. One could lock the primary surface and write to it directly.
However, one would always be advised to go for the flipping approach,
to get rid of flickering, tearing and other annoying side-effects.

For what I have been able to see in SDL, so far, it appears it also
offers both possibilities. For my first application, I am simply
drawing to the screen surface (primary surface) and then calling
update to force the region to be repainted. I would think that using
flipping would be a better choice, specially when the scenes become
more complex. Is that so?

Another question: I have noticed that, with SDL, there is no need to
control the repainting of the client area’s contents, i.e. after you
write something on the screen, it seems as though SDL takes care of
restoring the images for you, either when you put some other window on
top of yours or move the application window out of the desktop. And
this happens without having the drawing code inside the loop, i.e. it
runs only once. Is this right or could I be overlooking something in
my own code?

Thank you very much for your attention and clarifications,

Ney Andr? de Mello Zunino.

“Take of the fruit,
But guard the seed…”

[…DX single/double buffer setups…]

For what I have been able to see in SDL, so far, it appears it also
offers both possibilities. For my first application, I am simply
drawing to the screen surface (primary surface) and then calling
update to force the region to be repainted. I would think that using
flipping would be a better choice, specially when the scenes become
more complex. Is that so?

In short; yes.

Another question: I have noticed that, with SDL, there is no need to
control the repainting of the client area’s contents, i.e. after you
write something on the screen, it seems as though SDL takes care of
restoring the images for you, either when you put some other window on
top of yours or move the application window out of the desktop. And
this happens without having the drawing code inside the loop, i.e. it
runs only once. Is this right or could I be overlooking something in
my own code?

Well… When using DirectX, you should alway count on surfaces being lost
occasionally, as Windows may decide it needs the WRAM they occupy.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Monday 08 October 2001 07:35, Ney Andr? de Mello Zunino wrote:

The fact that it does not do this transparently demonstrates some
stupidity on the part of the API designers. You should never have to
worry about such details IMO.On Tue, Oct 09, 2001 at 07:53:57PM +0200, David Olofson wrote:

Well… When using DirectX, you should alway count on surfaces being lost
occasionally, as Windows may decide it needs the WRAM they occupy.


Joseph Carter Free software developer

That reminds me, we’ll need to buy a chainsaw for the office. “In
case of emergency, break glass”

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20011009/69f3ca83/attachment.pgp

Yeah, they should have make DirectX transparently copy data back and
forth between VRAM and system memory (or swap) as needed - that’s both
doable, and would have been a lot nicer. (99% of the applications will
have to do something very similar anyway…)

But hey, we’re talking about an OS that idles with everything that hasn’t
be used for a while in the swap! Considering that, one would expect the
"fastest possible memory allocation at any cost" design rule to apply to
DirectX as well, which explains why DirectX can’t be arsed to allocate
some space and back surfaces up when it needs VRAM.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 10 October 2001 06:30, Joseph Carter wrote:

On Tue, Oct 09, 2001 at 07:53:57PM +0200, David Olofson wrote:

Well… When using DirectX, you should alway count on surfaces being
lost occasionally, as Windows may decide it needs the WRAM they
occupy.

The fact that it does not do this transparently demonstrates some
stupidity on the part of the API designers. You should never have to
worry about such details IMO.