diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-03-31 16:44:02 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-03-31 16:44:02 +0100 |
| commit | 0e8f0361c1068eb4c2f634dfcf4e1762d87f40d2 (patch) | |
| tree | 96a4eb154c1ac2dbe5ad4e04d4e33b281832e441 /gaunt01/src/normBindTexture.cpp | |
| parent | 623e1924aeea83ea70c8ae7f645b067f17a293ea (diff) | |
implementing trap door
Diffstat (limited to 'gaunt01/src/normBindTexture.cpp')
| -rw-r--r-- | gaunt01/src/normBindTexture.cpp | 52 |
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); +} |
