aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/background_image.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-04-15 22:50:28 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:40:52 +0100
commit816030e73aad13c39bc84ca6fdb814ba7131f19f (patch)
treeead3c4c691b3db7f396982327307c5da6ca99855 /src/menu/background_image.cpp
parente0e9997a5e92ce2a31f0ff4d139109be4434105b (diff)
downloadusdx-816030e73aad13c39bc84ca6fdb814ba7131f19f.tar.gz
usdx-816030e73aad13c39bc84ca6fdb814ba7131f19f.tar.xz
usdx-816030e73aad13c39bc84ca6fdb814ba7131f19f.zip
menu/background: backgrounds get to know the parent component
Backgrounds now know the parent control, they are painted in, to query the size. Backgrounds are not allowed to use glClear anymore, should only draw something during the extend of the parent control and should take care to do not modify the opengl cursor position.
Diffstat (limited to 'src/menu/background_image.cpp')
-rw-r--r--src/menu/background_image.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/menu/background_image.cpp b/src/menu/background_image.cpp
index c8d8642c..03836902 100644
--- a/src/menu/background_image.cpp
+++ b/src/menu/background_image.cpp
@@ -25,22 +25,16 @@
*/
#include "background_image.hpp"
+#include "drawable_control.hpp"
namespace usdx
{
- BackgroundImage::BackgroundImage(boost::filesystem::wpath filename)
+ BackgroundImage::BackgroundImage(const DrawableControl &control,
+ boost::filesystem::wpath filename) :
+ Background(control)
{
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;
@@ -53,10 +47,6 @@ namespace usdx
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;
@@ -75,9 +65,14 @@ namespace usdx
void BackgroundImage::draw(void)
{
- glClear(GL_COLOR_BUFFER_BIT);
-
- glLoadIdentity();
+ this->vertices[0] = 0;
+ this->vertices[1] = get_parent().get_height();
+ this->vertices[2] = get_parent().get_width();
+ this->vertices[3] = get_parent().get_height();
+ this->vertices[4] = get_parent().get_width();
+ this->vertices[5] = 0;
+ this->vertices[6] = 0;
+ this->vertices[7] = 0;
glBindTexture(GL_TEXTURE_2D, texture->get_texture());
@@ -85,8 +80,8 @@ namespace usdx
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, color);
+ glVertexPointer(2, GL_INT, 0, vertices);
+ glColorPointer(3, GL_UNSIGNED_BYTE, 0, color);
glTexCoordPointer(2, GL_FLOAT, 0, tex);
glDrawArrays(GL_QUADS, 0, 4);