| This section is a stub.
You can help Wikibooks by expanding it.
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
- or, you can recompile it and use it as a shared library, using MSys:
cd glew-1.7.0/ make
- or, you can build GLEW statically: add glew32s.lib to linker libraries in the linker options, and add -DGLEW_STATIC to your compiler flags.
- Link: The OpenGL Extension Wrangler Library - Installation
- Link: glew-users : mailing list where I reported the link issue - hopefully the GLEW developers will provide a MinGW-compatible binary release.
GLee only compiles statically under Windows (not cross-compiling from GNU/Linux) but doesn't have this issue.
- freeglut Windows Development Libraries - link with -lfreeglut instead of -lglut32; don't use the Code::Blocks wizard for GLUT projects since it's specific to non-free GLUT
- Using OpenGL & GLUT in Code::Blocks - good tutorial; add
#include <windows.h>before including non-free glut.h
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 https://github.com/mxe/mxe /opt/mxe cd /opt/mxe/ # select your architecture in settings.mk, e.g. MXE_TARGETS := i686-w64-mingw32.static make glew sdl2 sdl2_image freetype cp -a .../glm /opt/mxe/usr/i686-w64-mingw32.static/include/
- Prepare environment:
PATH=/opt/mxe/usr/i686-w64-mingw32.static/bin:/opt/mxe/usr/bin:$PATH export CXX=i686-w64-mingw32.static-g++ export EXTRA_CPPFLAGS=-DGLEW_STATIC export EXTRA_LDLIBS=-lopengl32 export PKG_CONFIG=i686-w64-mingw32.static-pkg-config
- Compile as easily as usual:
cd modern-tutorials/tutXXX/ make
Debugging note: due to a bug you need to pipe your input to GDB through cat:
cd /opt/mxe/ make gdb cd .../modern-tutorials/tutXXX/ cat | wine /opt/mxe/usr/i686-w64-mingw32.static/bin/gdb.exe ./triangle
sdl2-config --libs sets the -mwindows option which removes the command black window but also stdout and stderr.
To see e.g. SDL_LogMessage output you can:
- force console mode:
- or explicitly redirect stderr:
triangle.exe 2> stderr.txt
(If you know why explicit redirection is necessary, feel free to explain.)