Building wxWidgets from sources changed OpenGL vendor

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
User avatar
LukasLang
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Jan 24, 2023 10:53 am

Building wxWidgets from sources changed OpenGL vendor

Post by LukasLang »

I am currently trying to get a simple demo example using wxGLCanvas to run without issues. I was originally using the wxWidgets version installed via

Code: Select all

sudo apt install libwxgtk3.0-gtk3-dev
(this is on Ubuntu 20.04.5 LTS), this caused some issues however. As the wxWidgets version is 3.0.4 when using this installation method, I decided to build wxWidgets following the instructions here. I first ran

Code: Select all

sudo apt install libgtk-3-dev libglu1-mesa-dev libgl1-mesa-dev
to install the prerequisites as instructed, and the proceeded with the build steps. I could then successfully rebuild my project using the updated wxWidgets version, and the issues I was having which the older version seem to have been fixed. However, I am now running into another problem, which I think is causing issues for the next step I want to do. Specifically, the line

Code: Select all

printf("Vendor: %s, Renderer: %s, Version: %s\n", glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION));
prints
Vendor: NVIDIA Corporation, Renderer: NVIDIA RTX A5000/PCIe/SSE2, Version: 4.6.0 NVIDIA 525.60.13
when using the old 3.0.4 version of wxWidgets install via apt, but it prints
Vendor: Mesa/X.org, Renderer: llvmpipe (LLVM 12.0.0, 256 bits), Version: 3.1 Mesa 21.2.6
on the 3.2.1 version built from source.

Since I need to use OpenGL together with CUDA in the end, I think this change what OpenGL version is used is causing problems (at least this is the only difference between the two versions that I could find). How can I configure wxWidgets to select the correct OpenGL version when building from source?
Manolo
Can't get richer than this
Can't get richer than this
Posts: 780
Joined: Mon Apr 30, 2012 11:07 pm

Re: Building wxWidgets from sources changed OpenGL vendor

Post by Manolo »

the wxWidgets version is 3.0.4
This old version will limit you to OpenGL 2.1 or less. Starting with wx 3.1 you can use any OGL version.
.
sudo apt install libgtk-3-dev libglu1-mesa-dev libgl1-mesa-dev
I prefer mesa-common-dev instead of libgl1-mesa-dev because the later will provide OpenGL 1, while the former may give you any OGL version.
Not sure, perhaps you need libgl1-mesa-dri too.

wxWidgets knows nothing about glGetString(), It's a OGL command. Its output depends completely on the driver.

The different outputs come from the libs you installed or not.

If you have more than one ghx-card you can use "sudo prime-select nvidia" to force the use of Nvidia one.
User avatar
LukasLang
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Jan 24, 2023 10:53 am

Re: Building wxWidgets from sources changed OpenGL vendor

Post by LukasLang »

Thank you for your reply!
I prefer mesa-common-dev instead of libgl1-mesa-dev because the later will provide OpenGL 1, while the former may give you any OGL version.
Not sure, perhaps you need libgl1-mesa-dri too.
I tried to remove libgl1-mesa-dev and libglu1-mesa-dev and installed mesa-common-dev instead. Unfortunately, it seems that libgtk-3-dev depends on libgl1-mesa-dev, and

Code: Select all

../configure --with-gtk --with-opengl
complains about the missing GL/glu.h header when not explicitly installing libglu1-mesa-dev. So in the end, it seems that I do need both libgl1-mesa-dev and libglu1-mesa-dev? Finally, libgl1-mesa-dri appears to have already been installed.
wxWidgets knows nothing about glGetString(), It's a OGL command. Its output depends completely on the driver.

The different outputs come from the libs you installed or not.
That makes sense, but what am I doing wrong in that case? The only things I change between the two outputs are the include directories & library directories for the compiler & linker:

For the old version:

Code: Select all

INCLUDES  := -isystem /usr/include/python3.8 -isystem ../include/ -I../ -isystem /usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0 -isystem /usr/include/wx-3.0
LIBRARIES := -lspcm_linux -lcuda -lpython3.8 -lcufft_static -lculibos -lcurand -l:libboost_atomic.a -lGL -lGLU -L/usr/lib/x86_64-linux-gnu -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_qa-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_gl-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0
For the new version:

Code: Select all

INCLUDES  := -isystem /usr/include/python3.8 -isystem ../include/ -I../ -isystem /usr/local/lib/wx/include/gtk3-unicode-3.2 -isystem /usr/local/include/wx-3.2
LIBRARIES := -lspcm_linux -lcuda -lpython3.8 -lcufft_static -lculibos -lcurand -l:libboost_atomic.a -lGL -lGLU -L/usr/local/lib -lwx_gtk3u_xrc-3.2 -lwx_gtk3u_html-3.2 -lwx_gtk3u_qa-3.2 -lwx_gtk3u_core-3.2 -lwx_gtk3u_gl-3.2  -lwx_baseu_xml-3.2 -lwx_baseu_net-3.2 -lwx_baseu-3.2
So it must be something about the way I am builidng/installing/using wxWidgets, or am I missing something else?
If you have more than one ghx-card you can use "sudo prime-select nvidia" to force the use of Nvidia one.
I also tried this, unfortunately without any success.
Last edited by LukasLang on Wed Jan 25, 2023 9:14 am, edited 1 time in total.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 780
Joined: Mon Apr 30, 2012 11:07 pm

Re: Building wxWidgets from sources changed OpenGL vendor

Post by Manolo »

it seems that I do need both libgl1-mesa-dev and libglu1-mesa-dev?
Using mesa-common-dev instead of libgl1-mesa-dev works for me.
And yes, libglu1-mesa-dev is required by wx. Some day it may become not needed.

You are not doing anything wrong. It's a matter of what graphics driver is active. It can be Mesa or Nvidia.
And this is not exact, because when you install Nvidia driver it should make Nvidia libs as the current.
Some times is Mesa the always-current lib and redirects to installed (Nvidia, AMD, Intel) driver (that's why I suggested libgl1-mesa-dri (Direct Rendering Interface)

Your issue has nothing to do with wx. I know it does seem so because it happens you do a change in your wx version. But again, this is not related to wx, except if you link to different libs, which is not the case, right?

I advice searching and learning about how to know the hardware installed in you PC, how to select a specific, primary, driver, and the particular Nvidia case.

Mmmm, I know near nothing on python. But isn't it true that it handles its own GL includes and libs? How does it interact with wx-gl lib?
Post Reply