From d99f7dd959709b7a9e8cba23b88a216a6970209c Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 15 Nov 2002 23:58:57 +0000 Subject: Bleh --- mogltk/glbase.cpp | 8 ++++++++ mogltk/gltexture.cpp | 24 +++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'mogltk') 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; } -- cgit v1.2.3