KlassischeKeplerKriege/game/renderer.cpp
2016-09-27 21:28:26 +02:00

34 lines
806 B
C++

#include "renderer.hpp"
static const char *vss =
#include "main.vs"
;
static const char *fss =
#include "main.fs"
;
endofthejedi::Renderer::Renderer() {
m_shader.load(vss, GL_VERTEX_SHADER);
m_shader.load(fss, GL_FRAGMENT_SHADER);
}
endofthejedi::Renderer::~Renderer() {}
void endofthejedi::Renderer::render() {
m_shader.bind();
}
void endofthejedi::Renderer::drawCircle(float x, float y, float radius, float r,
float g, float b, int numSides) {
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();
}