Bug: OpenGL rendering on oldish Windows machines

We discovered a glitch where OpenGL rendering on oldish Windows machines (Intel chip etc.) produces garbage. The general shapes and colours of the rendering are there, but with a lot of elements missing. This has been reported by a customer as well. The bug could be reproduced at least with versions 4.3, 5.0 and the latest master, and is broken out of the box with the demo runner when switching OpenGL rendering back end. For us it was reproduced on a HP ProBook 430 G2, running Windows 7 x64.

The reason appears to be that the hardware sometimes doesn’t have time to draw the vertices, or its implementation chooses not to, before a new vertices are passed over in the drawing loop. Adding glFlush() into the draw function in file juce_OpenGLGraphicsContext.cpp (line 1277) after glDrawElements seems to fix the issue. As this seems to only happen with Windows, perhaps with macro guards for the platform. Would this be a viable option as a fix, or is there something more than meets the eye here?

On the topic of OpenGL, going through the code the OpenGL drawing backend seems to draw everything as quads based on the line scan. Is there any approach in the JUCE codebase for drawing shapes via triangle strips with less CPU strain, or would you advice us to roll our own implementation to increase the drawing performance?

Thanks, best,


Nope, there is no alternative. It’s been this way for an unfortunately extremely long time, and I’ve mentioned this very issue over the years on the forums: High CPU usage on opengl repaints/renderFrame no matter what, even on unmodified default project - #2 by jrlanglois

This is really a topic for another discussion, but JUCE’s rendering approach is totally not designed for GPU drawing.

1 Like