@yangyangcv wrote:
say i have an image like below:
this is the effect i want to achieve:
but acturally i get this:
below are the codes:
ofApp.h
#pragma once #include "ofMain.h" class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); ofShader shader; ofImage img; };ofApp.cpp
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ ofBackground(0); shader.load("shadersGL3/shader"); if(!img.loadImage("1.jpg")) std::cout<<"fail to load 1.jpg"<<std::endl; } //-------------------------------------------------------------- void ofApp::update(){ } //-------------------------------------------------------------- void ofApp::draw(){ shader.begin(); img.draw(0,0); shader.end(); }shader.frag
#version 150 uniform sampler2DRect tex0; in vec2 texCoordVarying; out vec4 outputColor; void main() { vec4 color; color = texture(tex0, texCoordVarying ); outputColor = color; }shader.vert
#version 150 uniform mat4 modelViewProjectionMatrix; in vec4 position; in vec2 texcoord; out vec2 texCoordVarying; void main() { texCoordVarying = texcoord; vec4 modifiedPosition = modelViewProjectionMatrix * position; gl_Position = modifiedPosition; if(gl_Position.x<500){ gl_Position.y -= 140; } }
Posts: 4
Participants: 3


