SGE Documentation - Blib

# SGE Blib

- sge_FadedLine
- sge_TexturedLine
- sge_Trigon
- sge_FilledTrigon
- sge_FadedTrigon
- sge_TexturedTrigon
- sge_TexturedRect
- sge_FilledPolygon
- sge_FadedPolygon

Important!

- The clipping rectangle set by SDL_SetClipRect() will always be respected.
- These functions will lock the surface if necessary, but you can control this with sge_Lock_ON/OFF().
- Functions marked as "Must be able to control surface locking" might use both SW (needs locked surfaces) and HW (SDL_FillRect() - needs unlocked surfaces) access to the surface if a HW surface is used, so don't toy with sge_Lock_ON/OFF() or SDL_LockSurface()!
- The destination surface will be updated if necessary, but you should really do this yourself to avoid unnecessary updates; control this with sge_Update_ON/OFF().
- Most drawing primitives can blend with the background; use the Alpha version of the routine to do this.
- A few primitives also has an anti-aliasing mode; use the AA version of the routine to get this feature.

void sge_FadedLine(SDL_Surface *dest, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r1, Uint8 g1, Uint8 b1, Uint8 r2, Uint8 g2, Uint8 b2)
Draws a horizontal line from (x1,y) to (x2,y) with its color faded from (r1,g1,b1) to (r2,g2,b2).
void sge_TexturedLine(SDL_Surface *dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface *source, Sint16 sx1, Sint16 sy1, Sint16 sx2, Sint16 sy2)
Draws a horizontal line from (x1,y) to (x2,y) on dest with the texture from the line (sx1,sy1) to (sx2,sy2) in src.
sge_Trigon

- void sge_Trigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
- void sge_Trigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B)
- void sge_TrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color, Uint8 alpha)
- void sge_TrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha)
- void sge_AATrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
- void sge_AATrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B)
- void sge_AATrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color, Uint8 alpha)
- void sge_AATrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha)

Draws a triangle.
sge_FilledTrigon

- void sge_FilledTrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
- void sge_FilledTrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B)
- void sge_FilledTrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color, Uint8 alpha)
- void sge_FilledTrigonAlpha(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha)

Draws a filled triangle. Note that if using sge_FilledTrigon() on a HW surface then the surface must be unlocked.
void sge_FadedTrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 c1, Uint32 c2, Uint32 c3)
Draws a gourand shaded triangle where c1, c2 and c3 are the colors of the three vertices.
void sge_TexturedTrigon(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, SDL_Surface *source, Sint16 sx1, Sint16 sy1, Sint16 sx2, Sint16 sy2, Sint16 sx3, Sint16 sy3)
Draws a texture mapped triangle (p1,p2,p3) on dest with the texture from the triangle (sp1,sp2,sp3) on src.
void sge_TexturedRect(SDL_Surface *dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Sint16 x4, Sint16 y4, SDL_Surface *source, Sint16 sx1, Sint16 sy1, Sint16 sx2, Sint16 sy2, Sint16 sx3, Sint16 sy3, Sint16 sx4, Sint16 sy4)
Draws a texture mapped rectangle (p1,p2,p3,p4) on dest with the texture from the rectangle (sp1,sp2,sp3,sp4) on src.
sge_FilledPolygon

- int sge_FilledPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint32 color)
- int sge_FilledPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 r, Uint8 g, Uint8 b)
- int sge_FilledPolygonAlpha(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint32 color, Uint8 alpha)
- int sge_FilledPolygonAlpha(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 r, Uint8 g, Uint8 b, Uint8 alpha)
- int sge_AAFilledPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint32 color)
- int sge_AAFilledPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 r, Uint8 g, Uint8 b)

Draws a filled polygon. Takes the arrays x[] and y[] with n elements as an argument where (x[i], y[i]) is the i:th vertex in the polygon. The last vertex, (x[n-1], y[n-1]), is automatically connected to the first, (x[0], y[0]), to close the polygon. Manages to fill most nonconvex, convex and complex polygons correctly but might be confused by extremly complex polygons, so don't push your luck. Note that sge_FilledPolygon() and sge_AAFilledPolygon() (and sge_FilledPolygonAlpha() if using opaque alpha value) must be able to control surface locking.
Returns int:
Zero - Operation finished OK.
-1 - Polygon rejected because n<3 or negative coords in arrays (the polygon might be halfdrawn).
-2 - Unable to lock surface.
sge_FadedPolygon

- int sge_FadedPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 *R, Uint8 *G, Uint8 *B)
- int sge_FadedPolygonAlpha(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 *R, Uint8 *G, Uint8 *B, Uint8 alpha)
- int sge_AAFadedPolygon(SDL_Surface *dest, Uint16 n, Sint16 *x, Sint16 *y, Uint8 *R, Uint8 *G, Uint8 *B)

As sge_FilledPolygon() but draws a gourand shaded polygon where (R[i], G[i], B[i]) is the color of the i:th vertex. Note that the shading is done on each y-line so some care is needed with the RGB values when working with complex polygons.

Copyright © 1999-2003 Anders Lindström
Last updated 030806