OpenGL Samples broken in 3.1.0 ?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

OpenGL Samples broken in 3.1.0 ?

Post by faradayent »

MinGW (4.9) build of samples including OpenGL penguin and isosurf seem to work just fine.

When samples for 3.1.0 are built (gcc_mswudll), they work fine (AFAIK), except for those in the OpenGL folder.

When penguin.exe is executed I get:

../../src/msw/glcanvas.cpp(767):assert ""Assert failure"" failed in Create(): Can't find a pixel format for the requested attributes
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: OpenGL Samples broken in 3.1.0 ?

Post by doublemax »

They work for me.

Which Windows version?
Did they still work in 3.0.2 for you?
Use the source, Luke!
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by faradayent »

Hi doublemax,
I went ahead and built the libraries and wxWidgets on an XP (32 bit) machine just to check. Isosurf works on it both in 3.0.2 and 3.1.0.

On the Win7 (64 bit Win7 Professional) machine, the 3.0.2 build of wxWidgets and Isosurf works. The 3.1.0 build of wxWidgets and Isosurf fails.

It fails on both the unicode release, and debug versions with the following errors:

1st Alert Box-
../../src/msw/glcanvas.cpp(767):assert ""Assert failure"" failed in Create(): Can't find a pixel format for the requested attributes

2nd Alert Box-
../../src/msw/glcanvas.cpp(578): assert ""tempContext"" failed in wxGLContext(): wglCreateContext failed!

Then Isosurf comes up without the desired graphic in it, but with a little black square in the upper left corner. The info dialog pops up saying it loaded 7179 vertices.

Also, copying the working app from the XP machine onto a memory stick and running it on the Win7 machine causes the same error.

One more note, although I hope it doesn't matter - The working XP machine is running OpenGL 2.1.2. The Win7 machine is running 1.1.0 (I can't upgrade the video card or drivers because I'm running dual monitors and this is the only one that will work).

Since I have one working machine (XP) and can develop on that, this isn't super critical, but I thought I'd mention it in case someone else runs into it.
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: OpenGL Samples broken in 3.1.0 ?

Post by doublemax »

The Win7 machine is running 1.1.0
This sounds pretty outdated.

However, it it worked with wxWidgets 3.0.2 and doesn't with 3.1.0, it might be worth opening a bug report about it. http://trac.wxwidgets.org/
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OpenGL Samples broken in 3.1.0 ?

Post by ONEEYEMAN »

Hi,
There was a pretty big rework of OpenGL recently.
You can checkout the recent OpenGL ticket(s) and the discussion in there.

Thank you.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo »

It seems to me that your problem arises from using a driver with only OGL 1.1
Please, in wx 3.1.0 remove lines 183 to 186 at src/common/glcmn.cpp (using PlatformDefaults()), compile wx again and let us know if now it works.
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by faradayent »

"Please, in wx 3.1.0 remove lines 183 to 186 at src/common/glcmn.cpp"

Nope, sorry, didn't work, same errors.

I started from fresh 3.1.0 source, commented out lines indicated, built widgets and samples under MinGW 4.9.3 with
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" MONOLITHIC=0 SHARED=1 UNICODE=1 USE_OPENGL=1 USE_MOUSEWHEEL=1 BUILD=debug
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo »

Strange. For what I see those lines were the only relevant difference between wx 3.0 & 3.1 for the isosurf sample.
Can you post a backtrace when it fails? Or better, can you look for the differences using a debugger?
I would do myself, but I don't have such an old card with only OGL 1.1

Mmmm... does it happens if you run only one monitor, even with the old driver?
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by faradayent »

Manolo,
I've been running that system with only one monitor attached, and the system that it works on has two attached.

I'm moving on, unfortunately can't spend any more time on this. Thanks for trying to help!
EverythingsShiny
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Dec 04, 2014 3:10 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by EverythingsShiny »

Has there been any update on this? I am seeing the same issue being reported to me from some users of my software. We have a distribution of a couple hundred people and we are seeing this issue on around 5-10% of the installs. It seems more prevalent on older Windows computers but there has been at least 1 report on a Mac.

One person reported that the error went away when they upgraded OpenGL on their Windows 7 machine. I have a Windows 10 box and a Mac Mini but I am not seeing the error on either of them.
Screen shot 2016-07-06 at 8.32.05 PM.png
You do not have the required permissions to view the files attached to this post.
faradayent
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sat Dec 12, 2009 3:13 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by faradayent »

"Has there been any update on this?"

No, I moved on to something else and haven't had time to re-visit.

Sorry you're having troubles too.
EverythingsShiny
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Dec 04, 2014 3:10 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by EverythingsShiny »

Thanks, I'll see if I can work anything out.
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Kerry »

I am having the same issue with wx3.1.0 under GTK with OpenGL 2.1. On a machine with new hardware the samples work fine. They also work fine on the older machine with 3.0.2. I've found that wxGLCanvas::IsDisplaySupported() method correctly predicts whether or not the canvas can be created without crashing, but there is no combination of parameters where it returns true for wx3.1.0.

I haven't fully identified the bug, but it does seem that wxGLAttributes::GetGLAttrs() returns unexpected results:

Code: Select all

void PrintArray(const int a[])
{
    int i(0);
    while (a[i])
    {
        std::cout << a[i++] << "   ";
    }
}

int main()
{
    int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
    std::cout << "int[] => ";
    PrintArray(args);
    std::cout << std::endl;

    wxGLAttributes attr;
    attr.RGBA().DoubleBuffer().EndList();
    std::cout << "wxGLA => ";
    PrintArray(attr.GetGLAttrs());
    std::cout << std::endl;

    return 0;
}

Gives these results:

Code: Select all

int[] => 1   4   
wxGLA => 32785   1   5   1 
So either 32785 or 5 prevent compatibility with my old hardware. 5 corresponds to WX_GL_STEREO, which is definitely not what I asked for, and 32785 is not a valid flag. wxGLAttributes is new in 3.1, so it makes sense that this is the culprit.

I'll keep poking around to see if I can narrow down the source and come up with a patch.

-Kerry
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Kerry »

I dug a little deeper, and it looks like wxGLAttributes is hiding some things that we used to have to do explicitly. For example, if we specified WX_GL_RGBA as an attribute, it ends up being passed (unaltered) to a platform-specific call to initialize the canvas (under GTK, this is InitXVisualInfo()).

In wx3.1.0, if we use the int[] style attributes, behind the scenes a wxGLAttributes object is built based off of the int[] array, and then the canvas is created using the wxGLAttributes. But when we call wxGLAttributes::RGBA(), it's doing this (under GTK):

Code: Select all

wxGLAttributes& wxGLAttributes::RGBA()
{
    if ( wxGLCanvasX11::GetGLXVersion() >= 13 )
        AddAttribBits(GLX_RENDER_TYPE, GLX_RGBA_BIT);
    else
        AddAttribute(GLX_RGBA);
    return *this;
}
Under windows it looks like this:

Code: Select all

wxGLAttributes& wxGLAttributes::RGBA()
{
    AddAttribute(WGL_PIXEL_TYPE_ARB);
    AddAttribute(WGL_TYPE_RGBA_ARB);
    AddAttribute(WGL_COLOR_BITS_ARB);
    AddAttribute(24);
    AddAttribute(WGL_ALPHA_BITS_ARB);
    AddAttribute(8);
    return *this;
}
So the result is that it's different than when we build the int[] array and use 3.0.2.

The other odd thing is that previously the WX_GL_XXX flags were passed directly to the initialization function, but now the same function is called with (in the case of GTK) GLX_XXX flags, which do not have identical definitions.

I'm thinking now that the odd part is that it works at all. Why doesn't newer OpenGL complain, too?

-Kerry

Edit: Opened ticket http://trac.wxwidgets.org/ticket/17595
EverythingsShiny
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Dec 04, 2014 3:10 am

Re: OpenGL Samples broken in 3.1.0 ?

Post by EverythingsShiny »

I'm not sure this addresses the original issue but I managed to find a workaround using the new constructor for wxGLCanvas, the one that uses wxGLAttributes.

I set up my attributes like this:

Code: Select all

  wxGLAttributes glAttributes;
  glAttributes.PlatformDefaults().MinRGBA(8,8,8,8).DoubleBuffer().Depth(24).EndList();
The key seems to be Depth(24). Using Depth(32) caused the same error to appear on my Windows 10 laptop as on the older systems. I am testing on an old Windows XP system which was displaying the original error; it has OGL 1.4 installed on it.
I'm thinking now that the odd part is that it works at all. Why doesn't newer OpenGL complain, too?
I bet the applied values are valid for new versions of OpenGL but one of them is out of range for older OpenGL installs.