-
Notifications
You must be signed in to change notification settings - Fork 0
/
easygame.h
47 lines (36 loc) · 1.22 KB
/
easygame.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
#ifndef __EASYGAME_H_
#define __EASYGAME_H_
#include <string>
#include <SDL2/SDL.h>
// initialization, shutdown, etc.
void eg_init(int width, int height, const std::string &title);
void eg_shutdown();
typedef SDL_Event EGEvent;
bool eg_poll_event(EGEvent *ev);
bool eg_get_keystate(int scancode);
void warp_mouse(int x, int y);
// graphics
void eg_swap_buffers();
void eg_clear_screen(float r, float g, float b, float a);
void eg_push_transform();
void eg_pop_transform();
void eg_reset_transform();
void eg_rotate(float r);
void eg_scale(float x, float y);
void eg_translate(float x, float y);
void eg_set_color(float r, float g, float b, float a);
void eg_draw_point(float x, float y, float w = 1.0f);
void eg_draw_square(float x, float y, float w, float h);
void eg_draw_line(float x0, float y0, float x1, float y1, float w = 1.0f);
struct EGImage;
EGImage *eg_load_image(const std::string &filename);
void eg_free_image(EGImage *image);
void eg_draw_image(EGImage *img, float x, float y, float w, float h);
// util
template<typename T>
T clamp(const T &x, const T &a, const T &b) {
return std::max(std::min(x, b), a);
}
float angle_diff(float a, float b);
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
#endif