OpenGL not working (black screen)


#1

We just released a new JUCE app to our customers for beta testing and we are getting a few “the app is completely black” messages back. I have replicated this myself with an old video card and it is clearly not supporting OpenGL properly. When I debug the code and I can see jassert hit in drawComponentBuffer:
jassert (context.extensions.glActiveTexture != nullptr);
with a note in the code about old drivers. This is not the nice behavour we would like since applications crashing or just painting a black window instead of either reverting to non-OpenGL or giving some sort of error message would be more useful and not generate tech support calls or hate mail.

I have modified the OpenGL code to add a quick check for the missing function in initialiseOnThread() right after context.extensions.initialise().

	if (context.extensions.glActiveTexture == nullptr)
		context.bInitError = true;

Then I can check for the bInitError and detach() the OpenGL context in my app if I see the problem.

This seems like quite a messy solution so I’m looking for a better way to know if OpenGL is going to work on the target computer. I would prefer either the setRenderer() or attachTo() to return an error so the app would know right away that OpenGL isn’t going to work. Optionally there could be another function that could be called at the same time as setRenderer() / attachTo() to see if there is an error - and not wait until the first paint occurs to detect the problem.

Any other ideas?


#2

No comments on this one?


#3

If you are building with XCode 10 and running on macOS Mojave, this is a known bug.
No comments from Apple so fare on this :frowning:

Some background




#4

I guess I should have given more information. This is on Windows (both Windows 7 and Windows 10 1809/RS5). We haven’t seen this on the Mac as far as I know.


#5

Like the comment above the assertion says, you can add in your own OpenGL version check before doing any rendering with something like this:

auto ver = String::fromUTF8 ((const char*) glGetString (GL_VERSION));

and then fall back to the software renderer if it’s too old.


#6

Old Intel cards do some nasty things.
On modern machines usually if they have integrated and discrete suggest switching between them -


#7

Thank you for the suggestion. glGetString returns: “1.1.0” on the non-working system and: “4.6.0 NVIDIA 417.35” and “4.0.0 - Build 10.18.10.4358” for working systems, so I will just parse out the version number at the start of the string and look for anything 2.0.0 or higher and hopefully that will work. Thanks again!