diff options
Diffstat (limited to 'mogltk/gltexture.cpp')
-rw-r--r-- | mogltk/gltexture.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/mogltk/gltexture.cpp b/mogltk/gltexture.cpp index 0878d04..0549ee3 100644 --- a/mogltk/gltexture.cpp +++ b/mogltk/gltexture.cpp @@ -3,7 +3,7 @@ #include "gltexture.h" #include "General.h" -mogltk::gltexture::gltexture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h), planar(plane) { +mogltk::texture::texture(int w, int h, bool plane) throw (GeneralException) : width(w), height(h), planar(plane) { if ((BITCOUNT(w) != 1) || (BITCOUNT(h) != 1)) throw GeneralException("Size of the texture not a power of 2!"); @@ -24,21 +24,21 @@ mogltk::gltexture::gltexture(int w, int h, bool plane) throw (GeneralException) } } -mogltk::gltexture::~gltexture() { +mogltk::texture::~texture() { if (surface) { SDL_FreeSurface(surface); } else { - glDeleteTextures(1, &texture); + glDeleteTextures(1, &tex); } } -SDL_Surface * mogltk::gltexture::GetSurface() throw (GeneralException) { +SDL_Surface * mogltk::texture::GetSurface() throw (GeneralException) { if (!surface) throw GeneralException("Texture already generated"); return surface; } -void mogltk::gltexture::Generate() throw (GeneralException) { +void mogltk::texture::Generate() throw (GeneralException) { if (!surface) throw GeneralException("Texture already generated"); @@ -59,16 +59,22 @@ void mogltk::gltexture::Generate() throw (GeneralException) { surface = 0; } -void mogltk::gltexture::Bind() throw (GeneralException) { +void mogltk::texture::Bind(bool expand) throw (GeneralException) { if (surface) throw GeneralException("Texture is not yet generated"); - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, tex); + if (expand) { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glScaled(1 / (double) width, 1 / (double) height, 1); + glMatrixMode(GL_MODELVIEW); + } } -GLuint mogltk::gltexture::GetWidth() { +GLuint mogltk::texture::GetWidth() { return width; } -GLuint mogltk::gltexture::GetHeight() { +GLuint mogltk::texture::GetHeight() { return height; } |