diff --git a/client/src/gfx/shape_renderer.cpp b/client/src/gfx/shape_renderer.cpp index 1f36d85..a61f0f4 100644 --- a/client/src/gfx/shape_renderer.cpp +++ b/client/src/gfx/shape_renderer.cpp @@ -54,9 +54,9 @@ ShapeRenderer::~ShapeRenderer(void) { delete _shape_shader; } -void ShapeRenderer::draw_rect(int x, int y, int width, int height, float color[3]) { +void ShapeRenderer::draw_rect(int x, int y, int width, int height, const Color& color) { _shape_shader->use(); - _shape_shader->set_vec3("objectColor", color[0], color[1], color[2]); + _shape_shader->set_vec3("objectColor", color.r, color.g, color.b); float x_f = (float)x; float y_f = (float)y; diff --git a/client/src/gfx/shape_renderer.h b/client/src/gfx/shape_renderer.h index eb0ec52..1cdfc3f 100644 --- a/client/src/gfx/shape_renderer.h +++ b/client/src/gfx/shape_renderer.h @@ -1,13 +1,14 @@ #pragma once #include "shader.h" +#include "types.h" class ShapeRenderer { public: ShapeRenderer(unsigned int screen_width, unsigned int screen_height); ~ShapeRenderer(void); - void draw_rect(int x, int y, int width, int height, float color[3]); + void draw_rect(int x, int y, int width, int height, const Color& color); private: Shader* _shape_shader; diff --git a/client/src/gfx/txt_renderer.cpp b/client/src/gfx/txt_renderer.cpp index 9b48579..191540e 100644 --- a/client/src/gfx/txt_renderer.cpp +++ b/client/src/gfx/txt_renderer.cpp @@ -1,4 +1,5 @@ #include +#include "gfx/types.h" #include #include #include @@ -106,9 +107,9 @@ void TextRenderer::load_font(const char* font_path, unsigned int font_size) { } void TextRenderer::render_text(const char* text, float x, float y, float scale, - float color[3]) { + const Color& color) { _txt_shader->use(); - _txt_shader->set_vec3("textColor", color[0], color[1], color[2]); + _txt_shader->set_vec3("textColor", color.r, color.g, color.b); glActiveTexture(GL_TEXTURE0); glBindVertexArray(_vao); diff --git a/client/src/gfx/txt_renderer.h b/client/src/gfx/txt_renderer.h index 531585e..c731e1c 100644 --- a/client/src/gfx/txt_renderer.h +++ b/client/src/gfx/txt_renderer.h @@ -5,6 +5,7 @@ #include #include "shader.h" +#include "types.h" /* State of a single charactrer glyph. */ struct character { @@ -20,7 +21,7 @@ public: ~TextRenderer(void); void load_font(const char* font_path, unsigned int font_size); - void render_text(const char* text, float x, float y, float scale, float color[3]); + void render_text(const char* text, float x, float y, float scale, const Color& color); private: Shader* _txt_shader; diff --git a/client/src/gfx/types.h b/client/src/gfx/types.h new file mode 100644 index 0000000..8362cc6 --- /dev/null +++ b/client/src/gfx/types.h @@ -0,0 +1,9 @@ +#pragma once + +struct Color { + float r, g, b; +}; + +struct Rect { + int x, y, w, h; +}; diff --git a/client/src/terminal.cpp b/client/src/terminal.cpp index 3fa6084..e6cc525 100644 --- a/client/src/terminal.cpp +++ b/client/src/terminal.cpp @@ -6,6 +6,7 @@ #include "terminal.h" #include "client_network.h" #include "gfx/txt_renderer.h" +#include "gfx/types.h" Terminal::Terminal(ClientNetwork* network) : _network(network) { /* Placeholder welcome message to history. */ @@ -103,8 +104,8 @@ void Terminal::scroll(int amount, int win_content_height) { void Terminal::render(TextRenderer* renderer, int x, int y, int width, int height, bool show_cursor) { - float white[] = { 1.0f, 1.0f, 1.0f }; - float green[] = { 0.2f, 1.0f, 0.2f }; + const Color white = { 1.0f, 1.0f, 1.0f }; + const Color green = { 0.2f, 1.0f, 0.2f }; float line_height = 20.0f; float padding = 5.0f; diff --git a/client/src/ui/ui_window.cpp b/client/src/ui/ui_window.cpp index 11a3cc1..794964b 100644 --- a/client/src/ui/ui_window.cpp +++ b/client/src/ui/ui_window.cpp @@ -3,6 +3,7 @@ #include #include "gfx/shape_renderer.h" #include "gfx/txt_renderer.h" +#include "gfx/types.h" UIWindow::UIWindow(const char* title, int x, int y, int width, int height) { _title = title; @@ -40,10 +41,10 @@ void UIWindow::render(ShapeRenderer* shape_renderer, TextRenderer* txt_renderer, int title_bar_height = 30; /* Define colours. */ - float frame_color[] = { 0.2f, 0.2f, 0.25f }; - float title_bar_color[] = { 0.15f, 0.15f, 0.2f }; - float focused_title_bar_color[] = { 0.3f, 0.3f, 0.4f }; - float title_text_color[] = { 0.9f, 0.9f, 0.9f }; + const Color frame_color = { 0.2f, 0.2f, 0.25f }; + const Color title_bar_color = { 0.15f, 0.15f, 0.2f }; + const Color focused_title_bar_color = { 0.3f, 0.3f, 0.4f }; + const Color title_text_color = { 0.9f, 0.9f, 0.9f }; /* Convert top-left coords to bottom-left for OpenGL. */ int y_gl = screen_height - _y - _height; diff --git a/server/src/network_manager.cpp b/server/src/network_manager.cpp index ce28644..d25fd62 100644 --- a/server/src/network_manager.cpp +++ b/server/src/network_manager.cpp @@ -5,7 +5,6 @@ #include "network_manager.h" -/* TODO: Re-implement. */ #include "asio/error_code.hpp" #include "asio/ip/tcp.hpp" #include "command_processor.h"