openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.83k stars 2.56k forks source link

OF_FBOMODE_NODEFAULTS doesn't set identity matrices #7998

Open neilmendoza opened 1 month ago

neilmendoza commented 1 month ago

The below code should create a view from [-1, -1] to [1, 1] and draw a square in the upper right quadrant...

 fbo.begin(OF_FBOMODE_NODEFAULTS);
 ofClear(0, 255);
 ofSetColor(255);
 ofDrawRectangle(0, 0, 1, 1);
 fbo.end();

However, to get it to actually to actually do that, I needed to explicitly load the identity matrices...

fbo.begin(OF_FBOMODE_NODEFAULTS);
ofSetMatrixMode(OF_MATRIX_PROJECTION);
ofPushMatrix();
ofLoadIdentityMatrix();
ofSetMatrixMode(OF_MATRIX_MODELVIEW);
ofPushMatrix();
ofLoadIdentityMatrix();
ofClear(0, 255);
ofSetColor(255);
ofDrawRectangle(0, 0, 1, 1);
ofSetMatrixMode(OF_MATRIX_PROJECTION);
ofPopMatrix();
ofSetMatrixMode(OF_MATRIX_MODELVIEW);
ofPopMatrix();
fbo.end();