Question

I installed the wxWidgets source code, compiled it and am linking the libraries thus obtained with my application code. Now I need to use OpenGL in my wxWidgets application. How do I enable this?

Was it helpful?

Solution

For building on Windows with project files:

Assume $(WXWIDGETSROOT) is the root directory of your wxWidgets installation.

  1. Open the file $(WXWIDGETSROOT)\include\wx\msw\setup.h
  2. Search for the #define for wxUSE_GLCANVAS.
  3. Change its value from 0 to 1.
  4. Recompile the library.

For building on Linux and other ./configure based platforms:

Just use ./configure --with-opengl

(A mashup answer from two partial answers given by others)

OTHER TIPS

If you're using configure to build wxWidgets you just need to add --with-opengl to your command line.

Just to add a little bit... If you're on linux you need to watch the logs when running configure. If it can't find opengl dev packages then it will turn opengl off with one line of warning which is easy to miss.

run it like this to make it more obvious what development libraries you're actually missing (it looks like the --with-opengl is on by default in 3.0.0 and possibly earlier versions of wxwidgets, but it can't hurt to include it I suspect).

./configure --with-opengl > configure.log

Once configure can find all the dev libs you think you're going to use you need to rebuild wxwidgets:

make
sudo make install 

I had to install these on linux mint to make wxwidget's configure happy as far as opengl was concerned (and should also work for ubuntu) to get the dev libs I needed.

sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev

(Assume $(WX_WIDGETS_ROOT) is the root directory of your wxWidgets installation.)

  1. Open the file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h
  2. Search and find the option wxUSE_GLCANVAS. Change its value from 0 to 1.
  3. Recompile the library.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top