summaryrefslogtreecommitdiff
path: root/mogltk
diff options
context:
space:
mode:
Diffstat (limited to 'mogltk')
-rw-r--r--mogltk/glbase.cpp8
-rw-r--r--mogltk/gltexture.cpp24
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;
}