|
uint16_t | color_to_packed16 (color_t c) |
| Convert a color_t to the 16-bit packed format used by a FMT_RGBA16 surface (RGBA 5551)
|
|
uint32_t | color_to_packed32 (color_t c) |
| Convert a color_t to the 32-bit packed format used by a FMT_RGBA32 surface (RGBA 8888)
|
|
color_t | color_from_packed16 (uint16_t c) |
| Create a color_t from the 16-bit packed format used by a FMT_RGBA16 surface (RGBA 5551)
|
|
color_t | color_from_packed32 (uint32_t c) |
| Create a color_t from the 32-bit packed format used by a FMT_RGBA32 surface (RGBA 8888)
|
|
uint32_t | graphics_make_color (int r, int g, int b, int a) |
| Return a packed 32-bit representation of an RGBA color. More...
|
|
uint32_t | graphics_convert_color (color_t color) |
| Convert a color structure to a 32-bit representation of an RGBA color. More...
|
|
void | graphics_draw_pixel (surface_t *surf, int x, int y, uint32_t color) |
| Draw a pixel to a given display context. More...
|
|
void | graphics_draw_pixel_trans (surface_t *surf, int x, int y, uint32_t color) |
| Draw a pixel to a given display context with alpha support. More...
|
|
void | graphics_draw_line (surface_t *surf, int x0, int y0, int x1, int y1, uint32_t color) |
| Draw a line to a given display context. More...
|
|
void | graphics_draw_line_trans (surface_t *surf, int x0, int y0, int x1, int y1, uint32_t color) |
| Draw a line to a given display context with alpha support. More...
|
|
void | graphics_draw_box (surface_t *surf, int x, int y, int width, int height, uint32_t color) |
| Draw a filled rectangle to a display context. More...
|
|
void | graphics_draw_box_trans (surface_t *surf, int x, int y, int width, int height, uint32_t color) |
| Draw a filled rectangle to a display context. More...
|
|
void | graphics_fill_screen (surface_t *surf, uint32_t c) |
| Fill the entire screen with a particular color. More...
|
|
void | graphics_set_color (uint32_t forecolor, uint32_t backcolor) |
| Set the current forecolor and backcolor for text operations. More...
|
|
void | graphics_set_default_font (void) |
| Set the font to the default.
|
|
void | graphics_set_font_sprite (sprite_t *font) |
| Set the current font. Should be set before using any of the draw function. More...
|
|
void | graphics_draw_character (surface_t *surf, int x, int y, char ch) |
| Draw a character to the screen using the built-in font. More...
|
|
void | graphics_draw_text (surface_t *surf, int x, int y, const char *const msg) |
| Draw a null terminated string to a display context. More...
|
|
void | graphics_draw_sprite (surface_t *surf, int x, int y, sprite_t *sprite) |
| Draw a sprite to a display context. More...
|
|
void | graphics_draw_sprite_stride (surface_t *surf, int x, int y, sprite_t *sprite, int offset) |
| Draw a sprite from a spritemap to a display context. More...
|
|
void | graphics_draw_sprite_trans (surface_t *surf, int x, int y, sprite_t *sprite) |
| Draw a sprite to a display context with alpha transparency. More...
|
|
void | graphics_draw_sprite_trans_stride (surface_t *surf, int x, int y, sprite_t *sprite, int offset) |
| Draw a sprite from a spritemap to a display context. More...
|
|
Software routines for manipulating graphics in a display context.
The graphics subsystem is responsible for software manipulation of a display context as returned from the Display Subsystem. All of the functions use a pure software drawing method and are thus much slower than hardware sprite support. However, they are slightly more flexible and offer no hardware limitations in terms of sprite size.
void graphics_set_font_sprite |
( |
sprite_t * |
font | ) |
|
Set the current font. Should be set before using any of the draw function.
The sprite font should be imported using hslices/vslices according to the amount of characters it has. The amount of hslices vs vslices does not matter for this, but it should include the whole ASCII range that you will want to use, including characters from the 0 to 32 range. Normally the sprite should have 127 slices to cover the normal ASCII range.
During rendering, the slice used will be the same number as the char (eg.: character 'A' will use slice 65).
You can see an example of a sprite font (that has the default font double sized) under examples/customfont.
- Parameters
-
[in] | font | Sprite font to be used. |
void graphics_draw_text |
( |
surface_t * |
surf, |
|
|
int |
x, |
|
|
int |
y, |
|
|
const char *const |
msg |
|
) |
| |
Draw a null terminated string to a display context.
Draw a string to the screen, following a few simple rules. Standard ASCII is supported, as well as \r, \n, space and tab. \r and \n will both cause the next character to be rendered one line lower and at the x coordinate specified in the parameters. The tab character inserts five spaces.
This function does not support alpha blending, only binary transparency. If the background color is fully transparent, the font is drawn with no background. Otherwise, the font is drawn on a fully colored background. The foreground and background can be set using graphics_set_color.
- Parameters
-
[in] | surf | The currently active display context. |
[in] | x | The X coordinate to place the top left pixel of the character drawn. |
[in] | y | The Y coordinate to place the top left pixel of the character drawn. |
[in] | msg | The ASCII null terminated string to draw to the screen. |
void graphics_draw_sprite_stride |
( |
surface_t * |
surf, |
|
|
int |
x, |
|
|
int |
y, |
|
|
sprite_t * |
sprite, |
|
|
int |
offset |
|
) |
| |
Draw a sprite from a spritemap to a display context.
Given a sprite structure, this function will draw a sprite out of a larger spritemap to the display context with clipping support. This function is useful for software tilemapping. If a sprite was generated as a spritemap (it has more than one horizontal or vertical slice), this function can display a slice of the sprite as a standalone sprite.
Given a sprite with 3 horizontal slices and 2 vertical slices, the offsets would be as follows:
*---*---*---*
| 0 | 1 | 2 |
*---*---*---*
| 3 | 4 | 5 |
*---*---*---*
- Note
- This function does not support alpha blending for speed purposes. For alpha blending support, please see graphics_draw_sprite_trans_stride
- Parameters
-
[in] | surf | The currently active display context. |
[in] | x | The X coordinate to place the top left pixel of the sprite. This can be negative if the sprite is clipped horizontally. |
[in] | y | The Y coordinate to place the top left pixel of the sprite. This can be negative if the sprite is clipped vertically. |
[in] | sprite | Pointer to a sprite structure to display to the screen. |
[in] | offset | Offset of the sprite to display out of the spritemap. The offset is counted starting from 0. The top left sprite in the map is 0, the next one to the right is 1, and so on. |
void graphics_draw_sprite_trans_stride |
( |
surface_t * |
surf, |
|
|
int |
x, |
|
|
int |
y, |
|
|
sprite_t * |
sprite, |
|
|
int |
offset |
|
) |
| |
Draw a sprite from a spritemap to a display context.
Given a sprite structure, this function will draw a sprite out of a larger spritemap to the display context with clipping support. This function is useful for software tilemapping. If a sprite was generated as a spritemap (it has more than one horizontal or vertical slice), this function can display a slice of the sprite as a standalone sprite.
Given a sprite with 3 horizontal slices and 2 vertical slices, the offsets would be as follows:
*---*---*---*
| 0 | 1 | 2 |
*---*---*---*
| 3 | 4 | 5 |
*---*---*---*
- Note
- This function supports alpha blending and is much slower for 32-bit sprites. If you do not need alpha blending support, please see graphics_draw_sprite_stride.
- Parameters
-
[in] | surf | The currently active display context. |
[in] | x | The X coordinate to place the top left pixel of the sprite. This can be negative if the sprite is clipped horizontally. |
[in] | y | The Y coordinate to place the top left pixel of the sprite. This can be negative if the sprite is clipped vertically. |
[in] | sprite | Pointer to a sprite structure to display to the screen. |
[in] | offset | Offset of the sprite to display out of the spritemap. The offset is counted starting from 0. The top left sprite in the map is 0, the next one to the right is 1, and so on. |