diff options
author | pixel <pixel> | 2003-09-05 22:01:00 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-09-05 22:01:00 +0000 |
commit | 343acb603be88ce4e9ac75de1d5ff64c086dfd77 (patch) | |
tree | f5fa96509a5c0fa6fd70805860a912003bfe1770 /mogltk/gltexture.cpp | |
parent | 2103fd655288946ef7353f05aed4d76a0f4f7f6c (diff) |
Removing mogltk...
Diffstat (limited to 'mogltk/gltexture.cpp')
-rw-r--r-- | mogltk/gltexture.cpp | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/mogltk/gltexture.cpp b/mogltk/gltexture.cpp deleted file mode 100644 index 7949cb9..0000000 --- a/mogltk/gltexture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include <GL/gl.h> -#include <GL/glu.h> -#include "gltexture.h" -#include "General.h" - -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!"); - - if (!(surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - 0xff000000, - 0x00ff0000, - 0x0000ff00, - 0x000000ff -#else - 0x000000ff, - 0x0000ff00, - 0x00ff0000, - 0xff000000 -#endif - ))) { - throw GeneralException("Can't create RGB Surface"); - } -} - -mogltk::texture::~texture() { - if (surface) { - SDL_FreeSurface(surface); - } else { - glDeleteTextures(1, &tex); - } -} - -SDL_Surface * mogltk::texture::GetSurface() throw (GeneralException) { - if (!surface) - throw GeneralException("Texture already generated"); - return surface; -} - -void mogltk::texture::Generate() throw (GeneralException) { - if (!surface) - throw GeneralException("Texture already generated"); - - if (planar) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); - } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); -// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); - } - - SDL_FreeSurface(surface); - surface = 0; -} - -void mogltk::texture::Bind(bool expand) throw (GeneralException) { - if (surface) - throw GeneralException("Texture is not yet generated"); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, tex); - if (expand) { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glScaled(1 / (double) width, 1 / (double) height, 1); - glMatrixMode(GL_MODELVIEW); - } -} - -GLuint mogltk::texture::GetWidth() { - return width; -} - -GLuint mogltk::texture::GetHeight() { - return height; -} - -void mogltk::texture::Unbind(void) { - glDisable(GL_TEXTURE_2D); -} |