Sunday, February 19

Week Six: A Nothing Trend

Hey, not much to report.

Amidst interviews, socialising (heaven forbid) and a bastard of a cold, little progress has been made on anything. I concentrated on the Buss book as it launched into averaging and interpolation.

Today I spent a couple of hours working on some of the Buss book problems, because I felt the mathematics was passing in front of my eyes but not attaching itself to my brain. I spent too long on "affine combinations preserve affine transformations" simply because I was thinking in homogeneous co-ordinates and that meant everything looked like linear operators to me.

This, of course, probably means nothing to any reader, even those people that know exactly what affine combinations are. It gives me joy to provide you with such puzzling mysteries.

Monday, February 13

Week Five: Alternate Views

I think I'm going to be stuck with a lack of programming time for the forseeable future. Interview season has started in earnest and I am just going to have to deal with it.

This hasn't put the brakes on the reading, though. I'm making good progress through the red book, reading all about viewing and colour. Also made some way through the lighting chapter. Still waiting to read about blending, you know...

Buss has now moved onto averaging and interpolation. I started reading the advanced lighting section on the Cook-Torrance model and, although I could have sat down and thrashed it out, I decided it wasn't going to be useful to me Right Now. I may come back later if I decide to play with alternate lighting models.

I'm not sure how one actually uses alternate lighting models at this point, considering that the Phong model is what is built into OpenGL. My current guess is that you have to build it yourself from scratch or perhaps it can be implemented using shading language.

Ah, so much left to discover.

Monday, February 6

Week Four: Light

I love the Buss book, it keeps giving me a deep-seated understanding of OpenGL. And I love the Red book because it tells me everything I need to know about using OpenGL. Then there's the Nehe tutorials which give me, in your face, no frills code to get stuff happening.

I am doing well at reading but not so good at the practical. I got into the blending tutorial at NeHe at a late hour of the day and my brain was struggling with the idea that you have to tell OpenGL yourself to put render transparent surfaces later. Or something like that. Neither the Red book nor the Buss book cover blending just yet, so I haven't had a full briefing on blending yet.

Another problem is that I am spending a lot of time searching for a job at the moment, writing CVs that sort of thing. Sucks, but part of life's tapestry.

I do, however, understand the basic lighting tools of OpenGL well. I appreciate the difference between ambient and diffuse lighting, diffuse and spectral reflection and also emissive surfaces. All thanks to the Buss book, I have to say. I am having fun, even if I haven't implemented yet.

The longer I go without implementing anything, the more nervous I get, however.

And thanks to Microsoft who have decided to tie Direct3D into the desktop experience, will I ever want to use OpenGL on a Windows platform after Vista?

Monday, January 30

Week Three: Elegant Lines

I am looking for work as it happens. Not out of a job... just yet... but I'd like to find a job with an element of C++ as it seems that its the language of choice for 3D graphics folks. My gut tells me it has something to do with fine control over the performance, but let's not start the language flame wars.

Anyhow, my time has been dragged in several directions and I am only just managing to keep up with the schedule. I realised I was reading a lot of the Buss book on the train and so decided today to swap it for the Red book. Not exactly an exchange that goes unnoticed, I grant you that, as the commute has become a slightly heavier affair.

In Buss, I've been reading a lot on the transformations required to produce the final image. Another sticky point: why we needed to record the depth even when we had transformed the view onto a plane, but I think I have it now; depth calculations are done after the perspective transformation. Quite cool how at how important it was to pick out a depth measure that didn't screw with things too much, otherwise lines would become curves and depth calculations just wouldn't look work out right.

The last thing I read was on how to draw a line in pixels, using the Bresenham algorithm. When I was a childhood programmer, I puzzled for hours over how to draw a line on the screen without using the built-in drawing commands; the algorithm escaped me. I'm sure I would've got it now if I had just sat down and thought about it, but there's something elegant about the Bresenham algorithm. It solves a childhood puzzle for me and so I am happy.

I used to work out almost everything myself. Now lifestyles and workstyles are twenty-four hour commitments; amazing, I feel that I was smarter as a child.

Finished Chapter 2 of the Red book and my head is now awash with function definitions. The Red book spends a number of pages explaining the use of arrays for handling large streams of vertex data and, for the advanced students amongst us, buffer objects. The chapter finishes with a discussion on modelling real surfaces with polygons which blew my mind with the first pass. I just did not get the "subdivision of triangles" initially, my head filling with images of the crystalline virus growing in The Andromeda Strain. A few more minutes spent wisely on the train home today and understanding, once again, made its presence known to me.

Little NeHe progress which is sad, as it demonstrates that I really haven't been spending the time on OpenGL. Busy most nights this week, so looks like it's going to be down to the weekend to rescue the situation...

Tuesday, January 24

Week Two: Raw Materials

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.

Wednesday, January 11

Week One: Easy Does It

I'll let you into a little secret. I'm not as 3D green as I seem. A year ago, I made some progress with a text exploring the mathematics of 3D graphics, Samuel R. Buss' 3D Computer Graphics... so I at least have a light smearing of 3D knowledge.

For example, I know possessing knowledge of linear algebra - the world of vectors and matrices - is highly important, but I suspect most developers would have, at least, a rudimentary understanding of ths subject. Going further, projective geometry is also important - which I am not so familiar with.

There are wonderous inventions in projective geometry such as homogeneous coordinates that features four coordinates for every three-dimensional point instead of three. They are actually very handy because they allow you, amongst many other things, to write translations (simple linear movements) in matrix form.

I'm just trying to explain that current study feels more like revision... and thus progress is as smooth as a baby's bottom.

I read the first chapter of the Red Book and it was fairly straightforward. It did throw in a stack of OpenGL functions that are alien to me right now, but I know that the authors were just trying to give a flavour of how OpenGL works. I, therefore, forgive them.

I sped through the first four tutorials of NeHe, which puts me ahead of schedule. You work up from creating an empty black window to populating it with a couple of rotating coloured polygons. What a rush; I can already feel I'm on the verge of being able to create Half-Life 3 before Valve.

It is important to not got too bogged down in "how to make your OpenGL window". I am familiar with C++ but not Visual C++ and had never seen #include <windows.h> before in my life. The NeHe tutorials are built using the glaux library, which pushes responsibility for creating windows onto the hapless student; probably not the best way to get cracking on OpenGL code. The OpenGL Utility Toolkit (GLUT) simplifies things significantly, but that's besides the point: best to concentrate on controlling content at this early stage, and get into the whole window mastery thing later.

Crawl, walk, run.

Sunday, January 8

Starting Points

So I'm a software developer a little bored with his lot. And what have I decided to do? I've decided to try my hand at 3D graphics programming, in particular OpenGL, with the hope that I might jump from my current technology niche into 3D. This is not about making games. This is not about money. This is not a New Year Resolution. This is not because the evil monkey in my closet told me to do so.

With the word "not" daubed all over the previous paragraph, you've probably already got me pegged as a cynical chap. I'm British, so you'd be right with that one.

I thought I'd write it up in a blog, to keep tabs on myself, because if you're born to procrastinate like me, you better start keepin' an eye on yourself. So, in reality, this blog is a mirror. I'll be reading this in a few months, thinking, "Jesus, man, you're getting fat." I will update this blog once a week.

When I rush through stuff, I find I forget approximately everything, so I have drawn up a cautious schedule that sees me through the NeHe tutorials and OpenGL red book by June. After that, well, I guess I'll come up with something else, huh?