Opengl and juce


i’m still very new to juce, so bear with me…

in the demo app, there’s a box that can be dropped onto the desktop and then brought back to the main window.

can this be done with an opengl component? i tried just hacking an addtodesktop(0) into the demo app to see, but i’m getting black renders in that component and otherwise confusing juce.


I don’t think it’ll work if the component is semi-transparent, but if you setOpaque (true) first, then it should be ok.


i add the code:


right after the “canvas->setBounds(…)” call in the openGLDemo::resize() function.

i get a black window with juce components showing up on ocasion (like whatever button the mouse goes over).


ok, well I’ve not really tested the OpenGLComponent very hard yet - in particular I’ve not tested changing the component hierarchy and seeing if it copes with that, but I will do.


yeah, it seems changing the component heirarchy on an opengl component might be the problem here. it seems the context never initializes properly if you do an addtodesktop call for an opengl component. in fact, the initialise() method is never called (so the context is not created).

poking around further it seems the componentParentHierarchyChanged() method is not called at the appropriate time, either. it will make it to that code a few times without doing an initialize – presumably because things aren’t ready to be initialized yet, tho i’m not certain of this. if you stick and addtodesktop() call to your demo app, it will skip the last run thru of heirarchyChanged() function (the one that actually initializes).

that’s as far as i’ve been able to figure things out so far…

while on the topic of opengl, i notice that popups can draw over opengl components, but their shadows can’t.


You can’t have anything partially transparent over an accelerated app, whether it be DirectX, OpenGL, or a Movie. That part will either not be visible, or flicker.


did i read something somewhere about a possible to switch to opengl for all drawing?


I experimented with this a bit, but came across a lot of problems like not being able to reliably draw an anitaliased polygon, and textures only having sizes that are a power of 2, things being different on different graphics cards, etc… opengl’s just a bit more clunky than I imagined.


Hi Jucers! I’m looking for a nice-looking and adjustable GUI for a OpenGL-based demo application. I tried out GLUI (I shared a screenshot on our website: ), and now I’m trying to use JUCE for this purpose. What I want is not more than a “pop-up” panel on the right side of the screen, over the OpenGLComponent (like in existing GLUI-demo). In this demo, the panel appears when I move the cursor to the right border of screen.
But the similar demo in JUCE have a problem: I can’t draw component over OpenGL canvas.

For example, if I expand OpenGLDemo.cpp…

Index: OpenGLDemo.cpp

— OpenGLDemo.cpp (revision 776)
+++ OpenGLDemo.cpp (working copy)
@@ -251,6 +251,7 @@
DemoOpenGLCanvas* canvas;

  • TabbedComponent* tabbed;

@@ -259,7 +260,12 @@
setName (T(“OpenGL”));

     canvas = new DemoOpenGLCanvas();
  •    addAndMakeVisible (canvas);
  •    addAndMakeVisible(canvas);
  •    tabbed = new TabbedComponent(TabbedButtonBar::TabsAtTop);
  •    addAndMakeVisible(tabbed);
  •    tabbed->setTabBarDepth(30);
  •    tabbed->addTab (T("Tab 0"), Colours::lightgrey, 0, false);
  •    tabbed->setCurrentTabIndex(0);


    @@ -269,7 +275,8 @@

    void resized()

  •    canvas->setBounds (10, 10, getWidth() - 20, getHeight() - 50);
  •    canvas->setBounds(10, 50, getWidth() - 20, getHeight() - 50);
  •    tabbed->setBounds(20, 10, 200, 150);

…the result is:
But the main menu appears correctly ( )
How can I draw my TabbedComponent in over the canvas?


Excuse me, it seems that I asked too fast, but than I found it out by myself:

void resized()