+ added drawCircle in renderer

This commit is contained in:
end 2016-09-25 23:05:27 +02:00
parent c482a3f779
commit a4557a2762
3 changed files with 23 additions and 2 deletions

View file

@ -11,6 +11,7 @@ set(GAME_SRC
src/glclasses.cpp src/glclasses.cpp
src/config.cpp src/config.cpp
src/simulation.cpp src/simulation.cpp
src/renderer.cpp
) )
set(GAME_HEADERS set(GAME_HEADERS
@ -19,6 +20,7 @@ set(GAME_HEADERS
include/vector.h include/vector.h
include/config.h include/config.h
include/simulation.h include/simulation.h
include/renderer.h
) )
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})

View file

@ -1,12 +1,20 @@
#pragma once #pragma once
#include <math.h>
#include <epoxy/gl.h> #include <epoxy/gl.h>
#include <epoxy/glx.h> #include <epoxy/glx.h>
namespace endofthejedi {
class Renderer { class Renderer {
private: private:
protected: protected:
public: public:
Renderer(); Renderer();
~Renderer(); ~Renderer();
void drawCircle(float x, float y, float radius, float r,
float g, float b);
}; };
}

View file

@ -1,5 +1,16 @@
#include <include/renderer.h> #include <include/renderer.h>
Renderer::Renderer() { endofthejedi::Renderer::Renderer() {}
endofthejedi::Renderer::~Renderer() {}
void endofthejedi::Renderer::drawCircle(float x, float y, float radius, float r,
float g, float b) {
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y); // center of circle
for (int i = 0; i <= 64; i++) {
glColor3f(r,g,b);
glVertex2f(x + (radius * cos(i * 2 * M_PI / 64)), y + (radius * sin(i * 2 * M_PI / 64)));
}
glEnd();
} }