openframeworks / openframeworks/openFrameworks
iOS bug drawing with FBO and ofSetOrientation.
@ofTheo is already working on this.
Since Apr 5, 2018.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Found a different bug which prevents drawing on iOS except in Portrait mode.
It looks like when FBOs are being drawn in landscape mode they are being drawn backwards somehow? There is a big black triangle over part of the image.
//--------------------------------------------------------------
void ofApp::setup(){
ofSetOrientation(OF_ORIENTATION_90_RIGHT);
fbo.allocate(1024, 1024, GL_RGBA);
fbo.begin();
ofClear(255, 255, 255, 255);
ofSetColor(255, 0, 0);
ofDrawCircle(ofGetWidth()/2, ofGetHeight()/2, 300);
fbo.end();
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(0);
if( bRotate ){
ofSetOrientation(OF_ORIENTATION_90_RIGHT);//Set iOS to Orientation Landscape Right
}else{
ofSetOrientation(OF_ORIENTATION_DEFAULT);//Set iOS to Portrait
}
ofSetColor(255);
fbo.draw(0,0);
}
//--------------------------------------------------------------
void ofApp::exit(){
}
//--------------------------------------------------------------
void ofApp::touchDown(ofTouchEventArgs & touch){
bRotate = true;
}
//--------------------------------------------------------------
void ofApp::touchMoved(ofTouchEventArgs & touch){
}
//--------------------------------------------------------------
void ofApp::touchUp(ofTouchEventArgs & touch){
bRotate = false;
}
This is what it looks like if you have ofSetOrientation(OF_ORIENTATION_90_RIGHT) set in ofApp::setup or if you just have it before the draw call ( you can even setup the fbo with no orientation set and if you have ofSetOrientation(OF_ORIENTATION_90_RIGHT) before fbo::draw it causes this issue ).
This is what it looks like if you have ofSetOrientation(OF_ORIENTATION_DEFAULT); before the draw call or if you don't set orientation anywhere in the app.
I think this is to do with the vFlip and or matrix stuff
https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/utils/ofMatrixStack.cpp#L49
If I setup the app this way:
( notice the false flag for ofSetOrientation vFlip )
//--------------------------------------------------------------
void ofApp::setup(){
ofSetOrientation(OF_ORIENTATION_90_RIGHT, false);
fbo.allocate(1024, 1024, GL_RGBA);
fbo.begin();
ofClear(255, 255, 255, 255);
ofSetColor(255, 0, 0);
ofDrawCircle(ofGetWidth()/2, ofGetHeight()/2, 300);
fbo.end();
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(0);
ofSetColor(255);
fbo.draw(0,0);
}
This produces:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.