A bit late on this update as things have not gone as well timewise in the last few weeks as one might have hoped. I did get a decent read of the Red Book on the train, however, and now things are starting to hot up. And certain things are becoming clearer.
The function
glClearColor
, for example, has become clear itself. When I saw constants like
GL_COLOR_BUFFER_BIT
being swallowed whole by the function, I developed this mental picture of an "image data map" and for each point there was a colour bit being cleared. God knows why I thought that, but the far more compelling and obvious truth is that
GL_COLOR_BUFFER_BIT
is just a fragment of a function's bitfield argument. What an idiot, huh? Huh?
The building blocks have been assembled. I can clear the screen (
glClear
), refresh the screen (
glFlush
,
glFinish
), and provide callbacks for OpenGL to respond to changes (
glReshapeFunc
). Simple primitives (e.g.
GL_LINE_STRIP
,
GL_POLYGON
,
GL_TRIANGLES
,
GL_QUADS
) are cast into virtual 3D space by specifying the points that compose them (
glVertex3f
) between markers that identify the type of primitive (
glBegin
,
glEnd
).
Messing around with tutorial code generates
intuition as opposed to bog-standard
knowledge, particularly with a bit of extra reading from
Buss' book, which is putting the mathematical concepts neatly alongside the OpenGL ones.
For example, functions such as
glTranslatef
,
glRotatef
build up a transformation matrix which will then act on all of the points you throw at OpenGL with the
glVertex3f
commands. So you need to be careful about what matrix you're playing with when sploshing more than one object on the screen.
But getting these concepts inside your head, making them your friends, is not as simple as reading a book. I decided to drop the matrix reset command
glLoadIdentity
between the pyramid and cube constructions in
NeHe tutorial 5; that did the trick. The cube started spinning around the pyramid, instead of about its own independent centre and I acquired a far more intuitive understanding of matrices and transformations.
One problem I am having is that I prefer the GLUT versions of the NeHe tutorials, but some of them are quite different to the original version of the tutorial code. Case in point: I looked at texture mapping in
tutorial 6 and the code described loads a bitmap using standard C functions. The GLUT version loads a TGA file using a TGA library that accompanies the code. I'm not sure what to do about this schizophrenic approach to the tutorials at the moment. Just bite the bullet and see how it goes I guess.
I have an idea for a simple test project to build; let's see if I can get some more serious time plugged into my OpenGL endeavours that this thrashing around for the odd spare minute that passes for study.