OpenGL in wxWidgets

379 views
Skip to first unread message

Karl Karpfen

unread,
Mar 2, 2016, 5:09:12 AM3/2/16
to wx-users
Hi,

I'm already familar with the concept of wxGLContext and its usage. But from what I see, it seems to contain OpenGL 1.0/1.1 functions only. Under Linux it is no problem to just to link some additional libraries to get newer functions, under Windows there is an additional, 3rd party wrapper-library/DLL required. Both are of course platform-specific solutions.

So my question: what is the intended way to have at least OpenGL 2.1 functions? Is there something in wxWidgets which provides a platform-independent way I may have overseen?

Cheers

Karl


Jim Orcheson

unread,
Mar 2, 2016, 5:58:29 AM3/2/16
to wx-u...@googlegroups.com, karlka...@gmail.com
Hi Karl,

I don't think there is anything in wxWidgets that will directly give you
OpenGL 2+, so you do need that 3rd part wrapper library / DLL thing that
you called it.

I recently wrote a couple of blog posts on OpenGL on Windows and using
OpenGL with wxWidgets in Visual Studio. Of course, much of what I wrote
can be used with other IDEs as well. Here are the links to my posts:

https://usingcpp.wordpress.com/2016/02/10/opengl-graphics/
https://usingcpp.wordpress.com/2016/02/13/visual-studio-wxwidgets-and-opengl/

Hope those help.

Jim
> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to wx-users+u...@googlegroups.com
> or visit http://groups.google.com/group/wx-users

Igor Korot

unread,
Mar 2, 2016, 6:34:41 AM3/2/16
to wx-u...@googlegroups.com
Hi, Karl,
You can use recently released 3.1, where there is support for OpenGL
up to version
3 (I think). If it is not available, wxWidgets will select prior version.

Check the new sample 3.1 distribution as well (opengl/pyramid).

Thank you.

Eric Jensen

unread,
Mar 2, 2016, 6:38:01 AM3/2/16
to Karl Karpfen
Hello Karl,

Wednesday, March 2, 2016, 11:09:12 AM, you wrote:

KK> Hi,


KK> I'm already familar with the concept of wxGLContext and its
KK> usage. But from what I see, it seems to contain OpenGL 1.0/1.1
KK> functions only. Under Linux it is no problem to just to link some
KK> additional libraries to get newer functions, under Windows there
KK> is an additional, 3rd party wrapper-library/DLL required. Both are
KK> of course platform-specific solutions.


KK> So my question: what is the intended way to have at least OpenGL
KK> 2.1 functions? Is there something in wxWidgets which provides a
KK> platform-independent way I may have overseen?

http://docs.wxwidgets.org/trunk/glcanvas_8h.html#wxGL_FLAGS

I don't know too much about OpenGL, but check out the
WX_GL_MAJOR_VERSION, WX_GL_MINOR_VERSION and WX_GL_CORE_PROFILE flags.

Maybe that's what you need.

Eric





--

Karl Karpfen

unread,
Mar 2, 2016, 8:14:41 AM3/2/16
to wx-u...@googlegroups.com
Version 3.1 sounds great - but isn't this a development version any more? I remember from 2.9 it was never official released to end users...

Vadim Zeitlin

unread,
Mar 2, 2016, 8:18:29 AM3/2/16
to wx-u...@googlegroups.com
On Wed, 2 Mar 2016 14:14:39 +0100 Karl Karpfen wrote:

KK> Version 3.1 sounds great - but isn't this a development version any more?

Quoting from the release announcement on www.wxwidgets.org:

Please notice that while 3.1.0 is officially a "development" version
because it is not fully compatible with 3.0.x, the list of backwards
incompatible changes is very short, so you shouldn't have any problems
updating to this version from 3.0.x in practice, and you're encouraged to
try this version out and use it in production in spite of its odd version
number.

All "development" means in this context is that we haven't committed to
keeping stable ABI.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Manolo

unread,
Mar 2, 2016, 9:56:49 PM3/2/16
to wx-users
Starting with OGL ver. 3.0 there are two kind of OGL rendering contexts: 'compatibilty' and 'core'. "Core Profile" will use only modern functions, while "Compatibility" will use all, old or new ones.
New wxWidgets 3.1 allows to use *any* available OGL version by using special atributes at wxGLContext creation.
Please, read http://docs.wxwidgets.org/trunk/classwx_g_l_context.html and related classes. And also take a look at the new 'pyramid' sample.

Selecting an specific OGL version is a matter of using wxGLContextAttrs::OGLVersion(ma,mi) and using the apropiate 'core' or 'compatibility' attribute.
OGLVersion() delegates the version selection to the GPU driver. On OSX you just use 'core' or 'compatibility'. You can use wxGLContext::IsOK() to check if the requested version was set or else failed.

So, for OGL 2.1:
wxGLContextAttrs ctxAttr;
ctxAtrr.CompatibilityProfile().OGLVersion(2, 1).EndList();

In order your app will use functions beyond OGL 1.1, you need to link to 'opengl32.dll' in Windows (file provided by GPU vendor). Link to 'GL' in Linux.

Karl Karpfen

unread,
Mar 3, 2016, 2:57:20 AM3/3/16
to wx-u...@googlegroups.com
Hello Manolo,

this part is not clear for me:

2016-03-03 3:56 GMT+01:00 Manolo <mano...@gmail.com>:
In order your app will use functions beyond OGL 1.1, you need to link to 'opengl32.dll' in Windows (file provided by GPU vendor). Link to 'GL' in Linux.


Apart from the linking procedure (which should work with any opengl32.lib) I do not have an idea which graphics adapter is used on end users side. So isn't it wrong to assume there exists a opengl32.dll on every target system? How about GPU-vendors that do not provide a opengl32.dll or a variant that does not fit to my link-opengl32.lib?

Kind regards

Karl



Igor Korot

unread,
Mar 3, 2016, 6:26:46 AM3/3/16
to wx-u...@googlegroups.com
Karl,
If opengl32.lib is not redistributable you can link everything statically.

Thank you.

>
> Kind regards

Manolo

unread,
Mar 3, 2016, 8:18:49 AM3/3/16
to wx-users
MIcrosoft does not provide OGL lib for OGL >1.1. But vendors do.
When the user installs the GPU driver opengl32.dll gets also installed (this is not precise, but you can see what I'm talking about). In other words, the file should always be available, as any other system lib.
Creating an OGL context means asking that driver for the required version.

About what features the driver has, use IsOK(). For a very old driver (<2007) most wxGLContextAttrs parameters will fail. In that case, try with an empty list, I mean, no parameters except EndList(). This would ask the driver to set a context in the old way. Likely in such an old machine, the OGL version would be 2.1
Anyhow, I repeat, opengl32.dll should be available even for such old cards.

Reply all
Reply to author
Forward
0 new messages