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_utils.h
Go to the documentation of this file.
1 
24 #ifndef __GFX_UTILS_H__
25 #define __GFX_UTILS_H__
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 
36 int gfxUtilIsCurGLThread(void);
37 
41 void gfxUtilSetGLThread(void);
42 
50 char *gfxUtilPrependPath(const char *path, char *file);
51 
59 char *gfxUtilGetBinFolderPath(char *bin_path);
60 
66 const char *gfxUtilFindResourceDirectory(void);
67 
76 FILE *gfxUtilFindResource(char *resource_name, const char *mode);
77 
88 char *gfxUtilFindResourcePath(char *resource_name);
89 
93 typedef void *rbuf_handle_t;
94 
103 rbuf_handle_t gfxRbufInit(size_t item_size, size_t item_count);
104 
115 rbuf_handle_t gfxRbufInitStatic(size_t item_size, size_t item_count, void *buffer);
116 
122 void gfxRbufFree(rbuf_handle_t rbuf);
123 
129 void gfxRbufReset(rbuf_handle_t rbuf);
130 
139 
147 int gfxRbufPut(rbuf_handle_t rbuf, void *data);
148 
157 int gfxRbufFPut(rbuf_handle_t rbuf, void *data);
158 
168 void *gfxRbufGetBuffer(rbuf_handle_t rbuf);
169 
178 int gfxRbufGet(rbuf_handle_t rbuf, void *data);
179 
186 unsigned char gfxRbufEmpty(rbuf_handle_t rbuf);
187 
194 unsigned char gfxRbufFull(rbuf_handle_t rbuf);
195 
202 size_t gfxRbufSize(rbuf_handle_t rbuf);
203 
210 size_t gfxRbufCapacity(rbuf_handle_t rbuf);
211 
212 #endif
void * rbuf_handle_t
A handle to a ring buffer object, created using gfxRbufInit()
Definition: gfx_utils.h:93
void gfxRbufReset(rbuf_handle_t rbuf)
Resets the ring buffer to it's initial state.
Definition: gfx_utils.c:322
char * gfxUtilPrependPath(const char *path, char *file)
Prepends a path string to a filename.
Definition: gfx_utils.c:79
size_t gfxRbufCapacity(rbuf_handle_t rbuf)
Returns the maximum number of elements that the ring buffer can store.
Definition: gfx_utils.c:492
int gfxRbufPut(rbuf_handle_t rbuf, void *data)
Fills the next available buffer slot, if a slot is free.
Definition: gfx_utils.c:352
char * gfxUtilFindResourcePath(char *resource_name)
Similar to gfxUtilFindResource() only returning the file's path instead of the opened FILE's referenc...
Definition: gfx_utils.c:207
char * gfxUtilGetBinFolderPath(char *bin_path)
Gets the execution folder of the current program, assumes that program is executing from a folder "bi...
Definition: gfx_utils.c:93
void gfxUtilSetGLThread(void)
The calling thread is registered as holding the current GL context.
Definition: gfx_utils.c:72
void gfxRbufFree(rbuf_handle_t rbuf)
Frees a ring buffer.
Definition: gfx_utils.c:311
int gfxRbufGet(rbuf_handle_t rbuf, void *data)
Returns a copy of the next buffer item's data.
Definition: gfx_utils.c:425
FILE * gfxUtilFindResource(char *resource_name, const char *mode)
Searches for a file in the RESOURCES_DIRECTORY and returns a FILE * if found.
Definition: gfx_utils.c:193
rbuf_handle_t gfxRbufInit(size_t item_size, size_t item_count)
Initialized a ring buffer object with a certain number of objects of a given size.
Definition: gfx_utils.c:257
int gfxRbufPutBuffer(rbuf_handle_t rbuf)
Used when a reference to the next buffer item is already filled, incrementing the next buffer item sh...
Definition: gfx_utils.c:338
const char * gfxUtilFindResourceDirectory(void)
Returns the lopcation of the resource directory.
Definition: gfx_utils.c:177
int gfxRbufFPut(rbuf_handle_t rbuf, void *data)
Fills the next available buffer, overwriting data if the ring buffer is full.
Definition: gfx_utils.c:376
unsigned char gfxRbufFull(rbuf_handle_t rbuf)
Checks if the buffer is full.
Definition: gfx_utils.c:459
rbuf_handle_t gfxRbufInitStatic(size_t item_size, size_t item_count, void *buffer)
Initialized a ring buffer object with a certain number of objects of a given size into a statically a...
Definition: gfx_utils.c:284
int gfxUtilIsCurGLThread(void)
Checks if the calling thread is the thread that currently holds the GL context.
Definition: gfx_utils.c:61
size_t gfxRbufSize(rbuf_handle_t rbuf)
Returns the number of elements currently stored in the ring buffer.
Definition: gfx_utils.c:471
unsigned char gfxRbufEmpty(rbuf_handle_t rbuf)
Checks if the buffer is empty or not.
Definition: gfx_utils.c:448
void * gfxRbufGetBuffer(rbuf_handle_t rbuf)
Returns a reference to the data of the next ring buffer entry.
Definition: gfx_utils.c:397