From 11e4937c9f9af5e064ad7434b2e4bf47b5fe31f6 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 17 Sep 2012 01:33:32 +0200 Subject: menu/texture: implement GlDelayedAllocation interface Textures are now initialized during their first use, destroyed after their last used and could be use with the Activator. --- src/menu/software_mouse_pointer.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/menu/software_mouse_pointer.cpp') diff --git a/src/menu/software_mouse_pointer.cpp b/src/menu/software_mouse_pointer.cpp index e9b3b603..a3594479 100644 --- a/src/menu/software_mouse_pointer.cpp +++ b/src/menu/software_mouse_pointer.cpp @@ -25,6 +25,7 @@ #include "software_mouse_pointer.hpp" #include #include +#include "utils/activator.hpp" namespace usdx { @@ -42,20 +43,11 @@ namespace usdx this->vertices[6] = 0.0f; this->vertices[7] = 0.0f; - this->texture[0] = 0.0f; - this->texture[1] = 1.0f; - this->texture[2] = 1.0f; - this->texture[3] = 1.0f; - this->texture[4] = 1.0f; - this->texture[5] = 0.0f; - this->texture[6] = 0.0f; - this->texture[7] = 0.0f; - set_position(0, 0); set_size(40, 40); - texture_normal = new Texture("game/themes/Deluxe/interface/cursor.png"); - texture_pressed = new Texture("game/themes/Deluxe/interface/cursor_pressed.png"); + texture_normal = new Disposer(new Texture("game/themes/Deluxe/interface/cursor.png")); + texture_pressed = new Disposer(new Texture("game/themes/Deluxe/interface/cursor_pressed.png")); mouse_move_connection = event_manager->mouse_move.connect( boost::bind(&SoftwareMousePointer::on_mouse_move, this, _1, _2)); @@ -83,8 +75,7 @@ namespace usdx return; } - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture_normal->get_texture()); + Activator a(texture_normal->get()); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -92,7 +83,7 @@ namespace usdx glVertexPointer(2, GL_FLOAT, 0, vertices); glColorPointer(4, GL_UNSIGNED_BYTE, 0, color.get_array(4)); - glTexCoordPointer(2, GL_FLOAT, 0, texture); + glTexCoordPointer(2, GL_FLOAT, 0, Texture::default_vertices); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -104,8 +95,6 @@ namespace usdx glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - - glDisable(GL_TEXTURE_2D); } void SoftwareMousePointer::on_mouse_move(int x, int y) -- cgit v1.2.3