Skip to content

Instantly share code, notes, and snippets.

@erikccoder
Created February 25, 2014 03:49
Show Gist options
  • Select an option

  • Save erikccoder/9202321 to your computer and use it in GitHub Desktop.

Select an option

Save erikccoder/9202321 to your computer and use it in GitHub Desktop.
draw Skew
void testApp::drawSkew(ofImage * src, ofPoint * tl, ofPoint * tr, ofPoint * br, ofPoint * bl) {
// tl,tr,br,bl = normalized 0.-1.
ofSetColor(255);
src->reloadTexture();
//src->draw(0,0);
//ofDisableArbTex();
src->getTextureReference().bind();
// glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
ofScale(src->getWidth(), src->getHeight());
glMatrixMode(GL_MODELVIEW);
glEnable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
glNormal3f(0.0f,0.0f,1.0f);
//Top Left
glTexCoord3f(0.0f, 0.0f, 0.0f);
glVertex3f( tl->x, tl->y, 0.0f);
// Top Right
glTexCoord3f(1.0f, 0.0f, 0.0f);
glVertex3f( tr->x, tr->y, 0.0f);
// Bottom Right
glTexCoord3f(1.0f, 1.0f, 0.0f);
glVertex3f( br->x,br->y, 0.0f);
// Bottom Left
glTexCoord3f(0.0f, 1.0f, 0.0f);
glVertex3f( bl->x, bl->y, 0.0f);
glEnd();
glDisable (GL_DEPTH_TEST);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
// glDisable(GL_TEXTURE_2D);
src->getTextureReference().unbind();
//ofEnableArbTex();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment