Re: [xmoto-dev] SDL_gfx help

[ Thread Index | Date Index | More lists.tuxfamily.org/xmoto-dev Archives ]


Hello Rasmus

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

greetings

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
rotations, etc.

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.

--
Rasmus Neckelmann






Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/