SDL¶
Functions
-
bool binocle_sdl_init()¶
Starts SDL2 and must be called before everything else.
- Returns
true if everything went ok
-
void binocle_sdl_exit()¶
Shuts down SDL2 and must be called when the program exits.
-
time_t binocle_sdl_get_last_modification_time(char *filename)¶
Gets the last modification time of a given file.
- Parameters
filename – The filename
- Returns
The last modification time of the file
-
bool binocle_sdl_load_text_file(char *filename, char **buffer, size_t *buffer_length)¶
Loads a text file Loads a text file and stores it in buffer. This function allocates memory so it’s up to the consumer to free it when done with the content.
- Parameters
filename – The filename
buffer – The buffer to write the output to
buffer_length – The size of the buffer
- Returns
true if everything went ok
-
bool binocle_sdl_write_text_file(char *filename, char *buffer, size_t size)¶
Writes a text to a file
- Parameters
filename – The filename
buffer – The buffer with the text
size – The size of the buffer
- Returns
true if everything went ok
-
bool binocle_sdl_load_binary_file(char *filename, char **buffer, size_t *buffer_length)¶
Loads a binary file Loads a binary file and stores it in buffer. This function allocates memory so it’s up to the consumer to free it when done with the content.
- Parameters
filename – The filename
buffer – The buffer to write the output to
buffer_length – The size of the buffer
- Returns
true if everything went ok
-
char *binocle_sdl_assets_dir()¶
Returns the path of the assets folder The actual path depends on the current platform. This function allocates the memory for the string and it’s up to the caller to free it after use.
- Returns
the pointer to the string with the folder of the assets
-
bool binocle_sdl_filename_ends_with(const char *str, const char *suffix)¶
Returns whether a filename ends with a certain suffix.
- Parameters
str – the filename
suffix – the suffix
- Returns
true if the filename ends with the provided suffix