aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/software_mouse_pointer.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-09-17 01:33:32 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:41:06 +0100
commit11e4937c9f9af5e064ad7434b2e4bf47b5fe31f6 (patch)
tree79390376632122609c710230390c0f4710c3b3e7 /src/menu/software_mouse_pointer.cpp
parent368ff00d125f00e9fcfc536f198697aba79c2d40 (diff)
downloadusdx-11e4937c9f9af5e064ad7434b2e4bf47b5fe31f6.tar.gz
usdx-11e4937c9f9af5e064ad7434b2e4bf47b5fe31f6.tar.xz
usdx-11e4937c9f9af5e064ad7434b2e4bf47b5fe31f6.zip
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.
Diffstat (limited to 'src/menu/software_mouse_pointer.cpp')
-rw-r--r--src/menu/software_mouse_pointer.cpp21
1 files changed, 5 insertions, 16 deletions
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 <GL/gl.h>
#include <iostream>
+#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<Texture>(new Texture("game/themes/Deluxe/interface/cursor.png"));
+ texture_pressed = new Disposer<Texture>(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<Texture> 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)