Hello, I have a strange issue applying a texture to an ofPlanePrimitive
.
If I draw the texture on the screen, I see this:
When I apply the texture to an ofPlanePrimitive, the resolution of the texture get suddenly way lower:
The texture and the plane have the same dimensions.
This is the code in which I apply the texture to the plane
// variables in the header
ofShader myShader;
ofImage test;
ofPlanePrimitive plane;
// in setup method
test.load("test.jpg");
plane.set(test.getWidth(), test.getHeight(), 2, 2);
plane.mapTexCoordsFromTexture(test.getTexture());
// in draw method
myShader.setUniformTexture("tex0",test.getTexture(), 0);
myShader.begin();
ofPushMatrix();
ofTranslate(test.getWidth()/2, test.getHeight()/2);
ofRotateXDeg(180);
plane.draw();
ofPopMatrix();
myShader.end();
This is my vertex shader
#version 150
uniform mat4 modelViewProjectionMatrix;
in vec4 position;
in vec2 texcoord;
out vec2 texCoordVarying;
void main(){
texCoordVarying = texcoord;
gl_Position = modelViewProjectionMatrix * position;
}
and this is the fragment one
#version 150
out vec4 outputColor;
in vec2 texCoordVarying;
uniform sampler2DRect tex0;
void main(){
vec4 texel0 = texture(tex0, texCoordVarying);
outputColor = texel0;
}
As you see, I am using ARB texture coordinates. If I disable them, a lot of other things that I have in this application stop to work. That’s why I would like to find a solution using ARB coordinates.