OpenGLAppComponent::initialise() runs twice

opengl

#1

I have a class that generalizes OpenGLAppComponent. This class was auto-generated by ProJucer, and all that I’ve done is add initialization of one class to the initialise() method.

In the process of step debugging my code to do some ad-hoc testing, I discovered that initialise() gets called twice. I tested and saw that the OpenGLAppComponent’s constructor is only called once, and the call stack to initialise() looks identical in both calls.

It’s possible this is caused by the step debugging, since that can screw up threading, and it’s also worth pointing out that my environment is Windows 10/VS2017.

A workaround is obvious, of course, but I thought it worth reporting in case it is a broad case rather than caused by something environmental.

Thanks!


#2

Are you talking about JUCEApplicationBase::initialise() ?

Because that definitely won’t be called twice… (?)


#3

No, it is specifically an initialise() override in a class derived from OpenGLAppComponent that is being called twice. I believe expected behavior should probably be that it runs once, but it actually runs twice.


#4

Oh, well if it’s the GL initialise call, it’s totally platform-dependent when it gets called. Could be that the GL context is re-created for some reason. But basically, you have to assume that your context could be released/initialised any number of times during your app’s runtime, so you’d need to make your code cope with that anyway.


#5

Fair enough… easy enough to do in any case.