From 82306827bd8c8b7b0a667df48bd95f5c2948c690 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 7 Sep 2012 04:04:24 +0200 Subject: menu: use RgbColor.get_array(?) magic everywhere --- src/menu/background_color.cpp | 32 ++++---------------------------- src/menu/background_color.hpp | 2 +- src/menu/background_image.cpp | 17 ++--------------- src/menu/background_image.hpp | 3 ++- src/menu/software_mouse_pointer.cpp | 21 ++------------------- src/menu/software_mouse_pointer.hpp | 3 ++- 6 files changed, 13 insertions(+), 65 deletions(-) diff --git a/src/menu/background_color.cpp b/src/menu/background_color.cpp index d0c088fb..f55763b7 100644 --- a/src/menu/background_color.cpp +++ b/src/menu/background_color.cpp @@ -27,39 +27,15 @@ namespace usdx { - BackgroundColor::BackgroundColor(const DrawableControl &control) : - Background(control) + BackgroundColor::BackgroundColor(const DrawableControl &control) + : Background(control), color(0,0,0) { - this->color[0] = 0; - this->color[1] = 0; - this->color[2] = 0; - this->color[3] = 0; - this->color[4] = 0; - this->color[5] = 0; - this->color[6] = 0; - this->color[7] = 0; - this->color[8] = 0; - this->color[9] = 0; - this->color[10] = 0; - this->color[11] = 0; } BackgroundColor::BackgroundColor(const DrawableControl &control, const RgbColor &color) : - Background(control) + Background(control), color(color) { - this->color[0] = color.get_red(); - this->color[1] = color.get_green(); - this->color[2] = color.get_blue(); - this->color[3] = color.get_red(); - this->color[4] = color.get_green(); - this->color[5] = color.get_blue(); - this->color[6] = color.get_red(); - this->color[7] = color.get_green(); - this->color[8] = color.get_blue(); - this->color[9] = color.get_red(); - this->color[10] = color.get_green(); - this->color[11] = color.get_blue(); } void BackgroundColor::draw() @@ -77,7 +53,7 @@ namespace usdx glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_INT, 0, vertices); - glColorPointer(3, GL_UNSIGNED_BYTE, 0, color); + glColorPointer(3, GL_UNSIGNED_BYTE, 0, color.get_array(4)); glDrawArrays(GL_QUADS, 0, 4); diff --git a/src/menu/background_color.hpp b/src/menu/background_color.hpp index f8bc69db..7913fe30 100644 --- a/src/menu/background_color.hpp +++ b/src/menu/background_color.hpp @@ -36,7 +36,7 @@ namespace usdx { private: GLint vertices[8]; - GLubyte color[12]; + RgbColor color; protected: void draw(void); diff --git a/src/menu/background_image.cpp b/src/menu/background_image.cpp index 56cdb1e0..4db81967 100644 --- a/src/menu/background_image.cpp +++ b/src/menu/background_image.cpp @@ -29,23 +29,10 @@ namespace usdx { BackgroundImage::BackgroundImage(const DrawableControl &control, boost::filesystem::wpath filename) : - Background(control) + Background(control), color(255,255,255) { texture = new Texture(filename); - this->color[0] = 255; - this->color[1] = 255; - this->color[2] = 255; - this->color[3] = 255; - this->color[4] = 255; - this->color[5] = 255; - this->color[6] = 255; - this->color[7] = 255; - this->color[8] = 255; - this->color[9] = 255; - this->color[10] = 255; - this->color[11] = 255; - this->tex[0] = 0.0f; this->tex[1] = 1.0f; this->tex[2] = 1.0f; @@ -80,7 +67,7 @@ namespace usdx glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_INT, 0, vertices); - glColorPointer(3, GL_UNSIGNED_BYTE, 0, color); + glColorPointer(3, GL_UNSIGNED_BYTE, 0, color.get_array(4)); glTexCoordPointer(2, GL_FLOAT, 0, tex); glDrawArrays(GL_QUADS, 0, 4); diff --git a/src/menu/background_image.hpp b/src/menu/background_image.hpp index 3ddb7e35..67d117b9 100644 --- a/src/menu/background_image.hpp +++ b/src/menu/background_image.hpp @@ -30,6 +30,7 @@ #include "background.hpp" #include "texture.hpp" +#include "utils/rgb_color.hpp" namespace usdx { @@ -39,7 +40,7 @@ namespace usdx Texture* texture; GLint vertices[8]; - GLubyte color[12]; + RgbColor color; GLfloat tex[8]; protected: diff --git a/src/menu/software_mouse_pointer.cpp b/src/menu/software_mouse_pointer.cpp index 8e42cc25..e9b3b603 100644 --- a/src/menu/software_mouse_pointer.cpp +++ b/src/menu/software_mouse_pointer.cpp @@ -29,7 +29,7 @@ namespace usdx { SoftwareMousePointer::SoftwareMousePointer(Container* parent, EventManager* event_manager) - : DrawableControl(parent) + : DrawableControl(parent), color(255,255,255,100) { fade_inactive = new Timer(this, 2000, true); @@ -42,23 +42,6 @@ namespace usdx this->vertices[6] = 0.0f; this->vertices[7] = 0.0f; - this->color[0] = 255; - this->color[1] = 255; - this->color[2] = 255; - this->color[3] = 100; - this->color[4] = 255; - this->color[5] = 255; - this->color[6] = 255; - this->color[7] = 100; - this->color[8] = 255; - this->color[9] = 255; - this->color[10] = 255; - this->color[11] = 100; - this->color[12] = 255; - this->color[13] = 255; - this->color[14] = 255; - this->color[15] = 100; - this->texture[0] = 0.0f; this->texture[1] = 1.0f; this->texture[2] = 1.0f; @@ -108,7 +91,7 @@ namespace usdx glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_FLOAT, 0, vertices); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, color.get_array(4)); glTexCoordPointer(2, GL_FLOAT, 0, texture); glEnable(GL_BLEND); diff --git a/src/menu/software_mouse_pointer.hpp b/src/menu/software_mouse_pointer.hpp index 29bc2995..bb4db608 100644 --- a/src/menu/software_mouse_pointer.hpp +++ b/src/menu/software_mouse_pointer.hpp @@ -30,6 +30,7 @@ #include "event_manager.hpp" #include "texture.hpp" #include "timer.hpp" +#include "utils/rgba_color.hpp" #include #include @@ -40,8 +41,8 @@ namespace usdx { private: GLfloat vertices[8]; - GLubyte color[16]; GLfloat texture[8]; + RgbaColor color; Texture* texture_normal; Texture* texture_pressed; -- cgit v1.2.3