[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Lutz Sammer wrote:
> Steve Baker wrote:
> > [CUT]
> >
> > * To display 2D sprites in a game, you could write your own
> >   code to talk to libsvga or Xlib - but for a beginner, you'll
> >   want to start with a library of convenient sprite rendering
> >   routines.  Perhaps you should learn Clanlib or one of the
> >   other packages that do these things well.
> A question I have to this part is: How to use a 3D engine todo
> the 2D stuff. Scaling, rotating and transparent effects shouldn't
> be a problem for a 3D engine.

OH!  I see!

Easy - stuff the sprite into a texture map - and draw a textured
quadrilateral to draw the sprite.

Rotating, translating, scaling the polygon (which is EASY) causes
the sprite to do the same thing.

Alpha-blended textures deal with the transparency.

To *animate* a sprite is a little harder.  You can either define
one texture for each step of the animation and switch textures
from frame to frame - or you can pack all of the animation steps
up into one big texture map and change the texture coordinates
on the polygon to select which sub-image you need.

Assuming you have hardware 3D accelleration, an OpenGL (Mesa)
'sprite' engine can be spectacularly fast with arbitary angle
rotation effects and scaling costing *nothing*.

You should also be able to have larger sprites than with
a software-only sprite engine because the 3D hardware can
push polygons MUCH faster than the main CPU - even with
translucent blending and such like.

Steve Baker                (817)619-2657 (Vox/Vox-Mail)
Raytheon Systems Inc.      (817)619-2466 (Fax)
Work: sjbaker@hti.com      http://www.hti.com
Home: sjbaker1@airmail.net http://web2.airmail.net/sjbaker1