alptugan
11/8/2018 - 2:37 PM

imageTexture

ofImage img;
ofTexture texture;
ofPlanePrimitive plane;
float tx0, ty0, tx1, ty1;

void ofApp::setup(){
    ofDisableArbTex();
    img.loadImage("test.jpg");
    texture = img.getTextureReference();
    texture.setTextureWrap(GL_REPEAT, GL_REPEAT);
    
    plane.set(512, 512);
    plane.setPosition(ofGetWidth() * 0.5, ofGetHeight() * 0.5, 0);
    plane.setResolution(2, 2);
}

void ofApp::update(){
    tx0 = ofMap(mouseX, 0, ofGetWidth(), 0, 1);
    ty0 = ofMap(mouseY, 0, ofGetHeight(), 0, 1);
    tx1 = tx0 + 1;
    ty1 = ty0 + 1;
    plane.mapTexCoords(tx0, ty0, tx1, ty1);
}

void ofApp::draw(){
    texture.bind();
    plane.draw();
    texture.unbind();
}