From 959202e1116bca160ffd687f9d32973fb64bdc1b Mon Sep 17 00:00:00 2001 From: end Date: Wed, 28 Sep 2016 05:50:43 +0200 Subject: [PATCH 1/4] * some fixes --- game/renderer.cpp | 33 +++++++++++++++++++++++++++++++-- game/renderer.hpp | 4 ++++ game/state/state.cpp | 4 +--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/game/renderer.cpp b/game/renderer.cpp index c11a04d..31b6c46 100644 --- a/game/renderer.cpp +++ b/game/renderer.cpp @@ -29,12 +29,41 @@ void endofthejedi::Renderer::render(const game::State *state) { std::vector reflections; for (const game::Planet *planet : state->planets) { - positions.push_back(glm::vec3(planet->position, -10.0f)); + positions.push_back(glm::vec3(planet->position, -5.0f)); radii.push_back(planet->radius); colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); } - glUniform1f(m_shader.location("aspectratio"), 16.0f/9.0f); + for (const game::Ship *ship : state->ships) { + positions.push_back(glm::vec3(ship->position, -3.0f)); + radii.push_back(ship->radius); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + + for (const game::Player *player : state->players) { + for (const game::Missile *missile : player->missiles) { + positions.push_back(glm::vec3(missile->position, -3.0f)); + radii.push_back(0.01f); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + } + + for (auto& pos : positions) { + pos.x *= 5; + pos.y *= 5; + } + for (auto& rad : radii) { + rad *= 5; + } + + /* + for (const game::Trace *trace : state->traces) { + positions.push_back(glm::vec3(trace->position, -3.0f)); + radii.push_back(trace->radius); + colors.push_back(glm::vec4(0.0f, 1.0f, 0.0f, 0.5f)); + }*/ + + glUniform1f(m_shader.location("aspectratio"), 1.0f); glUniform1i(m_shader.location("reflections"), 1); glUniform3f(m_shader.location("l_position"), 0.6f, 0.1f, 0.0f); glUniform1f(m_shader.location("l_radius"), 1.0f); diff --git a/game/renderer.hpp b/game/renderer.hpp index 572547a..36275ae 100644 --- a/game/renderer.hpp +++ b/game/renderer.hpp @@ -8,6 +8,10 @@ #include "glclasses.hpp" #include "game.hpp" #include "state/planet.hpp" +#include "state/trace.hpp" +#include "state/player.hpp" +#include "state/ship.hpp" +#include "state/missile.hpp" namespace endofthejedi { diff --git a/game/state/state.cpp b/game/state/state.cpp index acce65c..d84364d 100644 --- a/game/state/state.cpp +++ b/game/state/state.cpp @@ -45,9 +45,7 @@ namespace game { } } while(glm::length(pos) < 0.2 && tries++ < 1000); - pos.x *= 10; - pos.y *= 10; - planets.push_back(new Planet(pos, (0.03 + 0.07*util::randf_0_1()) * 10)); + planets.push_back(new Planet(pos, 0.03 + 0.07*util::randf_0_1())); } } From ed3990710e2f22278646962dfb78275818145eb6 Mon Sep 17 00:00:00 2001 From: end Date: Wed, 28 Sep 2016 07:03:29 +0200 Subject: [PATCH 2/4] * refactored --- game/CMakeLists.txt | 4 ++ game/game_window.hpp | 77 ++-------------------------- game/{main.fs => raycaster.fs} | 0 game/{main.vs => raycaster.vs} | 0 game/renderer.cpp | 92 ---------------------------------- game/renderer.hpp | 15 +----- game/renderer_shader.cpp | 75 +++++++++++++++++++++++++++ game/renderer_shader.hpp | 30 +++++++++++ game/renderer_simple.cpp | 79 +++++++++++++++++++++++++++++ game/renderer_simple.hpp | 33 ++++++++++++ 10 files changed, 226 insertions(+), 179 deletions(-) rename game/{main.fs => raycaster.fs} (100%) rename game/{main.vs => raycaster.vs} (100%) create mode 100644 game/renderer_shader.cpp create mode 100644 game/renderer_shader.hpp create mode 100644 game/renderer_simple.cpp create mode 100644 game/renderer_simple.hpp diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 627b003..67251b1 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -10,6 +10,8 @@ set(GAME_SRC glclasses.cpp renderer.cpp game_window.cpp + renderer_simple.cpp + renderer_shader.cpp util.cpp game.cpp @@ -28,6 +30,8 @@ set(GAME_HEADERS opengl.hpp glclasses.hpp renderer.hpp + renderer_simple.hpp + renderer_shader.hpp ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/game/game_window.hpp b/game/game_window.hpp index 475dd4c..39abb46 100644 --- a/game/game_window.hpp +++ b/game/game_window.hpp @@ -2,21 +2,15 @@ #include "opengl.hpp" #include "renderer.hpp" +#include "renderer_simple.hpp" +#include "renderer_shader.hpp" #include "game.hpp" -#include "state/trace.hpp" -#include "state/object.hpp" -#include "state/missile.hpp" -#include "state/player.hpp" -#include "state/planet.hpp" -#include "state/ship.hpp" -#include "state/explosion.hpp" - class GameWindow : public endofthejedi::GLWindow { private: Game m_game; - endofthejedi::Renderer m_renderer; + endofthejedi::RendererSimple m_renderer; protected: void init() override { @@ -41,77 +35,12 @@ class GameWindow : public endofthejedi::GLWindow { } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - /* - for (const game::Planet *planet : m_game.state()->planets) { - drawPlanet(planet->position, planet->radius); - } - for (const game::Trace *trace : m_game.state()->traces) { - drawTrace(trace); - } - - for (const game::Explosion *explosion : m_game.state()->explosions) { - drawExplosion(explosion); - } - - for (const game::Ship *ship : m_game.state()->ships) { - drawShip(ship->position); - } - - for (const game::Player *player : m_game.state()->players) { - for (const game::Missile *missile : player->missiles) { - drawMissile(missile->position); - } - } - */ m_renderer.render(m_game.state()); } void resize() override { glViewport(0, 0, getwidth(), getheight()); } - void drawShip(const glm::vec2 &pos) { - // std::cout<<"draw ship @ " << pos.x << ", " << pos.y << std::endl; - glm::vec3 color = glm::vec3(0.2, 1.0, 0.3); - - float radius = m_game.state()->shipRadius(); - - m_renderer.drawCircle(pos.x, pos.y, radius, color.x, color.y, color.z, - 12); - } - - void drawPlanet(const glm::vec2 &pos, float radius) { - glm::vec3 color = glm::vec3(0.7, 0.1, 0.2); - - // std::cout<<"draw planet @ " << pos.x << ", " << pos.y << std::endl; - m_renderer.drawCircle(pos.x, pos.y, radius, color.x, color.y, color.z, - 32); - } - - void drawMissile(const glm::vec2 &pos) { - glm::vec3 color = glm::vec3(1.0, 1.0, 0.3); - m_renderer.drawCircle(pos.x, pos.y, 0.01, color.x, color.y, color.z, 6); - } - - void drawTrace(const game::Trace *trace) { - for (const game::Trace::TracePoint &p : trace->points) { - glm::vec3 color = - glm::vec3(0.1, 0.3, 1.0) / (1.0f + 500.0f * p.speed); - m_renderer.drawCircle(p.position.x, p.position.y, 0.005, color.x, - color.y, color.z, 3); - } - } - - void drawExplosion(const game::Explosion *explosion) { - // TODO: transparent - // TODO: with glow in the middle - float r = explosion->maxRadius * (explosion->age / explosion->maxAge); - - // TODO: transparency? - glm::vec3 color = glm::vec3(1.0, 0.9, 0.1); - m_renderer.drawCircle(explosion->position.x, explosion->position.y, r, - color.x, color.y, color.z, 64); - } - public: GameWindow(unsigned int width, unsigned int height) : endofthejedi::GLWindow(width, height) {} diff --git a/game/main.fs b/game/raycaster.fs similarity index 100% rename from game/main.fs rename to game/raycaster.fs diff --git a/game/main.vs b/game/raycaster.vs similarity index 100% rename from game/main.vs rename to game/raycaster.vs diff --git a/game/renderer.cpp b/game/renderer.cpp index 31b6c46..cdc854a 100644 --- a/game/renderer.cpp +++ b/game/renderer.cpp @@ -1,96 +1,4 @@ #include "renderer.hpp" -static const char *vss = -#include "main.vs" - ; -static const char *fss = -#include "main.fs" - ; - -#include -#include "glm/glm.hpp" -#include "glm/vec2.hpp" -#include "glm/vec3.hpp" -#include "glm/gtc/type_ptr.hpp" - -endofthejedi::Renderer::Renderer() { - m_shader.load(vss, GL_VERTEX_SHADER); - m_shader.load(fss, GL_FRAGMENT_SHADER); -} - -endofthejedi::Renderer::~Renderer() {} - void endofthejedi::Renderer::render(const game::State *state) { - m_shader.bind(); - - std::vector positions; - std::vector colors; - std::vector radii; - std::vector reflections; - - for (const game::Planet *planet : state->planets) { - positions.push_back(glm::vec3(planet->position, -5.0f)); - radii.push_back(planet->radius); - colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); - } - - for (const game::Ship *ship : state->ships) { - positions.push_back(glm::vec3(ship->position, -3.0f)); - radii.push_back(ship->radius); - colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); - } - - for (const game::Player *player : state->players) { - for (const game::Missile *missile : player->missiles) { - positions.push_back(glm::vec3(missile->position, -3.0f)); - radii.push_back(0.01f); - colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); - } - } - - for (auto& pos : positions) { - pos.x *= 5; - pos.y *= 5; - } - for (auto& rad : radii) { - rad *= 5; - } - - /* - for (const game::Trace *trace : state->traces) { - positions.push_back(glm::vec3(trace->position, -3.0f)); - radii.push_back(trace->radius); - colors.push_back(glm::vec4(0.0f, 1.0f, 0.0f, 0.5f)); - }*/ - - glUniform1f(m_shader.location("aspectratio"), 1.0f); - glUniform1i(m_shader.location("reflections"), 1); - glUniform3f(m_shader.location("l_position"), 0.6f, 0.1f, 0.0f); - glUniform1f(m_shader.location("l_radius"), 1.0f); - glUniform3fv(m_shader.location("s_positions"), positions.size(), - glm::value_ptr(positions[0])); - glUniform4fv(m_shader.location("s_colors"), colors.size(), - glm::value_ptr(colors[0])); - glUniform1fv(m_shader.location("s_radii"), radii.size(), &radii[0]); - glUniform1i(m_shader.location("s_length"), positions.size()); - - // render fullscreen quad with legacy opengl (too lazy, sorry) - glBegin(GL_QUADS); - glVertex2f(-1.0f, -1.0f); - glVertex2f(1.0f, -1.0f); - glVertex2f(1.0f, 1.0f); - glVertex2f(-1.0f, 1.0f); - glEnd(); -} - -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(); } diff --git a/game/renderer.hpp b/game/renderer.hpp index 36275ae..88c0b45 100644 --- a/game/renderer.hpp +++ b/game/renderer.hpp @@ -5,26 +5,15 @@ #include #include -#include "glclasses.hpp" #include "game.hpp" -#include "state/planet.hpp" -#include "state/trace.hpp" -#include "state/player.hpp" -#include "state/ship.hpp" -#include "state/missile.hpp" namespace endofthejedi { class Renderer { private: - Shader m_shader; - protected: public: - Renderer(); - ~Renderer(); - void render(const game::State* state); - void drawCircle(float x, float y, float radius, float r, float g, float b, - int numSides = 12); + virtual void render(const game::State *state); }; + } diff --git a/game/renderer_shader.cpp b/game/renderer_shader.cpp new file mode 100644 index 0000000..47beaf5 --- /dev/null +++ b/game/renderer_shader.cpp @@ -0,0 +1,75 @@ +#include "renderer_shader.hpp" + +#include +#include "glm/glm.hpp" +#include "glm/vec2.hpp" +#include "glm/vec3.hpp" +#include "glm/gtc/type_ptr.hpp" + +endofthejedi::RendererShader::RendererShader() { + m_shader.load(vss, GL_VERTEX_SHADER); + m_shader.load(fss, GL_FRAGMENT_SHADER); +} + +void endofthejedi::RendererShader::render(const game::State *state) { + m_shader.bind(); + + std::vector positions; + std::vector colors; + std::vector radii; + std::vector reflections; + + for (const game::Planet *planet : state->planets) { + positions.push_back(glm::vec3(planet->position, -5.0f)); + radii.push_back(planet->radius); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + + for (const game::Ship *ship : state->ships) { + positions.push_back(glm::vec3(ship->position, -3.0f)); + radii.push_back(ship->radius); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + + for (const game::Player *player : state->players) { + for (const game::Missile *missile : player->missiles) { + positions.push_back(glm::vec3(missile->position, -3.0f)); + radii.push_back(0.01f); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + } + + for (auto &pos : positions) { + pos.x *= 5; + pos.y *= 5; + } + for (auto &rad : radii) { + rad *= 5; + } + + /* + for (const game::Trace *trace : state->traces) { + positions.push_back(glm::vec3(trace->position, -3.0f)); + radii.push_back(trace->radius); + colors.push_back(glm::vec4(0.0f, 1.0f, 0.0f, 0.5f)); + }*/ + + glUniform1f(m_shader.location("aspectratio"), 1.0f); + glUniform1i(m_shader.location("reflections"), 1); + glUniform3f(m_shader.location("l_position"), 0.6f, 0.1f, 0.0f); + glUniform1f(m_shader.location("l_radius"), 1.0f); + glUniform3fv(m_shader.location("s_positions"), positions.size(), + glm::value_ptr(positions[0])); + glUniform4fv(m_shader.location("s_colors"), colors.size(), + glm::value_ptr(colors[0])); + glUniform1fv(m_shader.location("s_radii"), radii.size(), &radii[0]); + glUniform1i(m_shader.location("s_length"), positions.size()); + + // render fullscreen quad with legacy opengl (too lazy, sorry) + glBegin(GL_QUADS); + glVertex2f(-1.0f, -1.0f); + glVertex2f(1.0f, -1.0f); + glVertex2f(1.0f, 1.0f); + glVertex2f(-1.0f, 1.0f); + glEnd(); +} diff --git a/game/renderer_shader.hpp b/game/renderer_shader.hpp new file mode 100644 index 0000000..2287740 --- /dev/null +++ b/game/renderer_shader.hpp @@ -0,0 +1,30 @@ +#pragma once + +static const char *vss = +#include "raycaster.vs" + ; +static const char *fss = +#include "raycaster.fs" + ; + +#include "renderer.hpp" + +#include "glclasses.hpp" +#include "game.hpp" +#include "state/planet.hpp" +#include "state/trace.hpp" +#include "state/player.hpp" +#include "state/ship.hpp" + +namespace endofthejedi { + + class RendererShader : Renderer { + private: + Shader m_shader; + protected: + public: + RendererShader(); + void render(const game::State *state) override; + }; + +} diff --git a/game/renderer_simple.cpp b/game/renderer_simple.cpp new file mode 100644 index 0000000..2c42c9a --- /dev/null +++ b/game/renderer_simple.cpp @@ -0,0 +1,79 @@ +#include "renderer_simple.hpp" + +void endofthejedi::RendererSimple::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(); +} + +void endofthejedi::RendererSimple::drawShip(const glm::vec2 &pos, + float radius) { + // std::cout<<"draw ship @ " << pos.x << ", " << pos.y << std::endl; + glm::vec3 color = glm::vec3(0.2, 1.0, 0.3); + + drawCircle(pos.x, pos.y, radius, color.x, color.y, color.z, 12); +} + +void endofthejedi::RendererSimple::drawPlanet(const glm::vec2 &pos, + float radius) { + glm::vec3 color = glm::vec3(0.7, 0.1, 0.2); + + // std::cout<<"draw planet @ " << pos.x << ", " << pos.y << std::endl; + drawCircle(pos.x, pos.y, radius, color.x, color.y, color.z, 32); +} + +void endofthejedi::RendererSimple::drawMissile(const glm::vec2 &pos) { + glm::vec3 color = glm::vec3(1.0, 1.0, 0.3); + drawCircle(pos.x, pos.y, 0.01, color.x, color.y, color.z, 6); +} + +void endofthejedi::RendererSimple::drawTrace(const game::Trace *trace) { + for (const game::Trace::TracePoint &p : trace->points) { + glm::vec3 color = glm::vec3(0.1, 0.3, 1.0) / (1.0f + 500.0f * p.speed); + drawCircle(p.position.x, p.position.y, 0.005, color.x, color.y, color.z, + 3); + } +} + +void endofthejedi::RendererSimple::drawExplosion( + const game::Explosion *explosion) { + // TODO: transparent + // TODO: with glow in the middle + float r = explosion->maxRadius * (explosion->age / explosion->maxAge); + + // TODO: transparency? + glm::vec3 color = glm::vec3(1.0, 0.9, 0.1); + drawCircle(explosion->position.x, explosion->position.y, r, color.x, + color.y, color.z, 64); +} + +void endofthejedi::RendererSimple::render(const game::State *state) { + for (const game::Planet *planet : state->planets) { + drawPlanet(planet->position, planet->radius); + } + + for (const game::Trace *trace : state->traces) { + drawTrace(trace); + } + + for (const game::Explosion *explosion : state->explosions) { + drawExplosion(explosion); + } + + for (const game::Ship *ship : state->ships) { + drawShip(ship->position, ship->radius); + } + + for (const game::Player *player : state->players) { + for (const game::Missile *missile : player->missiles) { + drawMissile(missile->position); + } + } +} diff --git a/game/renderer_simple.hpp b/game/renderer_simple.hpp new file mode 100644 index 0000000..b62a650 --- /dev/null +++ b/game/renderer_simple.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "renderer.hpp" + +#include "glclasses.hpp" + +#include "game.hpp" +#include "state/trace.hpp" +#include "state/object.hpp" +#include "state/missile.hpp" +#include "state/player.hpp" +#include "state/planet.hpp" +#include "state/ship.hpp" +#include "state/explosion.hpp" + +namespace endofthejedi { + +class RendererSimple : Renderer { + private: + void drawCircle(float x, float y, float radius, float r, float g, float b, + int numSides = 12); + void drawShip(const glm::vec2 &pos, float radius); + void drawPlanet(const glm::vec2 &pos, float radius); + void drawMissile(const glm::vec2 &pos); + void drawTrace(const game::Trace *trace); + void drawExplosion(const game::Explosion *explosion); + + protected: + public: + void render(const game::State *state) override; +}; + +} From 648d7999c8ec054fd3112b47f8e9c1d6ed3a8a14 Mon Sep 17 00:00:00 2001 From: end Date: Wed, 28 Sep 2016 07:28:18 +0200 Subject: [PATCH 3/4] * fixes --- game/CMakeLists.txt | 2 +- game/game_window.hpp | 14 ++++++++------ game/main.cpp | 2 ++ game/session.hpp | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 69522c0..1c510ab 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -12,7 +12,7 @@ set(GAME_SRC game_window.cpp renderer_simple.cpp renderer_shader.cpp - session.hpp + session.cpp util.cpp game.cpp diff --git a/game/game_window.hpp b/game/game_window.hpp index db36f43..5f741ba 100644 --- a/game/game_window.hpp +++ b/game/game_window.hpp @@ -9,7 +9,7 @@ class GameWindow : public endofthejedi::GLWindow { private: - Game m_game; + Game* m_game; endofthejedi::RendererSimple m_renderer; protected: @@ -29,19 +29,21 @@ class GameWindow : public endofthejedi::GLWindow { // } //} - if (!m_game->cycle(static_cast(time/1000000000.0))) { - std::cout<<"stopping the game..." << std::endl; + if (!m_game->cycle(static_cast(time / 1000000000.0))) { + std::cout << "stopping the game..." << std::endl; stop(); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_renderer.render(m_game.state()); + m_renderer.render(m_game->state()); } void resize() override { glViewport(0, 0, getwidth(), getheight()); } public: - GameWindow(unsigned int width, unsigned int height) - : endofthejedi::GLWindow(width, height) {} + GameWindow(unsigned int width, unsigned int height, Game *ptr) + : endofthejedi::GLWindow(width, height) { + m_game = ptr; + } }; diff --git a/game/main.cpp b/game/main.cpp index 2718363..924fcd0 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -1,3 +1,5 @@ +#define ASIO_STANDALONE + #include #include #include diff --git a/game/session.hpp b/game/session.hpp index 23a8a49..730dc93 100644 --- a/game/session.hpp +++ b/game/session.hpp @@ -1,5 +1,7 @@ #pragma once +#define ASIO_STANDALONE + #include #include #include From 14dc7ff4edcdd86b311a37a81497a5c65aa7bd7b Mon Sep 17 00:00:00 2001 From: end Date: Wed, 28 Sep 2016 07:57:10 +0200 Subject: [PATCH 4/4] * final merge fixes --- game/game_window.hpp | 8 ++++++++ game/opengl.cpp | 8 ++++++++ game/renderer_simple.cpp | 2 +- game/session.cpp | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/game/game_window.hpp b/game/game_window.hpp index 5f741ba..e54f39f 100644 --- a/game/game_window.hpp +++ b/game/game_window.hpp @@ -7,6 +7,14 @@ #include "game.hpp" +#include "state/trace.hpp" +#include "state/object.hpp" +#include "state/missile.hpp" +#include "state/player.hpp" +#include "state/planet.hpp" +#include "state/ship.hpp" +#include "state/explosion.hpp" + class GameWindow : public endofthejedi::GLWindow { private: Game* m_game; diff --git a/game/opengl.cpp b/game/opengl.cpp index f1644de..ee32a5c 100644 --- a/game/opengl.cpp +++ b/game/opengl.cpp @@ -118,6 +118,14 @@ void endofthejedi::GLWindow::poll() { sleeptime = sleeptime - (unsigned int)(sleeptime/1000.0); } } + + clock_gettime(CLOCK_MONOTONIC_RAW, ¤t); + delta = diff(prev, current).tv_nsec; + prev = current; + if(delta > 0.0) { + m_fps = (1000000000.0/delta); + //std::cout << m_fps << "\n"; + } } void endofthejedi::GLWindow::stop() { m_running = false; } diff --git a/game/renderer_simple.cpp b/game/renderer_simple.cpp index 2c42c9a..197001c 100644 --- a/game/renderer_simple.cpp +++ b/game/renderer_simple.cpp @@ -4,9 +4,9 @@ void endofthejedi::RendererSimple::drawCircle(float x, float y, float radius, float r, float g, float b, int numSides) { glBegin(GL_TRIANGLE_FAN); + glColor3f(r, g, b); 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))); } diff --git a/game/session.cpp b/game/session.cpp index 261140b..ef62b5a 100644 --- a/game/session.cpp +++ b/game/session.cpp @@ -1,3 +1,5 @@ +#define ASIO_STANDALONE + #include "session.hpp" #include "game.hpp" #include "state/commands.hpp"