Skip to content

Instantly share code, notes, and snippets.

@microcosm
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save microcosm/2d5a8cb81e7161f44365 to your computer and use it in GitHub Desktop.
Save microcosm/2d5a8cb81e7161f44365 to your computer and use it in GitHub Desktop.
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment