|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 16:48:21 +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=r+OJ6xVg+S4gNtQgE/mlRwagjb9S38S6C1ss6vATuMwfh22S9yXux1h7DuGAcZxzgb74jNSGvyMPIooOMwJp1SLHI/5Bijv1jCC9GbDtpTuRcK6scuM4whx3ZvXJrPrf55l0xu2dH3jwAZyrQwv4oe6aGck/8Syz9CrCFlgzrfo=
your code is many times better then what I did.
I have included the PolyDraw code into xmoto
and adapted the rendering.
not everything is rendered correctly but it is a way better start then
what I did
I will need to ad alpha handling. and perhaps add an improved version
for square rendering.
The speed varies with the rendered size.but it is adequate om my machine
I hope to have a little more time this week-end
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.