Glew init error with GTK3 wx 3.1.5

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

Glew init error with GTK3 wx 3.1.5

Post by thoray »

glewInit() gives "Unknown error" with WX 3.1.5 when wx is compiled with '--with-gtk=3'. It works with GTK2 and on all the other platforms. Opengl samples do work. I call glewInit() in OnPaint() for wxGLCanvas. It also used to work with older wx versions. This is Debian bullseye.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN »

Hi,
Why can't you modify your code to match the sample?

Thank you.
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

Re: Glew init error with GTK3 wx 3.1.5

Post by thoray »

Because the samples do not use external libraries to enable opengl extensions.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN »

Hi,
Can you at least explain why you are initializing it the paint event?

Thank you.
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

Re: Glew init error with GTK3 wx 3.1.5

Post by thoray »

No particular reason, just the way its currently done. I guess calling glewInit() could be moved to the constructor.

I really only needed GTK3 version for some testing so this is not a huge deal for me.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN »

Hi,
It is possible that calling it inside the OnPaint() is already too late.

So I would try to move it in the init routine of you frame and try again. There uis a reason for it to be called "init" ;-)

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

Re: Glew init error with GTK3 wx 3.1.5

Post by Manolo »

Calling glewinit() from a paint-event doesn't seem a good idea. I find two reasons:
a) Unless you set some flag, you're calling glewinit() time and time and time...
b) In GTK the paint event may be handled before the window is realized. This means you can not set the gl-context as current, which is required before any glew call.

If you take a look at the pyramid sample you'll find that any gl initialization is done at OnSize event handler. And with some checks, just because the "window not realized yet" issu in GTK.
This wx sample handles OGL in a very similar way glew does.
thoray
Knows some wx things
Knows some wx things
Posts: 48
Joined: Sun Oct 18, 2015 9:31 am

Re: Glew init error with GTK3 wx 3.1.5

Post by thoray »

I tried moving glewinit() to OnSize() with " if ( !IsShownOnScreen() ) return; " test, and getting gl context in constructor like with pyramid sample but it didn't change anything.

I am doing a very similar check in OnPaint() anyway.

Since this code was working earlier with GTK3 I presume it is some change in either recent wx or Debian's gtk 3 dev package that breaks glewinit().

I tried adding glewinit() into the penguin sample at OnSize() and it failed there too.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by stahta01 »

Did you read this post?
viewtopic.php?t=29239

Tim S.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 548
Joined: Fri Nov 03, 2006 2:00 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by stahta01 »

debeus
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Aug 05, 2022 5:40 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by debeus »

This problem is reproducibly fixed with patching glew to
include egl for wxWidgets =< 3.1.5 including 3.2.0

See https://bbs.archlinux.org/viewtopic.php?id=278127
and the the AUR page for the patched version on Arch and its derivatives.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN »

Hi,
Please open an issue at github.com/wxwidgets with the reference to the patch.
This is user forum and this will not be visible to the core developers.

Thank you.
debeus
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Aug 05, 2022 5:40 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by debeus »

Post Reply