This tutorial shows how to build a basic application with OpenGL graphics.
The most important part of this tutorial is the class wxGLCanvas and it derivative, respectively. The OpenGL specific part of three parts:
GLCanvas::InitGL
).GLCanvas::OnSize
).GLCanvas::Render
).Simple initialization, without eyecandy (well, almost).
FOV (field of view) is constant 45°, while the aspect ratio is calculated from the size of the visible area.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (double)width / (double)height, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
Business as usual: clearing the buffers, translate and rotate to the viewers position and draw the objects.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -15.0);
glRotatef(30.0, 1.0, 0.0, 0.0);
glColor4f(0.3, 0.3, 0.3, 1.0);
glutWireTeapot(3.0);
Linux:
Windows/Cygwin:
Using the makefile: