Mirroring a surface

Hi everyone

Is there a fast methode to mirror a SDL_Surface ?
I need something like that for an project, i have all animations rendered
for one side and need to build the other side by mirroring the left one…
I could do this “by hand” but then i would have a big waste of memory
since each image is present two times in memory, then…

thanks in advance
Johannes

Hi Johannes,

well, there is no magic way to mirror surfaces unfortunately. You have 2
options as far as i see it.

Option 1:
use up some CPU every time you want to display the reversed picture by
flipping the pixels in the surface itself. If you are short on CPU like
most games are, this isnt a good option IMHO.

Option 2:
use up some extra RAM by making a mirrored copy of the art when your game
starts up. Whenever you want to display the flipped art, just draw the
flipped version at no extra load to the CPU.

i would choose option 2 personaly, but its up to you :P> ----- Original Message -----

From: cowhead@g m x.net (Johannes W.)
To:
Sent: Tuesday, March 25, 2003 12:17 PM
Subject: [SDL] Mirroring a surface

Hi everyone

Is there a fast methode to mirror a SDL_Surface ?
I need something like that for an project, i have all animations
rendered
for one side and need to build the other side by mirroring the left
one…
I could do this “by hand” but then i would have a big waste of memory
since each image is present two times in memory, then…

thanks in advance
Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks :wink:

Then i will probably use option 2 since the animations are used quite often
and often also more than once per frame…
I just thought that there could be a simple blitting mode or something you
had to use… but it seems bnot to be the case

  Johannes

“Atrix Wolfe” schrieb im Newsbeitrag
news:104d01c2f30e$201bf4f0$6501a8c0 at atrix…> Hi Johannes,

well, there is no magic way to mirror surfaces unfortunately. You have 2
options as far as i see it.

Option 1:
use up some CPU every time you want to display the reversed picture by
flipping the pixels in the surface itself. If you are short on CPU like
most games are, this isnt a good option IMHO.

Option 2:
use up some extra RAM by making a mirrored copy of the art when your game
starts up. Whenever you want to display the flipped art, just draw the
flipped version at no extra load to the CPU.

i would choose option 2 personaly, but its up to you :stuck_out_tongue:

----- Original Message -----
From: “Johannes W.”
To:
Sent: Tuesday, March 25, 2003 12:17 PM
Subject: [SDL] Mirroring a surface

Hi everyone

Is there a fast methode to mirror a SDL_Surface ?
I need something like that for an project, i have all animations
rendered
for one side and need to build the other side by mirroring the left
one…
I could do this “by hand” but then i would have a big waste of memory
since each image is present two times in memory, then…

thanks in advance
Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

At the cost of some performance hits, you can SDL_BlitSurface vertical lines
in reverse order to accomplish the mirroring without storing the image in
memory twice.On Tuesday 25 March 2003 02:17 pm, Johannes W. wrote:

Hi everyone

Is there a fast methode to mirror a SDL_Surface ?
I need something like that for an project, i have all animations rendered
for one side and need to build the other side by mirroring the left one…
I could do this “by hand” but then i would have a big waste of memory
since each image is present two times in memory, then…

thanks in advance
Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Tyler Montbriand writes:

At the cost of some performance hits, you can SDL_BlitSurface vertical lines
in reverse order to accomplish the mirroring without storing the image in
memory twice.

‘blit’ is a word that stands for copy (rather from the historic asm
command ‘BLT’ which stands for BLockTransfer). So indeed
SDL_BlitSurface is copying one surface on to another. and in this
case, copying regions of the surface multiple times. I have a question
here, if SDL_HWSURFACE is used, will SDL leave the blitting work to
hardware instead of it doing it by itself? If this is true, i think
there will be a significant improvement in performance.

-Suraj–
±-------------------------------------------<@Suraj_Kumar>—+
| It is not so much the armor that sustains success |
| of a ruler, as righteous and just governance |
| (good governance - 6), Thirukkural |
±–http://symonds.net/~suraj/-----------------------------------+

SDL can use hardware-accelerated colorkey blits, when available.On Tuesday 25 March 2003 11:35 pm, Suraj Kumar wrote:

Tyler Montbriand writes:

At the cost of some performance hits, you can SDL_BlitSurface vertical
lines in reverse order to accomplish the mirroring without storing the
image in memory twice.

‘blit’ is a word that stands for copy (rather from the historic asm
command ‘BLT’ which stands for BLockTransfer). So indeed
SDL_BlitSurface is copying one surface on to another. and in this
case, copying regions of the surface multiple times. I have a question
here, if SDL_HWSURFACE is used, will SDL leave the blitting work to
hardware instead of it doing it by itself? If this is true, i think
there will be a significant improvement in performance.

-Suraj

Hi Johannes,

well, there is no magic way to mirror surfaces unfortunately. You have 2
options as far as i see it.

Option 1:
use up some CPU every time you want to display the reversed picture by
flipping the pixels in the surface itself. If you are short on CPU like
most games are, this isnt a good option IMHO.

Option 2:
use up some extra RAM by making a mirrored copy of the art when your game
starts up. Whenever you want to display the flipped art, just draw the
flipped version at no extra load to the CPU.

Option 3:
Write a blit that mirrors the image as it copies it.

	Bob PendletonOn Tue, 2003-03-25 at 14:35, Atrix Wolfe wrote:

i would choose option 2 personaly, but its up to you :stuck_out_tongue:

----- Original Message -----
From: “Johannes W.”
To:
Sent: Tuesday, March 25, 2003 12:17 PM
Subject: [SDL] Mirroring a surface

Hi everyone

Is there a fast methode to mirror a SDL_Surface ?
I need something like that for an project, i have all animations
rendered
for one side and need to build the other side by mirroring the left
one…
I could do this “by hand” but then i would have a big waste of memory
since each image is present two times in memory, then…

thanks in advance
Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±----------------------------------+

  • Bob Pendleton: independent writer +
  • and programmer. +
  • email: Bob at Pendleton.com +
    ±----------------------------------+

i agree with bob. a little wasted ram isnt as bad as wasting cpu cycles,
unless you have a whooooole lot of surfaces you’re going to need to be
flipped around.

or option 4: combination of 1 and 2
for images that are flipped that need to be drawn regularly, waste the ram,
but for images that you’ll only display a few times, save the ram and waste
a little cpu time (i’d only recommend this if the images are only going to
be there for a few frames, or if they appear in a menu or something)

M@_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail