-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.h
98 lines (62 loc) · 1.98 KB
/
graphics.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* *
* @project nbodies
* @file graphics.h
*
* @author Braden Nicholson
* @date 3/8/21, 5/10/22
*/
#ifndef GRAPHICS_H
#define GRAPHICS_H
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <OpenGL/glu.h>
#include <iostream>
using std::string;
struct Camera {
float x{}, y{}, z{};
float pitch = -180, roll = 0, yaw = 0;
float scale = 1;
float radius = 0;
};
class Graphics {
private:
int vw, vh;
SDL_Window *window{};
SDL_Renderer *renderer{};
SDL_GLContext glContext{};
GLUquadric *quad{};
Camera *camera{};
bool state{};
public:
Graphics(int w, int h);
~Graphics();
void clear();
void render();
int drawChar(char c, float size, float x, float y);
void fillRect(float x, float y, float w, float h);
void setColor(int r, int g, int b);
void setAlphaColor(int r, int g, int b, int a);
void drawCube(float x, float y, float z, float w, float h, float d);
void drawOrigin(float x, float y, float z, float w, float h, float d);
Camera getCamera() {
return *camera;
}
void rotate(float y, float p, float r);
void scaleCamera(float s);
void drawMeter(float x, float y, float w, float h, float p);
void setRadius(float r);
void drawString(string s, float size, float x, float y);
void drawString3D(string s, float size, float x, float y, float z);
void centerFull(float s);
void drawCircle(float x, float y, float r);
float drawStringGetLength(string s, float size, float x, float y);
void strokeRect(float x, float y, float w, float h);
void drawSphere(float x, float y, float z, float r);
void beginSimulationFrame();
void endSimulationFrame();
void materialColor(float r, float g, float b);
void materialEmit(float r, float g, float b, float f);
void drawString3DFace(string s, float size, float x, float y, float z);
void drawLine(float x1, float y1, float z1, float x2, float y2, float z2);
};
#endif //BARNESHUT_GRAPHICS_H