2016-09-27 17:01:21 +00:00
|
|
|
#include "renderer.hpp"
|
2016-09-15 15:23:02 +00:00
|
|
|
|
2016-09-27 18:56:17 +00:00
|
|
|
static const char *vss =
|
|
|
|
#include "main.vs"
|
|
|
|
;
|
|
|
|
static const char *fss =
|
|
|
|
#include "main.fs"
|
|
|
|
;
|
2016-09-27 15:57:41 +00:00
|
|
|
|
2016-09-27 18:56:17 +00:00
|
|
|
endofthejedi::Renderer::Renderer() {
|
|
|
|
m_shader.load(vss, GL_VERTEX_SHADER);
|
|
|
|
m_shader.load(fss, GL_FRAGMENT_SHADER);
|
2016-09-27 19:28:26 +00:00
|
|
|
|
2016-09-27 15:57:41 +00:00
|
|
|
|
|
|
|
}
|
2016-09-25 21:05:27 +00:00
|
|
|
|
|
|
|
endofthejedi::Renderer::~Renderer() {}
|
|
|
|
|
2016-09-27 18:56:17 +00:00
|
|
|
void endofthejedi::Renderer::render() {
|
|
|
|
m_shader.bind();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-09-25 21:05:27 +00:00
|
|
|
void endofthejedi::Renderer::drawCircle(float x, float y, float radius, float r,
|
2016-09-27 16:23:58 +00:00
|
|
|
float g, float b, int numSides) {
|
2016-09-27 18:56:17 +00:00
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
glVertex2f(x, y); // center of circle
|
|
|
|
for (int i = 0; i <= numSides; i++) {
|
|
|
|
glColor3f(r, g, b);
|
|
|
|
glVertex2f(x + (radius * cos(i * 2 * M_PI / numSides)),
|
|
|
|
y + (radius * sin(i * 2 * M_PI / numSides)));
|
|
|
|
}
|
|
|
|
glEnd();
|
2016-09-15 15:23:02 +00:00
|
|
|
}
|