diff options
Diffstat (limited to 'src/menu/background_image.cpp')
-rw-r--r-- | src/menu/background_image.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/menu/background_image.cpp b/src/menu/background_image.cpp index 4db81967..15229284 100644 --- a/src/menu/background_image.cpp +++ b/src/menu/background_image.cpp @@ -24,6 +24,7 @@ #include "background_image.hpp" #include "drawable_control.hpp" +#include "utils/activator.hpp" namespace usdx { @@ -31,21 +32,16 @@ namespace usdx boost::filesystem::wpath filename) : Background(control), color(255,255,255) { - texture = new Texture(filename); - - 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; + texture = new Disposer<Texture>(new Texture(filename)); } BackgroundImage::~BackgroundImage() { - delete texture; + if (texture != NULL) { + delete texture; + texture = NULL; + } + } } void BackgroundImage::draw(void) @@ -59,8 +55,7 @@ namespace usdx this->vertices[6] = 0; this->vertices[7] = 0; - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture->get_texture()); + Activator<Texture> t(texture->get()); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -68,14 +63,12 @@ namespace usdx glVertexPointer(2, GL_INT, 0, vertices); glColorPointer(3, GL_UNSIGNED_BYTE, 0, color.get_array(4)); - glTexCoordPointer(2, GL_FLOAT, 0, tex); + glTexCoordPointer(2, GL_FLOAT, 0, Texture::default_vertices); glDrawArrays(GL_QUADS, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - - glDisable(GL_TEXTURE_2D); } }; |