aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/texture.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/texture.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/texture.cpp')
-rw-r--r--src/menu/texture.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/menu/texture.cpp b/src/menu/texture.cpp
index bae6dc2c..4ad0c39e 100644
--- a/src/menu/texture.cpp
+++ b/src/menu/texture.cpp
@@ -29,13 +29,24 @@ namespace usdx
log4cpp::Category& Texture::log =
log4cpp::Category::getInstance("usdx.base.texture");
+ const GLfloat Texture::default_vertices[] = { 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f };
+
Texture::Texture(boost::filesystem::wpath filename) :
filename(filename), texture(0), size(0, 0), rotation(0)
{
- Image image(filename);
+ }
- size.set_width(image.get_surface()->w);
- size.set_height(image.get_surface()->h);
+ Texture::~Texture()
+ {
+ }
+
+ void Texture::gl_initialize()
+ {
+ Image image(filename);
+ size = image.get_size();
// // Check that the image dimensions are a power of 2
// if ((image.get_surface()->w & (image.get_surface()->w - 1)) != 0 ) {
@@ -98,15 +109,26 @@ namespace usdx
image.get_surface()->pixels);
}
- Texture::~Texture()
+ void Texture::gl_cleanup()
{
if (glIsTexture(texture)) {
glDeleteTextures(1, &texture);
}
}
- GLuint Texture::get_texture(void) const
+ void Texture::enable(void)
+ {
+ GlDelayedAllocation::enable();
+
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, texture);
+
+ }
+
+ void Texture::disable(void)
{
- return texture;
+ GlDelayedAllocation::disable();
+
+ glDisable(GL_TEXTURE_2D);
}
};