Created
March 15, 2015 14:00
-
-
Save mikewesthad/568da37da89f657f96f0 to your computer and use it in GitHub Desktop.
An ofSketch showing that the order in which transparent objects are drawn in openGL matters
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
ofEasyCam cam; | |
void setup() { | |
ofSetWindowShape(800, 400); | |
ofSetRectMode(OF_RECTMODE_CENTER); | |
} | |
void draw() { | |
ofEnableBlendMode(OF_BLENDMODE_DISABLED); | |
ofBackground(ofColor::white); | |
ofEnableBlendMode(OF_BLENDMODE_ALPHA); | |
cam.begin(); | |
// Center the camera over the rects | |
ofTranslate(-150, 0, 0); | |
// Draw red on blue | |
ofSetColor(255, 0, 0, 127); | |
ofRect(0, 0, 100, 200, 200); | |
ofSetColor(0, 0, 255, 127); | |
ofRect(0, 0, 0, 200, 200); | |
// Draw blue on red | |
ofSetColor(0, 0, 255, 127); | |
ofRect(300, 0, 100, 200, 200); | |
ofSetColor(255, 0, 0, 127); | |
ofRect(300, 0, 0, 200, 200); | |
cam.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment