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/8b5630c1414aa8762e8e to your computer and use it in GitHub Desktop.
Save microcosm/8b5630c1414aa8762e8e to your computer and use it in GitHub Desktop.
ofImage img;
ofTexture texture;
ofPlanePrimitive plane;
float tx0, ty0, tx1, ty1;
void ofApp::setup(){
ofDisableArbTex(); //Removing this line allows npot textures to work fine
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 = mouseX;
ty0 = mouseY;
tx1 = mouseX + 512;
ty1 = mouseY + 512;
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