SDL 1.2 or 1.3: How to do Flip Sprites Vertically/Horizontally?

Like the title, how do I do it?

Did a search, but nothing came up.

Thanks in advance.–
View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28425824.html
Sent from the SDL mailing list archive at Nabble.com.

You can’t. For that we’d need a rotation API, with the ability to manipulate vertices as they’re being drawn. We don’t have one yet.>From: delete12345 <tom_mai78101 at yahoo.com.tw>

Subject: [SDL] SDL 1.2 or 1.3: How to do Flip Sprites Vertically/Horizontally?

Like the title, how do I do it?

Did a search, but nothing came up.

Thanks in advance.

Using Sprig (in SDL 1.2), this creates a new surface, vertically flipped:
SPG_Scale(mysurface, 1, -1);

SDL_gfx has a similar function in its rotozoom interface.

Jonny DOn Sun, May 2, 2010 at 5:37 AM, Mason Wheeler wrote:

You can’t. For that we’d need a rotation API, with the ability to
manipulate vertices as they’re being drawn. We don’t have one yet.

From: delete12345 <tom_mai78101 at yahoo.com.tw>
Subject: [SDL] SDL 1.2 or 1.3: How to do Flip Sprites
Vertically/Horizontally?

Like the title, how do I do it?

Did a search, but nothing came up.

Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for providing a lead. :slight_smile:

Jonathan Dearborn-2 wrote:>

Using Sprig (in SDL 1.2), this creates a new surface, vertically flipped:
SPG_Scale(mysurface, 1, -1);

SDL_gfx has a similar function in its rotozoom interface.

Jonny D

On Sun, May 2, 2010 at 5:37 AM, Mason Wheeler wrote:

You can’t. For that we’d need a rotation API, with the ability to
manipulate vertices as they’re being drawn. We don’t have one yet.

From: delete12345 <@delete12345>
Subject: [SDL] SDL 1.2 or 1.3: How to do Flip Sprites
Vertically/Horizontally?

Like the title, how do I do it?

Did a search, but nothing came up.

Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28433527.html
Sent from the SDL mailing list archive at Nabble.com.

The other solution is to just blit it in strips, backwards or upside-down.
(Either to the display surface, or to a buffer, if you expect to use
the flipped- or mirrored- results often.)

e.g.:

/* src = your source surface /
/
dest = a dest surface; in this example, identical in size to src */

for (y = 0; y < src->h; y++) {
src_rect.x = 0;
src_rect.y = y;
src_rect.w = src->w;
src_rect.h = 1;

dest_rect.x = 0;
dest_rect.y = src->h - y - 1;

/* then blit */

}

/* now dest is a flipped version of src */

-bill!On Sun, May 02, 2010 at 08:45:41AM -0700, Jonathan Dearborn wrote:

Using Sprig (in SDL 1.2), this creates a new surface, vertically flipped:
SPG_Scale(mysurface, 1, -1);
SDL_gfx has a similar function in its rotozoom interface.
Jonny D

I didn’t understand it clearly.

  1. I need to use SDL_BlitSurface() and use dest_rect? Else, what is the
    src_rect for?
  2. The effects, which I have tried making it, isn’t right. Following along
    the for loop, it seemed to move away from my sprite.

Awaiting your replies. :slight_smile:

Bill Kendrick wrote:>

On Sun, May 02, 2010 at 08:45:41AM -0700, Jonathan Dearborn wrote:

Using Sprig (in SDL 1.2), this creates a new surface, vertically
flipped:
SPG_Scale(mysurface, 1, -1);
SDL_gfx has a similar function in its rotozoom interface.
Jonny D

The other solution is to just blit it in strips, backwards or upside-down.
(Either to the display surface, or to a buffer, if you expect to use
the flipped- or mirrored- results often.)

e.g.:

/* src = your source surface /
/
dest = a dest surface; in this example, identical in size to src */

for (y = 0; y < src->h; y++) {
src_rect.x = 0;
src_rect.y = y;
src_rect.w = src->w;
src_rect.h = 1;

dest_rect.x = 0;
dest_rect.y = src->h - y - 1;

/* then blit */

}

/* now dest is a flipped version of src */

-bill!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28444819.html
Sent from the SDL mailing list archive at Nabble.com.

I didn’t understand it clearly.

  1. I need to use SDL_BlitSurface() and use dest_rect? Else, what is the
    src_rect for?

To take the appropriate slice of the source. In my example,
it takes the 1st row of the source, and blits it on the last row of the
destination. Then it takes the 2nd row of the source, and blits it on the
2nd-to-last row of the destination. And so forth, until it takes the last
(bottom-most) row of the source, and blits it on the 1st (top-most) row
of the destination. And there, you have the destination filled with an
upside-down rendering of the source surface.

  1. The effects, which I have tried making it, isn’t right. Following along
    the for loop, it seemed to move away from my sprite.

I have no idea what that means, sorry. :slight_smile:

-bill!On Tue, May 04, 2010 at 02:01:33AM -0700, delete12345 wrote:

  1. It means my sprite art wouldn’t show up, and instead, by reading the code
    in the debugger, it tends to move the blitting offset away from the target
    destination.

Bill Kendrick wrote:>

I have no idea what that means, sorry. :slight_smile:


View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28460750.html
Sent from the SDL mailing list archive at Nabble.com.

Did you check the documentation of sdlgfx?

Cheers

In data mercoled? 05 maggio 2010 15:20:36, delete12345 ha scritto:
: > 2. It means my sprite art wouldn’t show up, and instead, by reading the> code in the debugger, it tends to move the blitting offset away from the

target destination.

Bill Kendrick wrote:

I have no idea what that means, sorry. :slight_smile:


Fabio Giovagnini

Aurion s.r.l.
P.I e C.F.
00885711200
Tel. +39.051.594.78.24
Cell. +39.335.83.50.919

Yes, you can use SDL_gfx:

SDL_SurfacezoomSurface(SDL_Surface src, double zoomx, double zoomy, int smooth)

When zoomx and/or zoomy are negative the image is flipped on the
vertical and/or horizontal respectively.

–AndreasOn 5/5/10 7:21 AM, Fabio Giovagnini wrote:

Did you check the documentation of sdlgfx?

Cheers

In data mercoled? 05 maggio 2010 15:20:36, delete12345 ha scritto:
:> 2. It means my sprite art wouldn’t show up, and instead, by reading the

code in the debugger, it tends to move the blitting offset away from the
target destination.

Bill Kendrick wrote:

I have no idea what that means, sorry. :slight_smile:

I’m not sure if SDL and/or other libraries can be compiled under Visual
Studio 2010. I’ve been searching around Google for some time, but there’s no
answers. :frowning:

Andreas Schiffler-2 wrote:>

Yes, you can use SDL_gfx:

SDL_SurfacezoomSurface(SDL_Surface src, double zoomx, double zoomy,
int smooth)

When zoomx and/or zoomy are negative the image is flipped on the
vertical and/or horizontal respectively.

–Andreas


View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28511818.html
Sent from the SDL mailing list archive at Nabble.com.

What problems are you having? Are you using the VisualC project in the
source distribution?

Jonny DOn Mon, May 10, 2010 at 6:55 AM, delete12345 <tom_mai78101 at yahoo.com.tw>wrote:

I’m not sure if SDL_gfx can be compiled under Visual Studio 2010. I’ve been
searching around Google for some time, but there’s no answers. :frowning:

Andreas Schiffler-2 wrote:

Yes, you can use SDL_gfx:

SDL_SurfacezoomSurface(SDL_Surface src, double zoomx, double
zoomy,
int smooth)

When zoomx and/or zoomy are negative the image is flipped on the
vertical and/or horizontal respectively.

–Andreas


View this message in context:
http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28511818.html
Sent from the SDL mailing list archive at Nabble.com.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

When Google can’t find it, email them. :wink:

Get the latest development version via svn/TortoiseSvn here:
http://sourceforge.net/projects/sdlgfx/develop
Sources contain a working VS solution/project.

–AndreasOn 5/10/10 6:55 AM, delete12345 wrote:

I’m not sure if SDL_gfx can be compiled under Visual Studio 2010. I’ve been
searching around Google for some time, but there’s no answers. :frowning:

Andreas Schiffler-2 wrote:

Yes, you can use SDL_gfx:

SDL_SurfacezoomSurface(SDL_Surface src, double zoomx, double zoomy,
int smooth)

When zoomx and/or zoomy are negative the image is flipped on the
vertical and/or horizontal respectively.

–Andreas

When Google can’t find it, email them. :wink:

Get the latest development version via svn/TortoiseSvn here:
http://sourceforge.net/projects/sdlgfx/develop
Sources contain a working VS solution/project.

–AndreasOn 5/10/10 6:55 AM, delete12345 wrote:

I’m not sure if SDL_gfx can be compiled under Visual Studio 2010. I’ve been
searching around Google for some time, but there’s no answers. :frowning:

Andreas Schiffler-2 wrote:

Yes, you can use SDL_gfx:

SDL_SurfacezoomSurface(SDL_Surface src, double zoomx, double zoomy,
int smooth)

When zoomx and/or zoomy are negative the image is flipped on the
vertical and/or horizontal respectively.

–Andreas

It’s been 9 days since I had checked on this place. I was having midterm
exams, so I hoped this does not count as a bump or any sort.

Anyway, the problem I’m having is “Converting the Visual C projects to
Visual Studio 2010 (Version 10.0) C Projects”.

And what “vcproj” file should I use for minimal errors/warnings? And when
will SDL have VS 2010 compatible project files and subversions? (If worded
correctly…)

Awaiting replies sincerely.

Jonathan Dearborn-2 wrote:>

What problems are you having? Are you using the VisualC project in the
source distribution?

Jonny D


View this message in context: http://old.nabble.com/SDL-1.2-or-1.3%3A-How-to-do-Flip-Sprites-Vertically-Horizontally--tp28425824p28598152.html
Sent from the SDL mailing list archive at Nabble.com.