OpenGL First Person Camera, non-gluLookAt()

I’ve been looking into OpenGL the past few days, and have been using LWJGL to make some simple displays of cubes and so forth. I’m very interested and see that there’s a lot to learn (which is not a bad thing).

First, though, I thought I should learn how I can move around the world. I had a kind of hackish system put together where all objects would move in the opposite direction of user input (implemented with glTranslatef()). After looking around the 'Net, I learned that it is better practice to employ matrices instead. Plenty of websites discussed that the camera does not move through the world, and coordinates are in the modelView matrix and so forth, but very few touched on how to actually use this knowledge to create a functional camera. The ones that did were vague and unhelpful.

I understand what matrices are- I have used them in math- but do not understand why matrix multiplication is necessary or useful in OpenGL. One website mentioned that it allows the GPU to asynchronously calculate all sixteen new values for the modelView matrix simultaneously, but I still don’t understand why it’s necessary to change several values when the “camera” has, for example, only moved a couple units on one axis. I’m sure there is good reason, but I have not seen it.

Could someone enlighten me about this? An explanation here or a link to a resource that actually thoroughly explains how to use matrices to create a basic first person perspective (with keyboard motion and mouselook, the typical style) would be greatly appreciated.

Thanks in advance for your assistance.

try this
http://knol.google.com/k/matrices-for-3d-applications-translation-rotation#1(2E)_Transformations

That was helpful, but I’m still kind of in the dark about how to use that knowledge.

Shouldn’t this create the 4*4 identity matrix?

FloatBuffer fb;
fb = ByteBuffer.allocateDirect(4 * 16).asFloatBuffer();
fb.put(0, 1);
fb.put(5, 1);
fb.put(10, 1);
fb.put(15, 1);

Judging by the results I get (I no longer see anything but the background clear color) when I perform
glMultMatrix(fb);
I believe fb must not be the identity matrix. If it were, nothing would have changed, right?

(By the way, glMatrixMode is GL_MODELVIEW and I am calling glMultMatrix(fb) after glLoadIdentity() and before drawing my stuff.)

Just learned about glPushMatrix()/glPopMatrix().

//For the camera:
GL11.glLoadIdentity();
GL11.glTranslatef(2, 2, -30);

//For the first thing I want to draw:
GL11.glPushMatrix();
GL11.glTranslatef(2, 2, -30);
GL11.glCallList(cube);
GL11.glPopMatrix();

//For the second thing I want to draw
GL11.glPushMatrix();
GL11.glTranslatef(-6, 7, -30);
GL11.glCallList(cube);
GL11.glPopMatrix();

amidoinitrite?

Ok try this set of tutorials

http://nehe.gamedev.net/tutorial/lessons_01__05/22004/

there is a lot of useful information on this site

I figured it out in my “amidoinitrite?” post.

Also, I’m not a fan of the NeHe tutorials, but thanks.