OpenGL under WxWidgets in Eclipse Topic is solved

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
Phantom
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Feb 01, 2019 2:05 pm

OpenGL under WxWidgets in Eclipse

Post by Phantom »

Hello dear people,

For my bachelor thesis, I have to make a frame under WxWidgets with a button '' Open File '', read out a .ptm file and use it to display a human phantom in 3D format in the window. The 3D object is to be created under OpenGL. Of course everything in C ++.

I have managed to compile WxWidgets and create a frame with the button '' Open File ''.
Now to my questions:

1. How can I compile OpenGL under Wxwidgets in Eclipse (Windows)
2. Do you happen to have an example of a cube ...

Please help me. I am really desperate. Many Thanks.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OpenGL under WxWidgets in Eclipse

Post by ONEEYEMAN »

Hi,
This is very simple task.

1. cd wxWidgets\sample\opengl\cube\
2. mingw32/64 -f makefile.gcc <set_of_options_you_used_when_compiling_library>
3. ./cube.exe

Now open the source code and do the same.

I presume you already have a handler for your button?

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: OpenGL under WxWidgets in Eclipse

Post by Manolo »

"cube", "isosurf", and "penguin" at samples/opengl folder are examples for old OpenGL 1.1

Modern OpenGL (>=3.2) requires much more setting: context (this has been always required), function pointers retriever, maths. But it's much more powerfull and featured. Speed is also improved if you manage large data.

wxWidgets provides context handling. The rest is up to you. You can use good libraries like Glew (function pointers stuff), and Glm (maths).

The "pyramid" sample is for OpenGL 3.2. It doesn't use glew nor glm, but implements things on its own.
Phantom
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Feb 01, 2019 2:05 pm

Re: OpenGL under WxWidgets in Eclipse

Post by Phantom »

Thanks so far.

Is OpenGL working with MinGW? And which libraries should I insert for the Linker?
I would then prefer to implement the "Pyramide". Thank you for more answers :)
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OpenGL under WxWidgets in Eclipse

Post by ONEEYEMAN »

Hi,
The simplest answer is to build the sample and look at the command used. ;-)
And yes - I believe OpenGL does work with any compiler, as it is hardware specific.

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: OpenGL under WxWidgets in Eclipse

Post by Manolo »

Includes:
<gl.h>
If you use OGL>3 then also glext.h. This file can be downloaded from official https://www.khronos.org/registry/OpenGL/index_gl.php . The pyramid sample uses parts of it.
I think that if you use glew then you already have that file.

Don't forget to compile wxWidgets with USE_OPENGL=1 and to add opengl32 lib to your app.
Phantom
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Feb 01, 2019 2:05 pm

Re: OpenGL under WxWidgets in Eclipse

Post by Phantom »

How can I compile --> wxWidgets with USE_OPENGL=1 <--?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OpenGL under WxWidgets in Eclipse

Post by ONEEYEMAN »

Manolo,
He doesn't use the "CMake thing".
Phantom,
If you compiled wxWidgets with just a default parameters, then this option is already set by default.

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: OpenGL under WxWidgets in Eclipse

Post by Manolo »

Using Mingw compiler, the OpenGL option is NOT default.

A typical command is

Code: Select all

mingw32-make -f makefile.gcc BUILD=release USE_OPENGL=1
which will build a static (.a files to be linked to your executable), not-debug version, with OGL support of wx

After building, you should see the file libwxmsw31u_gl.a in the yourwxdir\lib\gcc_lib folder (or similar name)

If you have used other command/way, please post it here.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: OpenGL under WxWidgets in Eclipse

Post by PB »

Manolo wrote:Using Mingw compiler, the OpenGL option is NOT default.
Is it not? FWIW, when I build wxWidgets master with MinGW-w64 with GCC 8.1 using provided makefile, there is file libwxmsw31u_gl.a for the static build and files libwxmsw31u_gl.a and wxmsw313u_gl_gcc_custom.dll for the dynamic one. The only make parameters I changed were BUILD and SHARED as well as CXXFLAGS="-std=c++17"...

WXWIN/msw/build/config.gcc contains (for master, 3.1.1, and 3.04)

Code: Select all

# Build OpenGL canvas library (USE_GUI must be 1)? [0,1]
USE_OPENGL ?= 1
However, the same setting defaults to 0 in v2.8.12...
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL under WxWidgets in Eclipse

Post by Manolo »

PB wrote: Is it not?
Dam. PB, you're right.
I found the commit... May 31, 2009
Actually, it was added to wx 3.0. Not to wx 2.9
User avatar
TwistedSpace
In need of some credit
In need of some credit
Posts: 6
Joined: Tue Mar 05, 2019 7:59 am

Re: OpenGL under WxWidgets in Eclipse

Post by TwistedSpace »

Manolo wrote: Tue Feb 05, 2019 1:52 pm and to add opengl32 lib to your app.
I'm just wondering why is it opengl32 and not opengl64?
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: OpenGL under WxWidgets in Eclipse

Post by Manolo »

The history of OpenGL in MS Windows is weird.
opengl32 was chosen when XP saw the light, as opposed to Win 9X 16 bits. Since then, the name still stands, despite it's for 32 or for 64 bits.
Post Reply