Last active
August 29, 2015 14:08
-
-
Save microcosm/8b5630c1414aa8762e8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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