HI! I have some problem with this basic shader.
I don’t know why, but i try to simply redraw my texture using fragment shader, but if i don’t flip vertically my y coord i see my image reflected.
Can somebody explain me why this happen?
(my image is 1000x400px, like my window)
testApp.cpp
#include "testApp.h"
void testApp::setup()
{
ofSetVerticalSync(true);
ofSetFrameRate(60);
ofBackground(10, 10, 10);
shader.load( "shader.vert", "shader.frag");
ggpTest.loadImage("ggpTest.jpg");
}
void testApp::update()
{
}
void testApp::draw()
{
shader.begin();
shader.setUniformTexture("ggpTest", ggpTest.getTextureReference(), 1);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
shader.end();
}
shader.vert
#version 150
uniform mat4 modelViewProjectionMatrix;
in vec4 position;
void main(){
gl_Position = modelViewProjectionMatrix * position;
}
shader.frag
#version 150
out vec4 outputColor;
uniform sampler2DRect ggpTest;
void main()
{
vec4 ggpTestColor = texture(ggpTest, vec2(gl_FragCoord.x, 400 - gl_FragCoord.y));
outputColor = vec4(ggpTestColor);
}