SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Defines | Functions | Variables

# 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
SGEPOSITION * | sgePositionNew (int x, int y)
| create a new SGEPOSITION
void | sgePositionDestroy (SGEPOSITION *p)
| destroy a SGEPOSITION and free resources
SGEPIXELINFO * | sgePixelInfoNew (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
SGEPIXELINFO * | sgeGetPixel (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:

  s | a pointer to a SDL_Surface
  alpha | the 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:

  src | the 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:

  width | the width of the new surface
  height | the height of the new surface
  depth | the bit depth of the new surface
  sdlflags | the 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:

  width | the width of the new surface
  height | the height of the new surface
  depth | the bit depth of the new surface
  sdlflags | the 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:

  dest | the destination surface
  image | the actual image to draw onto dest
  x | the x position on dest to draw to
  y | the 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:

  dest | the destination surface
  x | the starting x coordinate of the line
  y | the starting y coordinate of the line
  x2 | the ending x coordinate of the line
  y2 | the ending y coordinate of the line
  color | the 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:

  dest | the destination surface
  x | the x coordinate of the pixel
  y | the y coordinate of the pixel
  color | the 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:

  dest | the destination surface
  x | the x coordinate of upper left corner of the rectangle
  y | the y coordinate of upper left corner of the rectangle
  w | the width of the rectangle
  h | the height of the rectangle
  linewidth | the line width in pixels of the outline
  color | the 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:

  dest | the destination surface
  x | the x coordinate of upper left corner of the rectangle
  y | the y coordinate of upper left corner of the rectangle
  w | the width of the rectangle
  h | the height of the rectangle
  color | the 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:

  dest | the SDL_Surface to read the pixel from
  x | the x coordinate of the pixel
  y | the 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:

  s | a 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:

  surface | the SDL_Surface it should be created for
  r | the red value of the pixel (0-255)
  g | the green value of the pixel (0-255)
  b | the blue value of the pixel (0-255)
  a | the 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:

  p | a 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:

  r | the red value of the pixel (0-255)
  g | the green value of the pixel (0-255)
  b | the blue value of the pixel (0-255)
  a | the 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:

  p | a pointer to a SGEPOSITION

Definition at line 20 of file sgegfx.c.

SGEPOSITION* sgePositionNew | ( | int | x,
|  | int | y
| ) |  |

create a new SGEPOSITION

Parameters:

  x | the x position in pixels
  y | the 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:

  source | a pointer to a SDL_Surface which will be used as source of the rotation/zoom
  rotation | the rotation of the result in radians
  zoom | the 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:

  s | a pointer to a SDL_Surface

Definition at line 181 of file sgegfx.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines