|Re: [xmoto-dev] SDL_gfx help|
[ Thread Index |
| More lists.tuxfamily.org/xmoto-dev Archives
- To: xmoto-dev@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [xmoto-dev] SDL_gfx help
- From: "Kees Jongenburger" <kees.jongenburger@xxxxxxxxx>
- Date: Thu, 25 Jan 2007 11:25:44 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=I0TeuIyVjnfJg+yeEI3YpVB81QGb8XeExMHnsikwDQWLyO0VhJvxXM8iCIwe8L7ywh5AgoyJmf4BYCf019uvVhJCiEfsXSZnjZLRRejUWBhCL0qDxVKqx0JZAVoOVMKwt7sfK9xDvz3VWvlsiGmjb317rIZqgDBNj3/5W4cuGQk=
Thanks a lot I will look into it!!
On 1/25/07, Rasmus Neckelmann <neckelmann@xxxxxxxxx> wrote:
On 1/25/07, Kees Jongenburger <kees.jongenburger@xxxxxxxxx> wrote:
> > transformations or anything. I don't know about SDL_gfx, but making
> > such a drawing function should be quite basic - interpolate the x
> > (screen) coordinate and the u,v (texture) coordinates over the edges
> > of the polygon, and then render the horizontal lines of the polygon
> > (with interpolated u,v coordinates). Nice thing about x-moto is that
> > no perspective correction or shading is required - i.e. it can be
> > implemented quite efficiently in plain c/c++ (even with no asm).
> This will not work when the object is rotated like the wheels
> and the width/height ration of the body is changed. or am I missing something?
The usual way to draw textured polygons, at least when talking
(modern) 3d, is to seperate transformation and texturing:
1. Polygons are first transformed according to how the scene is set up
- i.e. they are moved as specified by the camera and individual
2. Then they are projected unto the screen. I.e. converted to 2d.
3. The actual drawing (rasterization) of the polygons. At this point
all transformations are totally forgotten, the polygons are reduced to
simply being a list of 2d vertices (each both containing x,y on the
screen and u,v on the texture). These polygons can be of any shape,
rotated, stretched, scaled, etc.
I've cleaned up some old code of mine which draws textured polygons.
Unfortunately not as fast as I remembered, it will probably require
major optimizations to be of any use :)
Haven't tried the code on anything but windows. Needs SDL.
Note: it probably needs some tweaking of <= and <'s to handle adjecant
polygons probably. Have never been tested for that.