-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrendering.c
More file actions
40 lines (34 loc) · 1.22 KB
/
rendering.c
File metadata and controls
40 lines (34 loc) · 1.22 KB
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
#include "rendering.h"
#include <Windows.h>
#include <gl/GL.h>
#include <math.h>
#define TAU_F 6.2831853071f
void aaline(const float* r, const float* g, const float* b, const float* a, const float* startX, const float* startY, const float* endX, const float* endY, const float* lineWidth) {
glLineWidth(*lineWidth);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(*r, *g, *b, *a);
glBegin(GL_LINES);
glVertex2f(*startX, *startY);
glVertex2f(*endX, *endY);
glEnd();
}
void filledCircle(const float* centerX, const float* centerY, const float* radius, const float* r, const float* g, const float* b, const float* a, const int* nSegments) {
const float nSegments_f = (float)(*nSegments);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glColor4f(*r, *g, *b, *a);
glBegin(GL_TRIANGLE_FAN);
glVertex2f(*centerX, *centerY);
for (int i = 0; i <= *nSegments; i++) {
float theta = TAU_F * (float)i / nSegments_f;
float x = *radius * cosf(theta);
float y = *radius * sinf(theta);
glVertex2f(x + *centerX, y + *centerY);
}
glEnd();
}