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 » Wed Apr 21, 2021 11:58 am

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: 5154
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN » Wed Apr 21, 2021 12:07 pm

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 » Wed Apr 21, 2021 12:50 pm

Because the samples do not use external libraries to enable opengl extensions.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5154
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN » Wed Apr 21, 2021 1:47 pm

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 » Wed Apr 21, 2021 6:09 pm

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: 5154
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Glew init error with GTK3 wx 3.1.5

Post by ONEEYEMAN » Wed Apr 21, 2021 6:32 pm

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: 729
Joined: Mon Apr 30, 2012 11:07 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by Manolo » Wed Apr 21, 2021 7:42 pm

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 » Wed Apr 21, 2021 8:35 pm

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
Super wx Problem Solver
Super wx Problem Solver
Posts: 449
Joined: Fri Nov 03, 2006 2:00 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by stahta01 » Sun Apr 25, 2021 2:41 am

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

Tim S.

stahta01
Super wx Problem Solver
Super wx Problem Solver
Posts: 449
Joined: Fri Nov 03, 2006 2:00 pm

Re: Glew init error with GTK3 wx 3.1.5

Post by stahta01 » Sun Apr 25, 2021 2:42 am


Post Reply