summaryrefslogtreecommitdiff
path: root/gaunt01/src/normBindTexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gaunt01/src/normBindTexture.cpp')
-rw-r--r--gaunt01/src/normBindTexture.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/gaunt01/src/normBindTexture.cpp b/gaunt01/src/normBindTexture.cpp
new file mode 100644
index 0000000..68c17c9
--- /dev/null
+++ b/gaunt01/src/normBindTexture.cpp
@@ -0,0 +1,52 @@
+#include "normBindTexture.h"
+
+#include "ofMain.h"
+
+//texture binding with normalised coords
+void bindTexture(ofBaseHasTexture &t) {
+ ofTexture &tex = t.getTextureReference();
+ tex.bind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ ofTextureData texData = tex.getTextureData();
+ if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) {
+ glScalef(tex.getWidth(), tex.getHeight(), 1.0f);
+ } else {
+ glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+}
+void unbindTexture(ofBaseHasTexture &t) {
+ t.getTextureReference().unbind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}
+void bindTex(ofTexture &tex) {
+ tex.bind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ ofTextureData texData = tex.getTextureData();
+ if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) {
+ glScalef(tex.getWidth(), tex.getHeight(), 1.0f);
+ } else {
+ glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+}
+void unbindTex(ofTexture &tex) {
+ tex.unbind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}