From e0e9997a5e92ce2a31f0ff4d139109be4434105b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 11 Apr 2012 21:19:48 +0200 Subject: menu: generalized frame_background to background background could now be a background for all DrawableControl instances each subclass should call the parents draw() during executing the draw() method for background painting TODO: background should know the size of the control to only draw the background there --- src/frames/loading_frame.cpp | 8 +-- src/menu/background.hpp | 50 +++++++++++++++++++ src/menu/background_color.cpp | 47 ++++++++++++++++++ src/menu/background_color.hpp | 51 +++++++++++++++++++ src/menu/background_image.cpp | 98 +++++++++++++++++++++++++++++++++++++ src/menu/background_image.hpp | 57 +++++++++++++++++++++ src/menu/container.cpp | 2 + src/menu/drawable_control.cpp | 34 ++++++++++++- src/menu/drawable_control.hpp | 9 ++++ src/menu/frame.cpp | 34 ++----------- src/menu/frame.hpp | 11 +---- src/menu/frame_background.cpp | 38 -------------- src/menu/frame_background.hpp | 51 ------------------- src/menu/frame_background_color.cpp | 47 ------------------ src/menu/frame_background_color.hpp | 51 ------------------- src/menu/frame_background_image.cpp | 98 ------------------------------------- src/menu/frame_background_image.hpp | 57 --------------------- src/menu/text.cpp | 2 + 18 files changed, 357 insertions(+), 388 deletions(-) create mode 100644 src/menu/background.hpp create mode 100644 src/menu/background_color.cpp create mode 100644 src/menu/background_color.hpp create mode 100644 src/menu/background_image.cpp create mode 100644 src/menu/background_image.hpp delete mode 100644 src/menu/frame_background.cpp delete mode 100644 src/menu/frame_background.hpp delete mode 100644 src/menu/frame_background_color.cpp delete mode 100644 src/menu/frame_background_color.hpp delete mode 100644 src/menu/frame_background_image.cpp delete mode 100644 src/menu/frame_background_image.hpp (limited to 'src') diff --git a/src/frames/loading_frame.cpp b/src/frames/loading_frame.cpp index 31458b7f..ef05bd48 100644 --- a/src/frames/loading_frame.cpp +++ b/src/frames/loading_frame.cpp @@ -25,8 +25,8 @@ */ #include "loading_frame.hpp" -#include "menu/frame_background_image.hpp" -#include "menu/frame_background_color.hpp" +#include "menu/background_image.hpp" +#include "menu/background_color.hpp" #include "menu/text.hpp" namespace usdx @@ -38,8 +38,8 @@ namespace usdx Frame(app) { // RgbColor background(100, 100, 100); -// set_background(new FrameBackgroundColor(background)); - set_background(new FrameBackgroundImage("game/themes/Deluxe/[bg-load]blue.jpg")); +// set_background(new BackgroundColor(background)); + set_background(new BackgroundImage("game/themes/Deluxe/[bg-load]blue.jpg")); DrawableControl *c = new Text(this, "Halloäöüß"); c->set_position(100, 100); diff --git a/src/menu/background.hpp b/src/menu/background.hpp new file mode 100644 index 00000000..4f997700 --- /dev/null +++ b/src/menu/background.hpp @@ -0,0 +1,50 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef BACKGROUND_HPP +#define BACKGROUND_HPP + +#include "drawable.hpp" + +namespace usdx +{ + // Background - abstract class for Backgrounds + class Background : public Drawable + { + public: + virtual ~Background() {}; + + protected: + // abstract base class + Background() {}; + + // no copy and no assignment + Background(const Background&); + Background& operator=(const Background&); + }; +}; + +#endif diff --git a/src/menu/background_color.cpp b/src/menu/background_color.cpp new file mode 100644 index 00000000..aa8a90d2 --- /dev/null +++ b/src/menu/background_color.cpp @@ -0,0 +1,47 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#include "background_color.hpp" +#include + +namespace usdx +{ + BackgroundColor::BackgroundColor(RgbColor &color) : + color(color) + { + } + + BackgroundColor::BackgroundColor(void) : + color(0, 0, 0) + { + } + + void BackgroundColor::draw() + { + glClearColor(color.get_red(), color.get_green(), color.get_blue(), 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } +}; diff --git a/src/menu/background_color.hpp b/src/menu/background_color.hpp new file mode 100644 index 00000000..d91edcdf --- /dev/null +++ b/src/menu/background_color.hpp @@ -0,0 +1,51 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef BACKGROUND_COLOR_HPP +#define BACKGROUND_COLOR_HPP + +#include "background.hpp" +#include "utils/rgb_color.hpp" + +namespace usdx +{ + class BackgroundColor : public Background + { + private: + RgbColor color; + + protected: + void draw(void); + + public: + BackgroundColor(void); + BackgroundColor(RgbColor &color); + + }; +}; + + +#endif diff --git a/src/menu/background_image.cpp b/src/menu/background_image.cpp new file mode 100644 index 00000000..c8d8642c --- /dev/null +++ b/src/menu/background_image.cpp @@ -0,0 +1,98 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#include "background_image.hpp" + +namespace usdx +{ + BackgroundImage::BackgroundImage(boost::filesystem::wpath filename) + { + texture = new Texture(filename); + + this->vertices[0] = 0.0f; + this->vertices[1] = 600.0f; + this->vertices[2] = 800.0f; + this->vertices[3] = 600.0f; + this->vertices[4] = 800.0f; + this->vertices[5] = 0.0f; + 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] = 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->color[12] = 255; + this->color[13] = 255; + this->color[14] = 255; + this->color[15] = 255; + + this->tex[0] = 0.0f; + this->tex[1] = 1.0f; + this->tex[2] = 1.0f; + this->tex[3] = 1.0f; + this->tex[4] = 1.0f; + this->tex[5] = 0.0f; + this->tex[6] = 0.0f; + this->tex[7] = 0.0f; + } + + BackgroundImage::~BackgroundImage() + { + delete texture; + } + + void BackgroundImage::draw(void) + { + glClear(GL_COLOR_BUFFER_BIT); + + glLoadIdentity(); + + glBindTexture(GL_TEXTURE_2D, texture->get_texture()); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glVertexPointer(2, GL_FLOAT, 0, vertices); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); + glTexCoordPointer(2, GL_FLOAT, 0, tex); + + glDrawArrays(GL_QUADS, 0, 4); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +}; diff --git a/src/menu/background_image.hpp b/src/menu/background_image.hpp new file mode 100644 index 00000000..7c0549bf --- /dev/null +++ b/src/menu/background_image.hpp @@ -0,0 +1,57 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef BACKGROUND_IMAGE_HPP +#define BACKGROUND_IMAGE_HPP + +#include +#include + +#include "background.hpp" +#include "texture.hpp" + +namespace usdx +{ + class BackgroundImage : public Background + { + private: + Texture* texture; + + GLfloat vertices[8]; + GLubyte color[16]; + GLfloat tex[8]; + + protected: + void draw(void); + + public: + BackgroundImage(boost::filesystem::wpath filename); + virtual ~BackgroundImage(); + }; +}; + + +#endif diff --git a/src/menu/container.cpp b/src/menu/container.cpp index bf742dff..8c267819 100644 --- a/src/menu/container.cpp +++ b/src/menu/container.cpp @@ -58,6 +58,8 @@ namespace usdx void Container::draw(void) { + DrawableControl::draw(); + if (frame) { frame->repaint(); } diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp index 9d00d3f1..a0b4ad27 100644 --- a/src/menu/drawable_control.cpp +++ b/src/menu/drawable_control.cpp @@ -37,7 +37,8 @@ namespace usdx DrawableControl::DrawableControl(Container* parent) : Control(parent), position(0, 0), size(0, 0), - clipping_required(false), parent(parent) + clipping_required(false), background(NULL), + parent(parent) { ContainerHelper(this).add(parent); } @@ -45,7 +46,8 @@ namespace usdx DrawableControl::DrawableControl(Container* parent, const ContainerHelper& helper) : Control(parent), position(0, 0), size(0, 0), - clipping_required(false), parent(parent) + clipping_required(false), background(NULL), + parent(parent) { helper.add(parent); } @@ -53,6 +55,11 @@ namespace usdx DrawableControl::~DrawableControl() { remove_parent(); + + if (background) { + delete background; + background = NULL; + } } bool DrawableControl::get_clipping_required(void) const @@ -66,6 +73,14 @@ namespace usdx clipping_required = value; } + void DrawableControl::draw(void) + { + boost::mutex::scoped_lock lock(background_mutex); + if (background) { + background->repaint(); + } + } + void DrawableControl::repaint(void) { { @@ -164,4 +179,19 @@ namespace usdx c->add(self); } } + + void DrawableControl::set_background(Background* background) + { + boost::mutex::scoped_lock lock(background_mutex); + if (this->background) { + delete this->background; + } + + this->background = background; + } + + const Background* DrawableControl::get_background(void) const + { + return background; + } }; diff --git a/src/menu/drawable_control.hpp b/src/menu/drawable_control.hpp index 261f0514..fa1fdd4d 100644 --- a/src/menu/drawable_control.hpp +++ b/src/menu/drawable_control.hpp @@ -35,6 +35,7 @@ #include "control.hpp" #include "utils/point.hpp" #include "utils/dimension.hpp" +#include "background.hpp" namespace usdx { @@ -50,9 +51,12 @@ namespace usdx bool clipping_required; + Background* background; + boost::mutex position_mutex; boost::mutex size_mutex; boost::mutex clipping_required_mutex; + boost::mutex background_mutex; protected: Container* parent; @@ -71,6 +75,8 @@ namespace usdx bool get_clipping_required(void) const; void set_clipping_required(const bool); + virtual void draw(void); + public: DrawableControl(Container*); virtual ~DrawableControl(); @@ -92,6 +98,9 @@ namespace usdx int get_height(void) const; void remove_parent(void); + + void set_background(Background*); + const Background* get_background(void) const; }; }; diff --git a/src/menu/frame.cpp b/src/menu/frame.cpp index cbf073f5..ae529444 100644 --- a/src/menu/frame.cpp +++ b/src/menu/frame.cpp @@ -32,12 +32,12 @@ namespace usdx log4cpp::Category::getInstance("usdx.menu.frame"); Frame::Frame(Container* parent) - : Container(parent, FrameContainerHelper(this)), background(NULL) + : Container(parent, FrameContainerHelper(this)) { } - Frame::Frame(Container* parent, FrameBackground* background) - : Container(parent, FrameContainerHelper(this)), background(background) + Frame::Frame(Container* parent, Background* background) + : Container(parent, FrameContainerHelper(this)) { } @@ -47,34 +47,6 @@ namespace usdx parent->removeFrame(); parent = NULL; } - - if (background) { - delete background; - background = NULL; - } - } - - void Frame::set_background(FrameBackground* background) - { - if (this->background) { - delete this->background; - } - - this->background = background; - } - - const FrameBackground* Frame::get_background(void) const - { - return background; - } - - void Frame::draw(void) - { - if (background) { - background->repaint(); - } - - Container::draw(); } Frame::FrameContainerHelper::FrameContainerHelper(Frame* self) : diff --git a/src/menu/frame.hpp b/src/menu/frame.hpp index 7b2e315a..eeeee4e1 100644 --- a/src/menu/frame.hpp +++ b/src/menu/frame.hpp @@ -31,7 +31,7 @@ #include #include "container.hpp" -#include "frame_background.hpp" +#include "background.hpp" namespace usdx { @@ -39,7 +39,6 @@ namespace usdx { private: static log4cpp::Category& log; - FrameBackground* background; protected: class FrameContainerHelper : public ContainerHelper @@ -52,17 +51,11 @@ namespace usdx virtual void add(Container*) const; }; - virtual void draw(void); - public: Frame(Container*); - Frame(Container*, FrameBackground*); + Frame(Container*, Background*); virtual ~Frame(); - - void set_background(FrameBackground* background); - - const FrameBackground* get_background() const; }; }; diff --git a/src/menu/frame_background.cpp b/src/menu/frame_background.cpp deleted file mode 100644 index 5c18cf45..00000000 --- a/src/menu/frame_background.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "frame_background.hpp" - -namespace usdx -{ - FrameBackground::FrameBackground() - { - } - - FrameBackground::~FrameBackground() - { - } -}; diff --git a/src/menu/frame_background.hpp b/src/menu/frame_background.hpp deleted file mode 100644 index 9cb7c504..00000000 --- a/src/menu/frame_background.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef FRAME_BACKGROUND_HPP -#define FRAME_BACKGROUND_HPP - -#include "drawable.hpp" - -namespace usdx -{ - // Exception - class FrameBackgroundException { }; - - // FrameBackground - abstract class for FrameBackgrounds - class FrameBackground : public Drawable - { - public: - FrameBackground(); - virtual ~FrameBackground(); - - protected: - // no copy and no assignment - FrameBackground(const FrameBackground&); - FrameBackground& operator=(const FrameBackground&); - }; -}; - -#endif diff --git a/src/menu/frame_background_color.cpp b/src/menu/frame_background_color.cpp deleted file mode 100644 index a0558082..00000000 --- a/src/menu/frame_background_color.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "frame_background_color.hpp" -#include - -namespace usdx -{ - FrameBackgroundColor::FrameBackgroundColor(RgbColor &color) : - color(color) - { - } - - FrameBackgroundColor::FrameBackgroundColor(void) : - color(0, 0, 0) - { - } - - void FrameBackgroundColor::draw() - { - glClearColor(color.get_red(), color.get_green(), color.get_blue(), 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - } -}; diff --git a/src/menu/frame_background_color.hpp b/src/menu/frame_background_color.hpp deleted file mode 100644 index 2e850d2c..00000000 --- a/src/menu/frame_background_color.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef FRAME_BACKGROUND_COLOR_HPP -#define FRAME_BACKGROUND_COLOR_HPP - -#include "frame_background.hpp" -#include "utils/rgb_color.hpp" - -namespace usdx -{ - class FrameBackgroundColor : public FrameBackground - { - private: - RgbColor color; - - protected: - void draw(void); - - public: - FrameBackgroundColor(void); - FrameBackgroundColor(RgbColor &color); - - }; -}; - - -#endif diff --git a/src/menu/frame_background_image.cpp b/src/menu/frame_background_image.cpp deleted file mode 100644 index 893d573c..00000000 --- a/src/menu/frame_background_image.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "frame_background_image.hpp" - -namespace usdx -{ - FrameBackgroundImage::FrameBackgroundImage(boost::filesystem::wpath filename) - { - texture = new Texture(filename); - - this->vertices[0] = 0.0f; - this->vertices[1] = 600.0f; - this->vertices[2] = 800.0f; - this->vertices[3] = 600.0f; - this->vertices[4] = 800.0f; - this->vertices[5] = 0.0f; - 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] = 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->color[12] = 255; - this->color[13] = 255; - this->color[14] = 255; - this->color[15] = 255; - - this->tex[0] = 0.0f; - this->tex[1] = 1.0f; - this->tex[2] = 1.0f; - this->tex[3] = 1.0f; - this->tex[4] = 1.0f; - this->tex[5] = 0.0f; - this->tex[6] = 0.0f; - this->tex[7] = 0.0f; - } - - FrameBackgroundImage::~FrameBackgroundImage() - { - delete texture; - } - - void FrameBackgroundImage::draw(void) - { - glClear(GL_COLOR_BUFFER_BIT); - - glLoadIdentity(); - - glBindTexture(GL_TEXTURE_2D, texture->get_texture()); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - glVertexPointer(2, GL_FLOAT, 0, vertices); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, color); - glTexCoordPointer(2, GL_FLOAT, 0, tex); - - glDrawArrays(GL_QUADS, 0, 4); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - } -}; diff --git a/src/menu/frame_background_image.hpp b/src/menu/frame_background_image.hpp deleted file mode 100644 index 5aaa58b6..00000000 --- a/src/menu/frame_background_image.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * UltraStar Deluxe - Karaoke Game - * - * UltraStar Deluxe is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef FRAME_BACKGROUND_IMAGE_HPP -#define FRAME_BACKGROUND_IMAGE_HPP - -#include -#include - -#include "frame_background.hpp" -#include "texture.hpp" - -namespace usdx -{ - class FrameBackgroundImage : public FrameBackground - { - private: - Texture* texture; - - GLfloat vertices[8]; - GLubyte color[16]; - GLfloat tex[8]; - - protected: - void draw(void); - - public: - FrameBackgroundImage(boost::filesystem::wpath filename); - virtual ~FrameBackgroundImage(); - }; -}; - - -#endif diff --git a/src/menu/text.cpp b/src/menu/text.cpp index 96c22626..aa4a3195 100644 --- a/src/menu/text.cpp +++ b/src/menu/text.cpp @@ -79,6 +79,8 @@ namespace usdx void Text::draw(void) { + DrawableControl::draw(); + boost::mutex::scoped_lock lock(font_mutex); glTranslatef(offset.get_x(), offset.get_y(), 0.0f); -- cgit v1.2.3