diff --git a/include/colour.h b/include/colour.h new file mode 100644 index 0000000000000000000000000000000000000000..8f1f23ca34a55ed34dd8408f0357ee9d4a865763 --- /dev/null +++ b/include/colour.h @@ -0,0 +1,23 @@ +#ifndef __COLOUR_H__ +#define __COLOUR_H__ + +#include <cstdint>; + +struct RGBA{ + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; +}; + +class Colour +{ + public: + Colour( uint8_t r, uint8_t g, uint8_t b, uint8_t a ); + ~Colour(); + private: + RGBA _col; + +}; + +#endif //__COLOUR_H__ \ No newline at end of file diff --git a/include/window.h b/include/window.h index 79707801866482a93e65620d1c0f43aee1de44f1..75c3b8539cf00c47bb9c57b567530da5546adf7a 100644 --- a/include/window.h +++ b/include/window.h @@ -9,6 +9,7 @@ #include <cstring> #include <string> #include "logger.h" +#include "colour.h" #include "maths/vec2.h" #include "components/cTexture.h" @@ -33,6 +34,8 @@ class Window public: static SDL_Renderer* renderer; static bool sdlIsInit; + static RGBA KeyColour; + static RGBA RenderColour; Window(); ~Window(); @@ -58,6 +61,7 @@ class Window cTexture* _textureSprite; SDL_Rect _sprites[4]; + SDL_Renderer* _renderer; SDL_Surface* _screenSurface; SDL_Surface* _renderSurface; diff --git a/src/colour.cpp b/src/colour.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75bf78dcb175b04a623ba259c39120da89710e9a --- /dev/null +++ b/src/colour.cpp @@ -0,0 +1,7 @@ +#include "colour.h" + +Colour::Colour( uint8_t r, uint8_t g, uint8_t b, uint8_t a ) + : _col( {r,g,b,a} ) +{} +Colour::~Colour() +{} \ No newline at end of file diff --git a/src/window.cpp b/src/window.cpp index 810c82c41ab2cce93430f72035c7ba756abeb2cd..82652ec01e72b1c1e2c1d6872767d4a3393120c4 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2,6 +2,8 @@ bool Window::sdlIsInit = false; SDL_Renderer* Window::renderer = NULL; +RGBA Window::KeyColour = { 0xFF, 0x00, 0xFF, 0xFF }; +RGBA Window::RenderColour = { 0xFF, 0xFF, 0xFF, 0xFF }; Window::Window() : _logger( Logger::instance() ), _hasInit( false ) @@ -114,7 +116,13 @@ void Window::loadMedia( std::string path ) } void Window::update() { - SDL_SetRenderDrawColor( this->_renderer, 0xFF, 0xFF, 0xFF, 0xFF ); + SDL_SetRenderDrawColor( + this->_renderer, + Window::RenderColour.r, + Window::RenderColour.g, + Window::RenderColour.b, + Window::RenderColour.a + ); SDL_RenderClear( this->_renderer ); SDL_Rect bg = this->_createViewport( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); @@ -223,7 +231,13 @@ void Window::spawn() { printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() ); } else { - SDL_SetRenderDrawColor( this->_renderer, 0xFF, 0x00, 0xFF, 0xFF ); + SDL_SetRenderDrawColor( + this->_renderer, + Window::RenderColour.r, + Window::RenderColour.g, + Window::RenderColour.b, + Window::RenderColour.a + ); } Window::renderer = this->_renderer; } else {