Page 1 of 1

OpenGL under WxWidgets in Eclipse

Posted: Fri Feb 01, 2019 4:29 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Fri Feb 01, 2019 4:58 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Fri Feb 01, 2019 6:30 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Fri Feb 01, 2019 9:30 pm
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 :)

Re: OpenGL under WxWidgets in Eclipse

Posted: Fri Feb 01, 2019 10:01 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Tue Feb 05, 2019 1:52 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Tue Feb 05, 2019 1:58 pm
by Phantom
How can I compile --> wxWidgets with USE_OPENGL=1 <--?

Re: OpenGL under WxWidgets in Eclipse

Posted: Tue Feb 05, 2019 3:56 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Tue Feb 05, 2019 6:12 pm
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.

Re: OpenGL under WxWidgets in Eclipse

Posted: Tue Feb 05, 2019 9:29 pm
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...

Re: OpenGL under WxWidgets in Eclipse

Posted: Wed Feb 06, 2019 1:57 am
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

Re: OpenGL under WxWidgets in Eclipse

Posted: Thu Mar 07, 2019 3:40 am
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?

Re: OpenGL under WxWidgets in Eclipse

Posted: Fri Mar 15, 2019 5:27 pm
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.