SDLGameEngine

SgeGFX

Low level graphics and drawing functions. More...

Data Structures

struct  SGEPIXELINFO
struct  SGEPOSITION

Defines

#define sgeClearScreen()   SDL_FillRect(screen, NULL, 0)
 clear the whole screen to black
#define sgeConvertToGray   sgeConvertToGrey
 a alias for sgeConvertToGrey

Functions

SGEPOSITIONsgePositionNew (int x, int y)
 create a new SGEPOSITION
void sgePositionDestroy (SGEPOSITION *p)
 destroy a SGEPOSITION and free resources
SGEPIXELINFOsgePixelInfoNew (Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 create a new SGEPIXELINFO
void sgePixelInfoDestroy (SGEPIXELINFO *i)
 destroy a SGEPIXELINFO and free resources
Uint32 sgeMakeColor (SDL_Surface *surface, int r, int g, int b, int a)
 create a new hardware dependant color
void sgeFillRect (SDL_Surface *dest, int x, int y, int w, int h, Uint32 color)
 draw a filled rectangle
void sgeDrawRect (SDL_Surface *dest, int x, int y, int w, int h, int linewidth, Uint32 color)
 draw the outlines of a rectangle
void sgeDrawPixel (SDL_Surface *dest, int x, int y, Uint32 color)
 draw a pixel
SGEPIXELINFOsgeGetPixel (SDL_Surface *dest, int x, int y)
 get the color of a pixel
void sgeDrawLine (SDL_Surface *dest, int x, int y, int x2, int y2, Uint32 color)
 draw a line
void sgeDrawImage (SDL_Surface *dest, SDL_Surface *image, int x, int y)
 draw a image
void sgeIgnoreAlpha (SDL_Surface *s)
 disable alpha blending on a SDL_Surface
void sgeUseAlpha (SDL_Surface *s)
 enable alpha blending on a SDL_Surface
SDL_Surface * sgeRotoZoom (SDL_Surface *source, float rotation, float zoom)
 creates a new SDL_Surface from a source which displays a rotated and zoomed copy of source
SDL_Surface * sgeChangeSDLSurfaceAlpha (SDL_Surface *s, Uint8 alpha)
 copies a SDL_Surface and returns a new SDL_Surface with new overall alpha values
SDL_Surface * sgeCreateSDLSurface (int width, int height, int depth, Uint32 sdlflags)
 create a new SDL_Surface into application RAM
SDL_Surface * sgeCreateVideoSurface (int width, int height, int depth, Uint32 sdlflags)
 create a new accelerated SDL_Surface into video RAM (if possible)
SDL_Surface * sgeConvertToGrey (SDL_Surface *src)
 return a new SDL_Surface holding a grey version of another SDL_Surface

Variables

Uint8 SGEPIXELINFO::g
 the green value of the pixel (0-255)
Uint8 SGEPIXELINFO::b
 the blue value of the pixel (0-255)
Uint8 SGEPIXELINFO::a
 the alpha value of the pixel (0-255)
int SGEPOSITION::y
 the y position in pixels

Detailed Description

Low level graphics and drawing functions.


Define Documentation

#define sgeConvertToGray   sgeConvertToGrey

a alias for sgeConvertToGrey

sgeConvertToGray

Definition at line 243 of file sgegfx.h.


Function Documentation

SDL_Surface* sgeChangeSDLSurfaceAlpha ( SDL_Surface *  s,
Uint8  alpha 
)

copies a SDL_Surface and returns a new SDL_Surface with new overall alpha values

Parameters:
sa pointer to a SDL_Surface
alphathe new alpha of the target (0-255)
Returns:
a pointer to a new SDL_Surface

Definition at line 311 of file sgegfx.c.

SDL_Surface* sgeConvertToGrey ( SDL_Surface *  src)

return a new SDL_Surface holding a grey version of another SDL_Surface

Parameters:
srcthe SDL_Surface to convert to grey scale
Returns:
a pointer to a new SDL_Surface

Definition at line 369 of file sgegfx.c.

SDL_Surface* sgeCreateSDLSurface ( int  width,
int  height,
int  depth,
Uint32  sdlflags 
)

create a new SDL_Surface into application RAM

Parameters:
widththe width of the new surface
heightthe height of the new surface
depththe bit depth of the new surface
sdlflagsthe sdl flags of the new surface, or 0 for default flags

Definition at line 329 of file sgegfx.c.

SDL_Surface* sgeCreateVideoSurface ( int  width,
int  height,
int  depth,
Uint32  sdlflags 
)

create a new accelerated SDL_Surface into video RAM (if possible)

Parameters:
widththe width of the new surface
heightthe height of the new surface
depththe bit depth of the new surface
sdlflagsthe sdl flags of the new surface, or 0 for default flags

Will return a standard SDL_Surface if not enough video ram is free

Definition at line 356 of file sgegfx.c.

void sgeDrawImage ( SDL_Surface *  dest,
SDL_Surface *  image,
int  x,
int  y 
) [inline]

draw a image

Parameters:
destthe destination surface
imagethe actual image to draw onto dest
xthe x position on dest to draw to
ythe y position on dest to draw to

example:

Draw a image on the upper left position on the screen

 sgeDrawImage(screen, myImage, 0, 0); 

Definition at line 168 of file sgegfx.c.

void sgeDrawLine ( SDL_Surface *  dest,
int  x,
int  y,
int  x2,
int  y2,
Uint32  color 
) [inline]

draw a line

Parameters:
destthe destination surface
xthe starting x coordinate of the line
ythe starting y coordinate of the line
x2the ending x coordinate of the line
y2the ending y coordinate of the line
colorthe color of the rectangle (see sgeMakeColor)

Definition at line 117 of file sgegfx.c.

void sgeDrawPixel ( SDL_Surface *  dest,
int  x,
int  y,
Uint32  color 
) [inline]

draw a pixel

Parameters:
destthe destination surface
xthe x coordinate of the pixel
ythe y coordinate of the pixel
colorthe color of the rectangle (see sgeMakeColor)

Definition at line 66 of file sgegfx.c.

void sgeDrawRect ( SDL_Surface *  dest,
int  x,
int  y,
int  w,
int  h,
int  linewidth,
Uint32  color 
) [inline]

draw the outlines of a rectangle

Parameters:
destthe destination surface
xthe x coordinate of upper left corner of the rectangle
ythe y coordinate of upper left corner of the rectangle
wthe width of the rectangle
hthe height of the rectangle
linewidththe line width in pixels of the outline
colorthe color of the rectangle (see sgeMakeColor)

example:

Draw a white rectangle with a border with of 4 pixels on the screen

sgeDrawRect(screen, 20, 10, 200, 100, 4, sgeMakeColor(screen, 255, 255, 255, 255));

Definition at line 59 of file sgegfx.c.

void sgeFillRect ( SDL_Surface *  dest,
int  x,
int  y,
int  w,
int  h,
Uint32  color 
) [inline]

draw a filled rectangle

Parameters:
destthe destination surface
xthe x coordinate of upper left corner of the rectangle
ythe y coordinate of upper left corner of the rectangle
wthe width of the rectangle
hthe height of the rectangle
colorthe color of the rectangle (see sgeMakeColor)

Definition at line 50 of file sgegfx.c.

SGEPIXELINFO* sgeGetPixel ( SDL_Surface *  dest,
int  x,
int  y 
) [inline]

get the color of a pixel

Parameters:
destthe SDL_Surface to read the pixel from
xthe x coordinate of the pixel
ythe y coordinate of the pixel
Returns:
the pixel information as SGEPIXELINFO

Definition at line 90 of file sgegfx.c.

void sgeIgnoreAlpha ( SDL_Surface *  s)

disable alpha blending on a SDL_Surface

Parameters:
sa pointer to a SDL_Surface

Definition at line 177 of file sgegfx.c.

Uint32 sgeMakeColor ( SDL_Surface *  surface,
int  r,
int  g,
int  b,
int  a 
) [inline]

create a new hardware dependant color

Parameters:
surfacethe SDL_Surface it should be created for
rthe red value of the pixel (0-255)
gthe green value of the pixel (0-255)
bthe blue value of the pixel (0-255)
athe alpha value of the pixel (0-255)

example:

Draw a red, non transparent pixel on the screen at 100/50

 sgeDrawPixel(screen, 100, 50, sgeMakeColor(screen, 255, 0, 0, 255)); 

Definition at line 40 of file sgegfx.c.

void sgePixelInfoDestroy ( SGEPIXELINFO i)

destroy a SGEPIXELINFO and free resources

Parameters:
pa pointer to a SGEPIXELINFO

Definition at line 36 of file sgegfx.c.

SGEPIXELINFO* sgePixelInfoNew ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

create a new SGEPIXELINFO

Parameters:
rthe red value of the pixel (0-255)
gthe green value of the pixel (0-255)
bthe blue value of the pixel (0-255)
athe alpha value of the pixel (0-255)
Returns:
a pointer to a SGEPIXELINFO

Definition at line 24 of file sgegfx.c.

void sgePositionDestroy ( SGEPOSITION p)

destroy a SGEPOSITION and free resources

Parameters:
pa pointer to a SGEPOSITION

Definition at line 20 of file sgegfx.c.

SGEPOSITION* sgePositionNew ( int  x,
int  y 
)

create a new SGEPOSITION

Parameters:
xthe x position in pixels
ythe y position in pixels
Returns:
a pointer to a SGEPOSITION

Definition at line 11 of file sgegfx.c.

SDL_Surface* sgeRotoZoom ( SDL_Surface *  source,
float  rotation,
float  zoom 
)

creates a new SDL_Surface from a source which displays a rotated and zoomed copy of source

Parameters:
sourcea pointer to a SDL_Surface which will be used as source of the rotation/zoom
rotationthe rotation of the result in radians
zoomthe zoom of the result
Returns:
a new SDL_Surface with rotation and zoom applied

The rotation is in radians:

http://en.wikipedia.org/wiki/Radians

example:

Create a new SDL_Surface which is roughly 180 degrees rotated and two times the size of myImage

 SDL_Surface *new=sgeRotoZoom(myImage, 3.14, 2.0); 

Definition at line 185 of file sgegfx.c.

void sgeUseAlpha ( SDL_Surface *  s)

enable alpha blending on a SDL_Surface

Parameters:
sa pointer to a SDL_Surface

Definition at line 181 of file sgegfx.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines