OpenGlComponent + Buttons


#1

Hi!

I’m a newbie in JUCE.
I’ve just created a Windows with a OpenGlComponent inside. I can render scenes on it, but when I add any button I can’t see it (the mouse click appears to check the button, but it’s not drawed).
I add the button this way:

Somewhere in the end of “newOpenGLContextCreated ()”:

m_b1 = new TextButton (CharPointer_UTF8 (“Button 1”), “Button 1”);
m_b2 = new TextButton (CharPointer_UTF8 (“Button 2”), “Button 2”);
m_b1->setBounds (10, 10, 64, 24);
m_b2->setBounds (200, 200, 100, 100);
addAndMakeVisible (m_b1);
addAndMakeVisible (m_b2);

What am I doing wrong?

Thx in advance!

Javier.


#2

Yeah, the openGL component is a heavyweight canvas supplied by the OS - the juce renderer can’t draw over the top, I’m afraid.


#3

Ops!
I need an OpenGL GUI. Does anyone know a multiplatform one?

Thx in advance.

Javier.


#4

Is it too difficult to implement the painting of the child’s OpenGlComponent? That would be like 2D texture painting at the end of OpenGL redraw…


#5

Hi!

I have implemented this code in the “render” part of my OpenGL component:

int total = getNumChildComponents (); for (long t=0;t<total;t++){ Component* pB = (Component*) getChildComponent (t); int w = pB->getWidth (); int h = pB->getHeight (); int x = pB->getPosition ().getX (); int y = getHeight () - h - pB->getPosition ().getY (); juce::Image * img = new Image(juce::Image::PixelFormat::ARGB ,w, h, true, juce::Image::ImageType::SoftwareImage); juce::Graphics * g = new juce::Graphics (*img); pB->paint (*g); Image::BitmapData bmd (*img, Image::BitmapData::readOnly); m_textura = g_GL_CreateTextureFromRGBA (w, h, bmd.getPixelPointer (0, 0)); // A personal function to create texture. g_GL_DrawTexture2D (m_textura, x, y, w, h); // A personal function to draw the texture in OpenGL part. delete g; delete img; }

And it’s running ok! I put two buttons, and they paint ok.
Will it work well in the future?
Any advice?

Thanks in advance…

Edit: There seems to be a memory leak (not in my own funtions " g_GL_CreateTextureFromRGBA" or “g_GL_DrawTexture2D”) … Any idea?
Reedit: Solved “leak”. It was my problem, not JUCE.