blob: 68c17c9517fa21ba0957749e5a9ffbd19e40da07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
}
|