OpenGL Component assertion

Hello,

i tried to compile my app with new juce version (1.39) and now i get assertion error:
Assertion failure: platform_specific_code/juce_linux_Windowing.cpp, 2201

My MainWindow creates opengl component and sets it as mainContentComponent in constructor. And this fails. Is it a bug or should i move initialisation into something like ‘initialize’-function?

hmm. No, it should be able to cope with what you’re doing. How about just tweaking this method in juce_OpenGLComponent.cpp:

[code] void componentMovedOrResized (bool /wasMoved/, bool /wasResized/)
{
Component* const topComp = owner->getTopLevelComponent();

    if (topComp->getPeer() != 0)
    {
        if (context == 0 && owner->isShowing())
            initialise();

        juce_updateOpenGLWindowPos (context, owner, topComp);
        needToUpdateViewport = true;
    }
}

[/code]

[quote=“jules”]hmm. No, it should be able to cope with what you’re doing. How about just tweaking this method in juce_OpenGLComponent.cpp:

[code] void componentMovedOrResized (bool /wasMoved/, bool /wasResized/)
{
Component* const topComp = owner->getTopLevelComponent();

    if (topComp->getPeer() != 0)
    {
        if (context == 0 && owner->isShowing())
            initialise();

        juce_updateOpenGLWindowPos (context, owner, topComp);
        needToUpdateViewport = true;
    }
}

[/code][/quote]
tried that, didn’t help. printf’s say, that context is zero but owner is not showing…

Ah yes. Ok, try this:

    void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/)
    {
        Component* const topComp = owner->getTopLevelComponent();

        if (topComp->getPeer() != 0)
        {
            needToUpdateViewport = true;

            if (context == 0)
            {
                if (owner->isShowing())
                    initialise();
                else
                    return;
            }

            juce_updateOpenGLWindowPos (context, owner, topComp);
        }
    }

[quote=“jules”]Ah yes. Ok, try this:

[code]
void componentMovedOrResized (bool /wasMoved/, bool /wasResized/)
{
Component* const topComp = owner->getTopLevelComponent();

    if (topComp->getPeer() != 0)
    {
        needToUpdateViewport = true;

        if (context == 0)
        {
            if (owner->isShowing())
                initialise();
            else
                return;
        }

        juce_updateOpenGLWindowPos (context, owner, topComp);
    }
}

[/code][/quote]
i get following output in my terminal when i start my app:
JUCE v1.39
ERROR: X returned GLXBadDrawable for operation Unknown
ERROR: X returned GLXBadDrawable for operation Unknown
ERROR: X returned BadWindow (invalid Window parameter) for operation X_UnmapWindow
ERROR: X returned BadWindow (invalid Window parameter) for operation X_DestroyWindow
contents of the window are not shown, also

here is example project source (zipped)

Ok, well I’ve tried it now, and this seems to work for me, although you’ll need to tweak your resize code because the first time it’s called, the context isn’t yet active.

[code]
void initialise()
{
jassert (context == 0);

    if (context == 0)
    {
        context = juce_createOpenGLContext (owner,
                                            sharedContext != 0 ? sharedContext->context
                                                               : 0);

        if (context != 0)
            componentMovedOrResized (true, true);
    }
}[/code]

[code] void componentMovedOrResized (bool /wasMoved/, bool /wasResized/)
{
if (owner->getWidth() > 0 && owner->getHeight() > 0)
{
Component* const topComp = owner->getTopLevelComponent();

        if (topComp->getPeer() != 0)
        {
            needToUpdateViewport = true;

            if (context == 0)
            {
                if (owner->isShowing())
                    initialise();
                else
                    return;
            }

            juce_updateOpenGLWindowPos (context, owner, topComp);
        }
    }
}[/code]

sorry for these posts above, i think it was misconfigured/not fully uninstalled nvidia driver… :-/
Now everything works. Sorry once again

just downloaded 1.39 and uncommented #define JUCE_OPENGL 1, and when I run the demo and go to the OpenGL demo I get:

Assertion failure: platform_specific_code/juce_linux_Windowing.cpp, 2201
Trace/breakpoint trap

I’m pretty sure I have all the GL stuff I need (Fedora 5):

$ glxinfo | grep OpenGL
OpenGL vendor string: VA Linux Systems Inc.
OpenGL renderer string: Mesa DRI G400 20050609 AGP 1x x86/MMX/SSE2
OpenGL version string: 1.2 Mesa 6.4.2
OpenGL extensions:

$ rpm -q mesa-libGL mesa-libGL-devel mesa-libGLU mesa-libGLU-devel mesa-libGLw-devel mesa-libGLw
mesa-libGL-6.4.2-6.FC5.3
mesa-libGL-devel-6.4.2-6.FC5.3
mesa-libGLU-6.4.2-6.FC5.3
mesa-libGLU-devel-6.4.2-6.FC5.3
mesa-libGLw-devel-6.4.2-6.FC5.3
mesa-libGLw-6.4.2-6.FC5.3

unless I need freeglut-devel too?

… and of course I don’t get any link errors…

[quote=“bowerymarc”]just downloaded 1.39 and uncommented #define JUCE_OPENGL 1, and when I run the demo and go to the OpenGL demo I get:

Assertion failure: platform_specific_code/juce_linux_Windowing.cpp, 2201
Trace/breakpoint trap

I’m pretty sure I have all the GL stuff I need (Fedora 5):

$ glxinfo | grep OpenGL
OpenGL vendor string: VA Linux Systems Inc.
OpenGL renderer string: Mesa DRI G400 20050609 AGP 1x x86/MMX/SSE2
OpenGL version string: 1.2 Mesa 6.4.2
OpenGL extensions:

$ rpm -q mesa-libGL mesa-libGL-devel mesa-libGLU mesa-libGLU-devel mesa-libGLw-devel mesa-libGLw
mesa-libGL-6.4.2-6.FC5.3
mesa-libGL-devel-6.4.2-6.FC5.3
mesa-libGLU-6.4.2-6.FC5.3
mesa-libGLU-devel-6.4.2-6.FC5.3
mesa-libGLw-devel-6.4.2-6.FC5.3
mesa-libGLw-6.4.2-6.FC5.3

unless I need freeglut-devel too?

… and of course I don’t get any link errors…[/quote]

you have to apply patch to
src/juce_appframework/gui/components/special/juce_OpenGLComponent.cpp
as mentioned above

void initialise() 
{ 
        jassert (context == 0); 

        if (context == 0) 
        { 
            context = juce_createOpenGLContext (owner, 
                                                sharedContext != 0 ? sharedContext->context 
                                                                   : 0); 

            if (context != 0) 
                componentMovedOrResized (true, true); 
        } 
    }

and

void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) 
    { 
        if (owner->getWidth() > 0 && owner->getHeight() > 0) 
        { 
            Component* const topComp = owner->getTopLevelComponent(); 

            if (topComp->getPeer() != 0) 
            { 
                needToUpdateViewport = true; 

                if (context == 0) 
                { 
                    if (owner->isShowing()) 
                        initialise(); 
                    else 
                        return; 
                } 

                juce_updateOpenGLWindowPos (context, owner, topComp); 
            } 
        } 
    }

nope that didn’t help at all, same error.

btw, normally you talk about a patch like this (not to be too much of a weenie or anything…):

--- juce_OpenGLComponent.cpp.old        2006-10-27 09:00:45.000000000 -0400
+++ juce_OpenGLComponent.cpp    2006-10-27 09:05:01.000000000 -0400
@@ -118,9 +118,13 @@
         jassert (context == 0);

         if (context == 0)
+        {
             context = juce_createOpenGLContext (owner,
                                                 sharedContext != 0 ? sharedContext->context
                                                                    : 0);
+            if (context != 0)
+                componentMovedOrResized (true, true);
+        }
     }

     //==============================================================================
@@ -144,12 +148,24 @@
     //==============================================================================
     void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/)
     {
-        Component* const topComp = owner->getTopLevelComponent();
-
-        if (topComp->getPeer() != 0)
+        if (owner->getWidth() > 0 && owner->getHeight() > 0)
         {
-            juce_updateOpenGLWindowPos (context, owner, topComp);
-            needToUpdateViewport = true;
+            Component* const topComp = owner->getTopLevelComponent();
+
+            if (topComp->getPeer() != 0)
+            {
+                needToUpdateViewport = true;
+
+                if (context == 0)
+                {
+                    if (owner->isShowing())
+                        initialise();
+                    else
+                        return;
+                }
+
+                juce_updateOpenGLWindowPos (context, owner, topComp);
+            }
         }
     }

… since it can then be applied automatically, taking the guesswork out of whether I’m interpreting your prose correctly… (who knows maybe the above is incorrect?)

btww, the demo Makefile is missing a dependency of the juce library, once I remade the library, the demo thought it was still up to date.

btwww, when the demo ran it incorrectly thought the Xeon’s didn’t have hyperthreading, which I know is on in the bios:
CPU has hyperthreading: no
.

I don’t actually have a patch utility on my main machine - it’s much quicker for stuff like this to just paste a new function over an old one. Saves mucking about with the command line and you can see what you’re doing, too.

It does sound like your problem’s the same as the one above though (?)

patch utility? i used:

diff -Nuar oldfile newfile > patchfile.patch

(don’t actually need the ‘r’ for one file)

any *nix should have diff…

But yeah, evidently it’s not… I posted the OpenGL support the system is reporting, so what’s wrong?

Not sure what could be wrong - the demo runs fine on my ubuntu system. I’ll take a look next time I’m doing some linux stuff (I spend most of my time working on windows)