openframeworks / openframeworks/openFrameworks

iOS bug drawing with FBO and ofSetOrientation.

Open
#5,951 24 comments 0 reactions 1 assignee View on GitHub

@ofTheo is already working on this.

Since Apr 5, 2018.

bug iOS open gl es
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 ).

screen shot 2018-04-05 at 11 17 38 am

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.

screen shot 2018-04-05 at 11 18 31 am

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:

screen shot 2018-04-05 at 11 25 28 am

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.