openframeworks / openframeworks/openFrameworks

Need stack based handling of FBO bindings?

Open
#1,742 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core development-strategy section-3D
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

I ran into the inverted bitmap string issue (#1474) again when I was drawing to an FBO which was itself drawn inside another FBO. The "nested" FBO was actually an internal FBO used by an addon's draw method, neatly hidden away from view.

example:

void testApp::draw(){
    fbo1.begin();
    addon.draw(); // binds draws then releases an internal FBO

    ofDrawBitmapString(...);
    fbo1.end();

    fbo1.draw(); // inverted text
}

The outer FBO remains bound after the internal one releases, so openGl must be using a stack like mechanism. I can tell because the FBO contains the text, it is just inverted. The OF gl renderer only has support for one FBO, so once the internal one gets released, it thinks no FBO is bound, and won't re-invert the bitmap strings.

I fixed the issue by calling fbo1.end(); fbo1.begin(); prior to drawing the bitmap string, but a proper fix would be using a stack to keep track of bound FBOs. This will also affect anything else using the currentFbo variable of ofGLRenderer.

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.

Research direction

Start by inspecting ofGLRenderer's currentFbo handling and the FBO begin/end calls described in the example. Reproduce the nested-FBO scenario with addon.draw(); done means the outer FBO remains tracked after the internal FBO is released and bitmap text is no longer inverted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.