OpenGL Programming/Installation/Windows

From Wikibooks, open books for an open world
Jump to: navigation, search

All version of Windows from Windows 95 come with an OpenGL implementation (usually version 1.4). However, if you installed (or updated) the drivers for your graphics card it's probable that you're using your board manufacturer's own implementation of OpenGL.


The OpenGL library can usually be found by the name OpenGL32.dll under the \system32 folder, located in your system's root folder (usually c:\windows).

Headers compatible with OpenGL are bundled with most compilers. The header's versions may not be fully updated to your running implementation of OpenGL. If so, the new functions must be linked manually using the OpenGL's extension system, or using a wrapper such as GLEW.


GLEW's official release is meant to work with visualc++ - but if you're using MinGW/GCC with Code::Blocks, no worry - you can:

  • link directly to the .dll (instead of adding the mingw-incompatible .lib)
  • or, you can recompile it and use it as a shared library, using MSys:
cd glew-1.7.0/
  • or, you can build GLEW statically: add glew32s.lib to linker libraries in the linker options, and add -DGLEW_STATIC to your compiler flags.

GLee only compiles statically under Windows (not cross-compiling from GNU/Linux) but doesn't have this issue.



GLM is a headers-only library, so you just need to unzip the GLM release to a directory, and add that directory to your include path in the project properties.


Newer tutorial Makefile's can now be invoked using a MXE-compatible environment, for example:

  • Compile MXE:
git clone /usr/src/mxe
cd /usr/src/mxe/
# select your architecture in, e.g. MXE_TARGETS := i686-w64-mingw32.static
make glew sdl2 sdl2_image freetype
cp -a .../glm /usr/src/mxe/usr/i686-w64-mingw32.static/include/
  • Prepare environment:
export CXX=i686-w64-mingw32.static-g++
export EXTRA_LDLIBS=-lopengl32
export PKG_CONFIG=i686-w64-mingw32.static-pkg-config
  • Compile as easily as usual:
cd modern-tutorials/tutXXX/

Debugging note: due to a bug you need to pipe your input to GDB through cat:

cd /usr/src/mxe/
make gdb

cd .../modern-tutorials/tutXXX/
cat | wine /usr/src/mxe/usr/i686-w64-mingw32.static/bin/gdb.exe ./triangle

< OpenGL Programming/Installation

Browse & download complete code Download.svg