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.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 713
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo » Thu Jul 14, 2016 11:30 pm

First of all, thank you for trying to find the root of the problem and a solution.

Second, OGL Specifications usually are not very well respected. Some manufactures and also some driver-developers (Mesa included) make some sort of "own version", and some bugs. The result is that the same code may work or not on different machines and OS's.
Anyone coding with OGL will meet this issue. Worst, how many different machines do you have to make tests?

There are four kinds of problems:
a) Display attributes.
b) Context attributes and its creation.
c) OGL errors.
d) Application crashing.

wxWidgets provides testing for 'a' (wxGLCanvas::IsDisplaySupported) and 'b' (wxGLContext::IsOK). In the 'pyramid' sample (new in wx 3.1) you can find a little function for catching 'c'. For 'd' there's no easy way. While wx may give you a little info (assert...), usually it's you to fix it.

Third, the changes from wx 3.0 to wx 3.1 relating apps that worked in 3.0 but not in 3.1, are those for default attributes. For example, as Kerry found, RGBA() in Unix now _does_ set {GLX_RENDER_TYPE, GLX_RGBA_BIT} (i.e. 32785, 1 ints), while in wx 3.0 it did nothing, asuming RGBA is a display default. If it does not work now, the culprit is the Unix driver, not wx. More on this, you can read glx 1.3 specification https://www.opengl.org/registry/doc/glx1.3.pdf and a sample using these attributes https://www.opengl.org/sdk/docs/man2/xhtml/glXIntro.xml
There's also another change, those 3 lines at src/common/glcmn.cpp I told in this thread before. They will affect very very old (let's say before 2003) hardware only.

Last, solution? Well, patience is your friend :)
Don't presume that a particular attribute (even basic as RGBA) will be OK for all machines. You cant test one by one using those two tests provided in wx 3.1. And even it's pretty rare, don't presume neither that failing an attribute means it doesn't work (again, RGBA example).
If you want to set attrbutes on your own (not the provided by wx) you can do it using wxGLAttribsBase::AddAttribute and wxGLAttribsBase::AddAttribBits

That long speach being said, I will continue to do my best on fixing any wx bug that you will find. Thank you four your digging and debugging.

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 » Sat Jul 16, 2016 3:22 pm

Thank you! I appreciate all your hard work in figuring this out (working mostly in embedded stuff I lacked the expertise to do it).

Is it likely that the solution will be rolled into a future release of Widgets?

Manolo
Can't get richer than this
Can't get richer than this
Posts: 713
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo » Sat Jul 16, 2016 7:30 pm

There's an opened ticket at http://trac.wxwidgets.org/ticket/17425 The patch wxGLContext_ctor_x11Direct20160316.patch would solve these Unix issues with old hardware. Would you main testing it?

Each time a solution for a wx problem is found, it goes with the next release. Well, if someone has tested if before :) and doesn't generate new problems :)
OpenGL issues are difficult to fix, just because it is not as well implemented as C++ standards, specially in old drivers.

Manolo
Can't get richer than this
Can't get richer than this
Posts: 713
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo » Mon Jul 25, 2016 11:44 pm

For those waiting for a solution, I say that it seems a problem with default attributes.
I'm working on it and will provide patches soon.

If you are in a hurry and can't wait, then, for old hardware:
** Don't use wxGLAttributes::Defaults(). wxGLAttributes::PlatformDefaults() may work, I'm not sure.
* *Don't use an empty list of attributes, it will set wxGLAttributes::Defaults().
** Don't use wxGLAttributes::RGBA(), prefer wxGLAttributes::MinRGBA(r,g,b,a) with low values.
** For Unix, use the patch I told in my last post in this thread.

Anyhow, some testing from those having problems will be very very appreciated. I can not test every feature in every hardware.

Also... it's not easy to decide about defaults, specially if we are concerned about backwards compatibility. I'd like to know your own experiences.

Manolo
Can't get richer than this
Can't get richer than this
Posts: 713
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL Samples broken in 3.1.0 ?

Post by Manolo » Tue Aug 30, 2016 3:35 pm

I've added a patch GLReworkOldHardware20160830.patch at http://trac.wxwidgets.org/ticket/17425 that I expect to solve the issues with old hardware.

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 » Sun Sep 04, 2016 2:53 pm

I was finally able to test your patch on my system (under GTK), and I can confirm that it solved the problem for me :D

Thanks!

-Kerry

Post Reply