diff options
author | pixel <pixel> | 2002-11-15 23:58:57 +0000 |
---|---|---|
committer | pixel <pixel> | 2002-11-15 23:58:57 +0000 |
commit | d99f7dd959709b7a9e8cba23b88a216a6970209c (patch) | |
tree | 9e74abdec626b44ceb845239f8ed93f239946445 /mogltk | |
parent | 028c7dcfa9f1920d5fa2e573790bef40c4076275 (diff) |
Bleh
Diffstat (limited to 'mogltk')
-rw-r--r-- | mogltk/glbase.cpp | 8 | ||||
-rw-r--r-- | mogltk/gltexture.cpp | 24 |
2 files changed, 23 insertions, 9 deletions
diff --git a/mogltk/glbase.cpp b/mogltk/glbase.cpp index 0993b43..dabf28a 100644 --- a/mogltk/glbase.cpp +++ b/mogltk/glbase.cpp @@ -112,3 +112,11 @@ void mogltk::glbase::Leave2DMode(void) { twoD = 0; } + +void mogltk::glbase::Flip() { + SDL_GL_SwapBuffers(); +} + +bool mogltk::glbase::is2D() { + return twoD; +} 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; } |