I am working in a 2D console emulator project using Juce. I started by adding a few UI elements to debug the emulated CPU (i.e. display the state of the registers after an instruction is executed), as well as basic controls such as a FileChooser to select a ROM file.
It worked great so far, no performance issues whatsoever and looking great. I soon enough had to implement the game screen, so I created a subclass of OpenGLAppComponent, and I added it to my MainComponent, taking about half of its window size. This is where the problems started:
So far I just render a dummy image in my OpenGL component, a simple quad with a color gradient. However, this is enough to slow down the UI elements to unbearable levels. For instance, trying to open the FileChooser dialog takes about 7 seconds from clicking the option until the dialog is fully visible. Displaying the PopupMenu on mouse click takes about 1 second, when it used to be instantaneous without the OpenGL component.
I have been reading all the OpenGL related threads I could find in the forum, but still haven’t found a solution to this issue. Is an OpenGL component 100% incompatible with having regular UI elements in other components within the same window? I have read in the forum that the OpenGL rendering locks the whole Graphics object of the window (or something like that), in order to avoid rendering issues while the window might be moved or resized, and I understand that risk. However, doesn’t this defeat the purpose of using an OpenGL component?
I would love to hear the suggestions and insight of you all. I have been doing several tests with the JuceDemo and the OpenGlAppExample, and saw some interesting things. For instance, opening a FileChooser upon button press in them and comparing performance to my project, I realized that in the JuceDemo’s OpenGLDemo (the 3D one), it takes the same ~5 seconds to open the FileChooser when the “Draw 2D graphics in background” option is NOT enabled… but only about 1 second when it was enabled, and I just cannot figure out why. I have realized that the CPU usage increases from 0% when disabled to about 2% when enabled, so I guess that said background rendering is being done via CPU and not GPU…
Any comment is greatly appreciated, I would really love to continue this project using Juce!