|
SDLGameEngine
|
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 | |
Low level graphics and drawing functions.
| #define sgeConvertToGray sgeConvertToGrey |
| SDL_Surface* sgeChangeSDLSurfaceAlpha | ( | SDL_Surface * | s, |
| Uint8 | alpha | ||
| ) |
| SDL_Surface* sgeConvertToGrey | ( | SDL_Surface * | src | ) |
| SDL_Surface* sgeCreateSDLSurface | ( | int | width, |
| int | height, | ||
| int | depth, | ||
| Uint32 | sdlflags | ||
| ) |
| SDL_Surface* sgeCreateVideoSurface | ( | int | width, |
| int | height, | ||
| int | depth, | ||
| Uint32 | sdlflags | ||
| ) |
create a new accelerated SDL_Surface into video RAM (if possible)
| 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
| void sgeDrawImage | ( | SDL_Surface * | dest, |
| SDL_Surface * | image, | ||
| int | x, | ||
| int | y | ||
| ) | [inline] |
draw a image
| 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);
| void sgeDrawLine | ( | SDL_Surface * | dest, |
| int | x, | ||
| int | y, | ||
| int | x2, | ||
| int | y2, | ||
| Uint32 | color | ||
| ) | [inline] |
draw a line
| 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) |
| void sgeDrawPixel | ( | SDL_Surface * | dest, |
| int | x, | ||
| int | y, | ||
| Uint32 | color | ||
| ) | [inline] |
draw a pixel
| 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) |
| void sgeDrawRect | ( | SDL_Surface * | dest, |
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | h, | ||
| int | linewidth, | ||
| Uint32 | color | ||
| ) | [inline] |
draw the outlines of a rectangle
| 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));
| void sgeFillRect | ( | SDL_Surface * | dest, |
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | h, | ||
| Uint32 | color | ||
| ) | [inline] |
draw a filled rectangle
| 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) |
| SGEPIXELINFO* sgeGetPixel | ( | SDL_Surface * | dest, |
| int | x, | ||
| int | y | ||
| ) | [inline] |
get the color of a pixel
| dest | the SDL_Surface to read the pixel from |
| x | the x coordinate of the pixel |
| y | the y coordinate of the pixel |
| void sgeIgnoreAlpha | ( | SDL_Surface * | s | ) |
| Uint32 sgeMakeColor | ( | SDL_Surface * | surface, |
| int | r, | ||
| int | g, | ||
| int | b, | ||
| int | a | ||
| ) | [inline] |
create a new hardware dependant color
| 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));
| void sgePixelInfoDestroy | ( | SGEPIXELINFO * | i | ) |
destroy a SGEPIXELINFO and free resources
| p | a pointer to a SGEPIXELINFO |
| SGEPIXELINFO* sgePixelInfoNew | ( | Uint8 | r, |
| Uint8 | g, | ||
| Uint8 | b, | ||
| Uint8 | a | ||
| ) |
create a new SGEPIXELINFO
| 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) |
| void sgePositionDestroy | ( | SGEPOSITION * | p | ) |
destroy a SGEPOSITION and free resources
| p | a pointer to a SGEPOSITION |
| SGEPOSITION* sgePositionNew | ( | int | x, |
| int | y | ||
| ) |
create a new SGEPOSITION
| x | the x position in pixels |
| y | the y position in pixels |
| 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
| 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 |
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);