summaryrefslogtreecommitdiff
path: root/lib/gltexture.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gltexture.cc')
-rw-r--r--lib/gltexture.cc120
1 files changed, 0 insertions, 120 deletions
diff --git a/lib/gltexture.cc b/lib/gltexture.cc
deleted file mode 100644
index ff79112..0000000
--- a/lib/gltexture.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-#include <sys/types.h>
-#include <SDL.h>
-#include <SDL_opengl.h>
-#include <generic.h>
-#include "gltexture.h"
-#include "engine.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "gettext.h"
-
-mogltk::gltexture * mogltk::gltexture::active = 0;
-
-mogltk::gltexture::gltexture(int w, int h, bool plane) throw (GeneralException) :
- texture(w, h), texture_allocated(false), planar(plane), tainted(true) {
-}
-
-mogltk::gltexture::gltexture(Handle * h, bool plane) throw (GeneralException) :
- texture(h), texture_allocated(false), planar(plane), tainted(true) {
-}
-
-mogltk::gltexture::~gltexture() {
- if (texture_allocated) {
- glDeleteTextures(1, &tex);
- }
-}
-
-void mogltk::gltexture::Generate() {
- if (texture_allocated) {
- glDeleteTextures(1, &tex);
- }
-
- glGenTextures(1, &tex);
-#ifdef DEBUG
- printm(M_INFO, _("Generated gltexture index: %i\n"), tex);
-#endif
-
- glBindTexture(GL_TEXTURE_2D, tex);
-
-#if 0
- if (planar) {
-#ifdef DEBUG
- printm(M_INFO, _("Generating planar gltexture: %i\n"), tex);
-#endif
- 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 {
-#endif
-#ifdef DEBUG
- printm(M_INFO, _("Generating 3D gltexture: %i\n"), tex);
-#endif
- 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, GetWidth(), GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, GetPixels());
-// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
-#if 0
- }
-#endif
-
- texture_allocated = true;
- tainted = false;
-}
-
-void mogltk::gltexture::Bind(bool expand) {
- if ((!texture_allocated) || tainted)
- Generate();
- glEnable(GL_TEXTURE_2D);
- if (active == this)
- return;
-#ifdef DEBUG
- printm(M_INFO, _("Binding gltexture index %i.\n"), tex);
-#endif
- glBindTexture(GL_TEXTURE_2D, tex);
- if (expand) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glScaled(1 / (double) GetWidth(), 1 / (double) GetHeight(), 1);
- glMatrixMode(GL_MODELVIEW);
- }
-
- active = this;
-
-#ifdef TRACE_TEXTURES
- if (header == this)
- return;
-
- if (prev) {
- prev->next = next;
- }
-
- if (next) {
- next->prev = prev;
- }
-
- if (footer = this) {
- footer = prev;
- }
-
- header->prev = this;
- header = this;
-#endif
-}
-
-void mogltk::gltexture::Unbind(void) {
- if (active) {
- glBindTexture(GL_TEXTURE_2D, 0);
- glDisable(GL_TEXTURE_2D);
- active = 0;
-#ifdef DEBUG
- printm(M_INFO, _("Unbinding gltexture.\n"));
-#endif
- }
-}
-
-void mogltk::gltexture::Taint(void) {
- tainted = true;
-}