FreeRTOS Emulator with SDL2 Based Graphics and Input Library  1.0
A POSIX wrapper to run FreeRTOS on an x86 machine with some basic input and output libraries aimed at making teaching FreeRTOS simpler.
gfx_draw.h File Reference
#include "EmulatorConfig.h"

Go to the source code of this file.

Classes

struct  coord
 Holds a pixel co-ordinate. More...
 

Macros

#define WINDOW_TITLE   "FreeRTOS Emulator"
 
#define SCREEN_WIDTH   640
 
#define SCREEN_HEIGHT   480
 
Hex RGB colours

RRGGBB colours used by GFX Draw backend, colour standard is the same as the common html standard

#define TUMBlue   (unsigned int)(0x0065bd)
 
#define Red   (unsigned int)(0xFF0000)
 
#define Green   (unsigned int)(0x00FF00)
 
#define Blue   (unsigned int)(0x0000FF)
 
#define Yellow   (unsigned int)(0xFFFF00)
 
#define Aqua   (unsigned int)(0x00FFFF)
 
#define Fuchsia   (unsigned int)(0xFF00FF)
 
#define White   (unsigned int)(0xFFFFFF)
 
#define Black   (unsigned int)(0x000000)
 
#define Gray   (unsigned int)(0x808080)
 
#define Grey   Gray
 
#define Magenta   Fuchsia
 
#define Cyan   Aqua
 
#define Lime   (unsigned int)(0x00FF00)
 
#define Maroon   (unsigned int)(0x800000)
 
#define Navy   (unsigned int)(0x000080)
 
#define Olive   (unsigned int)(0x808000)
 
#define Purple   (unsigned int)(0x800080)
 
#define Silver   (unsigned int)(0xC0C0C0)
 
#define Teal   (unsigned int)(0x008080)
 
#define Orange   (unsigned int)(0xFFA500)
 
#define Pink   (unsigned int)(0xFFC0CB)
 
#define Skyblue   (unsigned int)(0x87CEEB)
 

Typedefs

typedef struct coord coord_t
 Holds a pixel co-ordinate. More...
 
typedef void * gfx_image_handle_t
 Handle used to reference loaded images, an invalid image will have a NULL handle. More...
 
typedef void * gfx_animation_handle_t
 Handle used to reference a loaded animation spritesheet, an invalid spritesheet will have a NULL handle. More...
 
typedef void * gfx_sequence_handle_t
 Returns an instance of an animation. More...
 
typedef void * gfx_spritesheet_handle_t
 Returns an instance of a spritesheet. More...
 

Enumerations

enum  sprite_sequence_direction { SPRITE_SEQUENCE_HORIZONTAL_POS , SPRITE_SEQUENCE_HORIZONTAL_NEG , SPRITE_SEQUENCE_VERTICAL_POS , SPRITE_SEQUENCE_VERTICAL_NEG }
 Defines the direction that the animation appears on the spritesheet. More...
 

Functions

char * gfxGetErrorMessage (void)
 Returns a string error message from the gfx_draw back end. More...
 
int gfxDrawInit (char *path)
 Initializes the gfx_draw backend. More...
 
int gfxDrawBindThread (void)
 Transfers the drawing ability to the calling thread/taskd. More...
 
void gfxDrawExit (void)
 Exits the GFX Draw backend. More...
 
int gfxDrawUpdateScreen (void)
 Executes the queued draw jobs. More...
 
int gfxDrawClear (unsigned int colour)
 Sets the screen to a solid colour. More...
 
void gfxDrawDuplicateBuffer (void)
 
int gfxDrawEllipse (signed short x, signed short y, signed short rx, signed short ry, unsigned int colour)
 Draws an ellipse on the screen. More...
 
int gfxDrawArc (signed short x, signed short y, signed short radius, signed short start, signed short end, unsigned int colour)
 Draws an arc on the screen. More...
 
int gfxDrawText (char *str, signed short x, signed short y, unsigned int colour)
 Prints a string to the screen. More...
 
int gfxGetTextSize (char *str, int *width, int *height)
 Finds the width and height of a strings bounding box. More...
 
int gfxDrawCenteredText (char *str, signed short x, signed short y, unsigned int colour)
 Prints a string to the screen. More...
 
int gfxDrawBox (signed short x, signed short y, signed short w, signed short h, unsigned int colour)
 Draws a filled box on the screen. More...
 
int gfxDrawFilledBox (signed short x, signed short y, signed short w, signed short h, unsigned int colour)
 Draws an unfilled box on the screen. More...
 
int gfxDrawCircle (signed short x, signed short y, signed short radius, unsigned int colour)
 Draws a filled circle on the screen. More...
 
int gfxDrawLine (signed short x1, signed short y1, signed short x2, signed short y2, unsigned char thickness, unsigned int colour)
 Draws a line on the screen. More...
 
int gfxDrawPoly (coord_t *points, int n, unsigned int colour)
 Draws a polygon on the screen. More...
 
int gfxDrawTriangle (coord_t *points, unsigned int colour)
 Draws a triangle on the screen. More...
 
gfx_image_handle_t gfxDrawLoadImage (char *filename)
 Loads an image file from disk, loaded image file can be closed using gfxDrawFreeLoadedImage() More...
 
gfx_image_handle_t gfxDrawLoadScaledImage (char *filename, float scale)
 Loads an image from disk and scales the image, loaded image file can be closed using gfxDrawFreeLoadedImage(). Note that scaled images have large overheads compared to manually scaled images (changing image file's dimensions) More...
 
int gfxDrawFreeLoadedImage (gfx_image_handle_t *img)
 Closes a loaded image and frees all memory used by the image structure. More...
 
int gfxDrawSetLoadedImageScale (gfx_image_handle_t img, float scale)
 Scales a loaded image, the scale is a value where, for example, 1.0 represents the original image's size. The scaling factor scales the image relative to the image file's dimensions on disk. More...
 
float gfxDrawGetLoadedImageScale (gfx_image_handle_t img)
 Retrieves the current scaling factor of an image. More...
 
int gfxDrawGetLoadedImageWidth (gfx_image_handle_t img)
 Retrieves the image's width when drawn to screen, ie. after scaling. More...
 
int gfxDrawGetLoadedImageHeight (gfx_image_handle_t img)
 Retrieves the image's height when drawn to screen, ie. after scaling. More...
 
int gfxDrawGetLoadedImageSize (gfx_image_handle_t img, int *w, int *h)
 Retrieves bother the image's width and height when drawn to screen, ie. after scaling. More...
 
int gfxDrawLoadedImage (gfx_image_handle_t img, signed short x, signed short y)
 Draws a loaded image to the screen. More...
 
int gfxDrawImage (char *filename, signed short x, signed short y)
 Draws an image on the screen. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromEntireImageUnpadded (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows)
 Creates a spritesheet object from a loaded image where each sprite is not padded and the sprite sheet is divided into an number of equal sized rows and columns. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromEntireImagePadded (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows, unsigned sprite_padding_x, unsigned sprite_padding_y)
 Creates a spritesheet object from a loaded image where sprites are padded. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromEntireImagePaddedSpacing (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows, unsigned sprite_spacing_x, unsigned sprite_spacing_y)
 Creates a spritesheet object from a loaded image where sprites are padded. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromPortionOfImageUnpadded (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows, unsigned sprite_width, unsigned sprite_height, unsigned bounding_box_left_x_pixel, unsigned bounding_box_top_y_pixel)
 Creates a spritesheet object from a portion of a loaded image where sprites are unpadded. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromPortionOfImagePadded (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows, unsigned sprite_width, unsigned sprite_height, unsigned sprite_padding_x, unsigned sprite_padding_y, unsigned bounding_box_left_x_pixel, unsigned bounding_box_top_y_pixel)
 Creates a spritesheet object from a portion of loaded image where sprites are padded. More...
 
gfx_spritesheet_handle_t gfxDrawLoadSpritesheetFromPortionOfImagePaddedSpacing (gfx_image_handle_t img, unsigned sprite_cols, unsigned sprite_rows, unsigned sprite_width, unsigned sprite_height, unsigned sprite_spacing_x, unsigned sprite_spacing_y, unsigned bounding_box_left_x_pixel, unsigned bounding_box_top_y_pixel)
 Creates a spritesheet object from a portion of loaded image where sprites are padded. More...
 
int gfxDrawSprite (gfx_spritesheet_handle_t spritesheet, char column, char row, signed short x, signed short y)
 Draws a sprite from a spritesheet. More...
 
int gfxGetImageSize (char *filename, int *w, int *h)
 Gets the width and height of an image. More...
 
int gfxDrawScaledImage (char *filename, signed short x, signed short y, float scale)
 Draws a scaled image on the screen. More...
 
int gfxDrawArrow (signed short x1, signed short y1, signed short x2, signed short y2, signed short head_length, unsigned char thickness, unsigned int colour)
 Draws an arrow on the screen. More...
 
gfx_animation_handle_t gfxDrawAnimationCreate (gfx_spritesheet_handle_t spritesheet)
 Creates an animation object with an attached spritesheet that must be loaded prior as an image. More...
 
int gfxDrawAnimationAddSequence (gfx_animation_handle_t animation, char *name, unsigned start_row, unsigned start_col, enum sprite_sequence_direction sprite_step_direction, unsigned frames)
 Adds an animation sequence to a previously created animation. More...
 
gfx_sequence_handle_t gfxDrawAnimationSequenceInstantiate (gfx_animation_handle_t animation, char *sequence_name, unsigned frame_period_ms)
 Creates an instance of an animation from a loaded animation object and a sequence name of a sequence previously added to the animation object. More...
 
void gfxDrawAnimationReset (gfx_sequence_handle_t sequence)
 Resets the time and frame of an animation back to its initial configuration. More...
 
int gfxDrawAnimationDrawFrame (gfx_sequence_handle_t sequence, unsigned ms_timestep, int x, int y)
 Draws the target intantiated animation sequence at a given location. More...
 
int gfxDrawSetGlobalXOffset (int offset)
 Sets the global draw position offset's X axis value. More...
 
int gfxDrawSetGlobalYOffset (int offset)
 Sets the global draw position offset's Y axis value. More...
 
int gfxDrawGetGlobalXOffset (int *offset)
 Retrieves a copy of the current global X axis drawing offset. More...
 
int gfxDrawGetGlobalYOffset (int *offset)
 Retrieves a copy of the current global X axis drawing offset. More...