-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utility.h
73 lines (62 loc) · 1.39 KB
/
Utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef HOMEWORK_UTILITY_H
#define HOMEWORK_UTILITY_H
#include <SDL_image.h>
/**
* @file Utility.h
* @brief Utility functions for other header files
* @version 0.1
* @date 2019-11-05
*
* @copyright Copyright (c) 2019
*
*/
#include <SDL.h>
#include <stdio.h>
/**
* @brief Log error
*
*/
#define log_error(fmt, ...) (log_error_base(__FILE__, __LINE__, fmt, ##__VA_ARGS__))
/**
* @brief Minimum of two values
*
*/
#define min(a, b) ((a) < (b) ? (a) : (b))
/**
* @brief Maximum of two values
*
*/
#define max(a, b) ((a) > (b) ? (a) : (b))
/**
* @brief Create an rgba surface
*
* @param w Width of the surface
* @param h Height of the surface
* @return SDL_Surface* Resulting surface
*/
SDL_Surface *get_rgba_surface(int w, int h);
/**
* @brief Get the file name from a path
*
* @param path Path to parse
* @return char* Resulting file name
*/
char *file_from_path(char *path);
/**
* @brief Base function for logging errors
*
* @param file File where log happens
* @param line Line where log happens
* @param fmt Format string
* @param ... Input
*/
void log_error_base(const char *file, int line, const char *fmt, ...);
/**
* @brief Loads a file into a texture
*
* @param path Path to the file
* @param renderer Renderer to bind the texture to
* @return Resulting texture
*/
SDL_Texture *load_texture(const char *path, SDL_Renderer *renderer);
#endif //HOMEWORK_UTILITY_H