Surface distortion?

I would like to distort an SDL Surface. Specifically I would like to do a
perspective projection distortion to the surface in order to make it appear as
if it is being viewed from an angle. Any ideas on how I could most easliy
accomplish this?
Thanks.

hey randy, i don’t know if this helps but…

to convert from a 3d point (lets say X1,Y1,Z1) to a 2d point (lets say
X2,Y2) so that you can display it on a 2d surface, you use the following
equations:

X2 = X1/Z1 * C
Y2 = Y1/Z1 * C

where C is some constant, you can play around with different values of C to
get what you are looking for.

You might be able to assign the 4 corners of the rectangle of your surface
3d points and then do your angle rotation on the rectangle to get the
"viewing angle", and then for each pixel on the surface run the above
equation and plot onto the screen (or some other surface) based on that.

running the above for each and every pixel on a surface would be super slow
for even small surfaces but you should be able to optomize it to give it the
effect you want through something like interpolation.

you might also look into using OpenGL if it can solve your problem. I use
OpenGL/SDL in a 2d side scroller i’m making and it works very nicely and is
super fast - and rotations (as well as skewing, transparency and color
tinting) are virtualy free as far as CPU is concerned (:

if this doesnt help or you need more info, paste some details and maybe
there’s a better solution to this problem> ----- Original Message -----

From: randy@randyedmonds.com (randy)
To:
Sent: Monday, June 20, 2005 12:28 PM
Subject: [SDL] Surface distortion ?

I would like to distort an SDL Surface. Specifically I would like to do a
perspective projection distortion to the surface in order to make it
appear as
if it is being viewed from an angle. Any ideas on how I could most easliy
accomplish this?
Thanks.


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

On Monday 20 June 2005 15:35, Alan Wolfe set 1,000 monkies in front of
keyboards and came up with the following:

you might also look into using OpenGL if it can solve your problem. I use
OpenGL/SDL in a 2d side scroller i’m making and it works very nicely and is
super fast - and rotations (as well as skewing, transparency and color
tinting) are virtualy free as far as CPU is concerned (:

I'll second that.....setting up a 2D orthographic matrix is pretty simple, 

and doing “sprites” is merely a matter of drawing a quad and throwing a
texture onto it. I even incorporated it with some 2D code I did in Pygame so
that on startup, I look at the actual sprite object and its image size, and
automatically create a quad with properly scaled dimensions so that it takes
up the same screen space as the raw image would as a sprite.
But actually, I’ve since ditched the 2D idea althogether and am doing my game
totally in 3D. It’s a Raptor-like top-down vertical shooter…now all the
buildings and the ship and stuff are in 3D. :slight_smile: It looks pretty cool.

-Matt Bailey

I would like to distort an SDL Surface. Specifically I would like to do a
perspective projection distortion to the surface in order to make it appear as
if it is being viewed from an angle. Any ideas on how I could most easliy
accomplish this?

Use OpenGL…that would definitely be the simplest (and most optimized)
way to do it, if you can get away with it.

–ryan.

    But actually, I've since ditched the 2D idea althogether and am doing my game

totally in 3D. It’s a Raptor-like top-down vertical shooter…now all the
buildings and the ship and stuff are in 3D. :slight_smile: It looks pretty cool.

What are you using for the 3D? I've been looking for a good light-weight 3D library (like what SDL is to 2D). All I can find are huge bloated systems like CrystalSpace.

TankkoOn 6/20/05, Matt Bailey wrote:

On Monday 20 June 2005 15:35, Alan Wolfe set 1,000 monkies in front of
keyboards and came up with the following:

you might also look into using OpenGL if it can solve your problem. I use
OpenGL/SDL in a 2d side scroller i’m making and it works very nicely and is
super fast - and rotations (as well as skewing, transparency and color
tinting) are virtualy free as far as CPU is concerned (:

    I'll second that.....setting up a 2D orthographic matrix is pretty simple,

and doing “sprites” is merely a matter of drawing a quad and throwing a
texture onto it. I even incorporated it with some 2D code I did in Pygame so
that on startup, I look at the actual sprite object and its image size, and
automatically create a quad with properly scaled dimensions so that it takes
up the same screen space as the raw image would as a sprite.
But actually, I’ve since ditched the 2D idea althogether and am doing my game
totally in 3D. It’s a Raptor-like top-down vertical shooter…now all the
buildings and the ship and stuff are in 3D. :slight_smile: It looks pretty cool.

    -Matt Bailey

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

On Tuesday 21 June 2005 20:41, Tankko Omaskio set 1,000 monkies in front of
keyboards and came up with the following:

    But actually, I've since ditched the 2D idea althogether and am

doing my game totally in 3D. It’s a Raptor-like top-down vertical
shooter…now all the buildings and the ship and stuff are in 3D. :slight_smile: It
looks pretty cool.

What are you using for the 3D? I've been looking for a good light-weight 3D library (like what SDL is to 2D). All I can find are huge bloated systems like CrystalSpace.
Erm, so far I'm more or less doing everything myself in OpenGL. I am in 

Python, using PyOpenGL, but this is pretty much just OpenGL in Python, not a
whole extra 3D library/engine. I started my game in Pygame/SDL, and am still
keeping Pygame around for the underlying game logic (for now I’m actually
getting OpenGL matrix translation values from the XY coords of my old Pygame
sprites), and also for sounds (for now), though at this point I don’t really
need Pygame as much. I’ll still more than likely keep it around
though…the rects are handy, and if nothing else I’ll keep Pygame for
its input handling (and, to a lesser extent, its OpenGL context).

-Matt Bailey
What are you using for the 3D? I've been looking for a good light-weight 3D library (like what SDL is to 2D). All I can find are huge bloated systems like CrystalSpace.

Some people like Ogre a lot:

http://www.ogre3d.org/

–ryan.

What are you using for the 3D? I've been looking for a good light-weight 3D library (like what SDL is to 2D). All I can find are huge bloated systems like CrystalSpace.

Some people like Ogre a lot:

http://www.ogre3d.org/

–ryan.

Ogre is a great libray, I have tried it out personally its pretty easy
to use and the tutorials are great.

However seriously SDL is mostly an abstraction library. The best
parallel for SDL in the 3D world would be opengl itself.On Wed, 2005-06-22 at 02:15 -0400, Ryan C. Gordon wrote:


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

!DSPAM:42b90df162812067615291!


Matt Pruett <@Matt_Pruett>