GLUT on OS X with OpenGL 3.2 Core Profile

You need at least Mac OS X Lion (OS X 10.7 or higher) for the basic support of OpenGL 3.2. To use the OpenGL 3.2 Core Profile, just add glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | … | …); in your main-function. You can check it by std::printf(“%s\n%s\n”, glGetString(GL_RENDERER), // e.g. Intel HD Graphics 3000 OpenGL Engine glGetString(GL_VERSION) // e.g. … Read more

Opengl pixel perfect 2D drawing

In OpenGL, lines are rasterized using the “Diamond Exit” rule. This is almost the same as saying that the end coordinate is exclusive, but not quite… This is what the OpenGL spec has to say: http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html Also have a look at the OpenGL FAQ, http://www.opengl.org/archives/resources/faq/technical/rasterization.htm, item “14.090 How do I obtain exact pixelization of lines?”. … Read more

GLUT exit redefinition error

Cause: The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h. Solution: Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code. #include <stdlib.h> #include <GL/glut.h>

Using the mouse scrollwheel in GLUT

Freeglut’s glutMouseWheelFunc callback is version dependant and not reliable in X. Use standard mouse function and test for buttons 3 and 4. The OpenGlut notes on glutMouseWheelFunc state: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability … Read more