Defines | Functions | Variables

graphics.c File Reference

2D Graphics More...

#include <stdint.h>
#include <malloc.h>
#include <string.h>
#include "display.h"
#include "graphics.h"
#include "font.h"

Defines

#define __set_pixel(buffer, x, y, color)   (buffer)[(x) + ((y) * __width)] = color
 Macro to set a pixel to a certain color in a buffer.
#define __get_pixel(buffer, x, y)   (buffer)[(x) + ((y) * __width)]
 Macro to get a pixel color from a buffer.
#define __get_buffer(x)   __safe_buffer[(x)-1]
 Get the correct video buffer given a display context.

Functions

uint32_t graphics_make_color (int r, int g, int b, int a)
 Return a 32-bit representation of an RGBA color.
uint32_t graphics_convert_color (color_t color)
 Convert a color structure to a 32-bit representation of an RGBA color.
void graphics_set_color (uint32_t forecolor, uint32_t backcolor)
 Set the current forecolor and backcolor for text operations.
void graphics_draw_pixel (display_context_t disp, int x, int y, uint32_t color)
 Draw a pixel to a given display context.
void graphics_draw_pixel_trans (display_context_t disp, int x, int y, uint32_t color)
 Draw a pixel to a given display context with alpha support.
void graphics_draw_line (display_context_t disp, int x0, int y0, int x1, int y1, uint32_t color)
 Draw a line to a given display context.
void graphics_draw_line_trans (display_context_t disp, int x0, int y0, int x1, int y1, uint32_t color)
 Draw a line to a given display context with alpha support.
void graphics_draw_box (display_context_t disp, int x, int y, int width, int height, uint32_t color)
 Draw a filled rectangle to a display context.
void graphics_draw_box_trans (display_context_t disp, int x, int y, int width, int height, uint32_t color)
 Draw a filled rectangle to a display context.
void graphics_fill_screen (display_context_t disp, uint32_t c)
 Fill the entire screen with a particular color.
void graphics_draw_character (display_context_t disp, int x, int y, char ch)
 Draw a character to the screen using the built-in font.
void graphics_draw_text (display_context_t disp, int x, int y, const char *const msg)
 Draw a null terminated string to a display context.
void graphics_draw_sprite (display_context_t disp, int x, int y, sprite_t *sprite)
 Draw a sprite to a display context.
void graphics_draw_sprite_stride (display_context_t disp, int x, int y, sprite_t *sprite, int offset)
 Draw a sprite from a spritemap to a display context.
void graphics_draw_sprite_trans (display_context_t disp, int x, int y, sprite_t *sprite)
 Draw a sprite to a display context with alpha transparency.
void graphics_draw_sprite_trans_stride (display_context_t disp, int x, int y, sprite_t *sprite, int offset)
 Draw a sprite from a spritemap to a display context.

Variables

uint32_t __bitdepth
 Currently active bit depth.
uint32_t __width
 Currently active video width (calculated).
uint32_t __height
 Currently active video height (calculated).
void * __safe_buffer []
 Pointer to uncached 16-bit aligned version of buffers.

Detailed Description

2D Graphics

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines