Hi
Problably a no-brainer question but I have a button that should show/close an openGl component. I use the following code:
if (button == buttons[1])
{
if(myOpenGLCanvas->isShowing())
myOpenGLCanvas->setVisible(false);
else
myOpenGLCanvas->setVisible(true);
}
I cannot make the OpenGl invisible which I believe should be possible with the code above.
Any hints?
Cheers
Thomas
jules
2
Are you’re sure it’s not because you’re using isShowing() rather than isVisible()? (They’re subtly different…)
Which OS is this on?
[quote=“jules”]Are you’re sure it’s not because you’re using isShowing() rather than isVisible()? (They’re subtly different…)
Which OS is this on?[/quote]
Hi
I have just tried IsVisible() too and that didn’t make the OpenGl component go away.
OS = WindowsXP
Thanks
Thomas
It’s not a clean solution, but you can try this
if (button == buttons[1])
{
if(myOpenGLCanvas->isShowing())
{
myOpenGLCanvas->setVisible(false);
myOpenGLCanvas->setBounds(0,0,0,0);
}
else
{
myOpenGLCanvas->setVisible(true);
myOpenGLCanvas->setBounds();// set appropriate value
}
}
By the way, which version of juce are you using?
[quote=“vishvesh”]It’s not a clean solution, but you can try this
[code]
if (button == buttons[1])
{
if(myOpenGLCanvas->isShowing())
{
myOpenGLCanvas->setVisible(false);
myOpenGLCanvas->setBounds(0,0,0,0);
}
else
{
myOpenGLCanvas->setVisible(true);
myOpenGLCanvas->setBounds();// set appropriate value
}
}
[/code][/quote]
Hi
Thanks for the code. Will try it out!
I’m using JUCE v1.46 and I’ve updated the source code using SVN some 2 months ago!
Thomas
I tried this:
if(myOpenGLCanvas->isVisible())
{
myOpenGLCanvas->setVisible(false);
myOpenGLCanvas->setBounds(0,0,0,0);
}
else
{
myOpenGLCanvas->setVisible(true);
myOpenGLCanvas->setBounds(140,140,200,200);
}
…but that doesn’t work either for me. The OpenGl component does not get removed …instead the content of the opengl canvas is cleared!
Thomas
are you directly placing “myOpenGLCanvas” on a component?
Thanks for asking. I’m not sure if I place the openglcanvas directly on the component but I do the following:
// Setup OpenGl component
myOpenGLCanvas = new OpenGLCanvas();
addAndMakeVisible(myOpenGLCanvas);
myOpenGLCanvas->makeCurrentContextActive();
myOpenGLCanvas->setVisible(false);
Does this answer your question?
I find that it is the transition from visible to not-visible that doesn’t work!
Cheers
Thomas