summaryrefslogtreecommitdiff
path: root/morpher/src/normBindTexture.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-03-28 16:28:45 +0100
committerTim Redfern <tim@eclectronics.org>2012-03-28 16:28:45 +0100
commit623e1924aeea83ea70c8ae7f645b067f17a293ea (patch)
tree6016c770098ef923e6fac0be12040703d99fcbb2 /morpher/src/normBindTexture.cpp
parenta47b39541a7f60dfdda921c9598abe947e1e6ad9 (diff)
mesh loader and morpher working
Diffstat (limited to 'morpher/src/normBindTexture.cpp')
-rw-r--r--morpher/src/normBindTexture.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/morpher/src/normBindTexture.cpp b/morpher/src/normBindTexture.cpp
new file mode 100644
index 0000000..68c17c9
--- /dev/null
+++ b/morpher/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);
+}