On a RaspberryPi 3 i have been using BeginTextureMode() to draw a framebuffer and had it running inside of a game loop with 2d and 3d graphics in it. However i noticed that as soon as i did anything to the framebuffer (Even as simple as writing a single character of text) made it slow down so it could never keep 60 fps.
I toggled a GPIO pin in the game loop so that i could time how long things take using a oscilloscope. However i soon found out that OpenGL does everything at its own pace at the end of the frame, including waiting tor frame sync so it didn't tell me much. To fix that i added a call to glFinish() right after and that let me measure frame render time.
I tried drawing the framebuffer both before everything else or between the BeginDrawing() EndDrawing() and it had no effect. Also found that calling glFinish() between those causes graphical glitches. However when i called glFinish() after i was done with drawing my framebuffer and before BeginDrawing() the performance came back to a solid 60fps. Infact if i looped my framebuffer drawing function 10 times, but still resulted in a higher FPS than if i called it just once without the flFinish trick. Even if the 10 passes draw lots of textures while the single pass draws a single text character its still faster to do those 10 passes.
Later on i found out that glFlush() works just as well while not halting the program so the CPU can be used to do useful stuff in that time.
Does anyone have an explanation of why performance would drop so badly when using a framebufer and why glFlush() somehow fixes it? The hack of calling glFlush myself works fine for me, but im putting it out there in case someone else runs in to the same issue.