Unfortunately, you seem to be getting way ahead of yourself. You need to have a grasp on linear algebra(at least the parts that pertain to 3D graphics) and the OpenGL API. I'd suggest getting yourself a book, there are plenty of good ones out there on the subject. I personally liked "Mathematics for 3D Game Programming and Computer Graphics" and "3D Math Primer for Graphics and Game Development." Yes, it is true that you can learn plenty about all the fancy pants stuff out there just by using google, however, it *appears* as though you lack the basic understanding of what's really going on when you make these calls. It is incredibly important that you do understand that in order to use it properly.
That being said, here is the important parts of my camera class, which is far from perfect but may shine some light on it.
#import <OpenGL/gl.h>#import <OpenGL/glu.h>#import "OCCamera.h"@implementation OCCamera- (id)initWithLocation:(vector_t)loc width:(int)w height:(int)h{ [super init]; position = loc; screenWidth = w; screenHeight = h; screenRatio = (float)(screenWidth/screenHeight); near = 1.0f; far = 768.0; fov = 45.0f; rotation = quaternion_identity(); //Completely unneccesary, but a good reminder. forward = quaternion_rotate_vector(rotation, vector3(0,0,1)); up = quaternion_rotate_vector(rotation, vector3(0,1,0)); right = quaternion_rotate_vector(rotation, vector3(1,0,0)); yaw = pitch = 0.0f; interpolationSpeed = 1.0f; return self;}- (void)animate:(float)dt{ if(allowInterpolation) { elapsedTime += dt * interpolationSpeed; if(elapsedTime > 1.0f) { elapsedTime = 1.0f; allowInterpolation = false; } position = vector_add(initPosition, vector_scale(vector_subtract(destPosition, initPosition), elapsedTime)); rotation = Quaternion_SLERP(initRotation, destRotation, elapsedTime); forward = quaternion_rotate_vector(rotation, vector3(0,0,1)); up = quaternion_rotate_vector(rotation, vector3(0,1,0)); right = quaternion_rotate_vector(rotation, vector3(1,0,0)); yaw = atan2(forward.x, forward.z); pitch = acos(vector_dot_product(vector3(0, 1, 0), forward)) - OSML_PI / 2.0f; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, screenRatio, near, far); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(position.x, position.y, position.z, position.x + forward.x, position.y + forward.y, position.z + forward.z, up.x, up.y, up.z);}- (void)rotateYaw:(double)delta{ if(allowInterpolation) return; yaw += delta; quaternion_t qPitch = quaternion_from_angle_around_axis(pitch, vector3(1,0,0)); quaternion_t qYaw = quaternion_from_angle_around_axis(yaw, vector3(0,1,0)); rotation = quaternion_product(qYaw, qPitch); forward = quaternion_rotate_vector(rotation, vector3(0,0,1)); up = quaternion_rotate_vector(rotation, vector3(0,1,0)); right = quaternion_rotate_vector(rotation, vector3(1,0,0));}- (void)rotatePitch:(double)delta{ if(allowInterpolation) return; pitch += delta; quaternion_t qPitch = quaternion_from_angle_around_axis(pitch, vector3(1,0,0)); quaternion_t qYaw = quaternion_from_angle_around_axis(yaw, vector3(0,1,0)); rotation = quaternion_product(qYaw, qPitch); forward = quaternion_rotate_vector(rotation, vector3(0,0,1)); up = quaternion_rotate_vector(rotation, vector3(0,1,0)); right = quaternion_rotate_vector(rotation, vector3(1,0,0));}- (void)setPitch:(double)p{ if(allowInterpolation) return; pitch = p; [self rotatePitch:0];}- (void)setYaw:(double)p{ if(allowInterpolation) return; yaw = p; [self rotateYaw:0];} - (vector_t)targetPoint:(vector_t)point distance:(float)f{ return vector3(point.x - forward.x * f, point.y - forward.y * f, point.z - forward.z * f);}- (void)targetOnPoint:(vector_t)point distance:(float)f{ if(allowInterpolation) return; position.y = point.y - forward.y * f; position.z = point.z - forward.z * f; position.x = point.x - forward.x * f;}- (void)orbitYaw:(double)amt aroundPoint:(vector_t)center{ if(allowInterpolation) return; vector_t newPos; quaternion_t newRot; float radius = sqrtf(pow(position.x - center.x, 2) + pow(position.z - center.z, 2)); yawOrbit += amt; newPos.x = center.x + cos(yawOrbit + OSML_HALF_PI) * radius; newPos.y = position.y; newPos.z = center.z - sin(yawOrbit + OSML_HALF_PI) * radius; yaw += amt; quaternion_t qPitch = quaternion_from_angle_around_axis(pitch, vector3(1,0,0)); quaternion_t qYaw = quaternion_from_angle_around_axis(yaw, vector3(0,1,0)); newRot = quaternion_product(qYaw, qPitch); position = newPos; [self rotateTo:newRot];}- (void)rotateTo:(quaternion_t)q{ if(allowInterpolation) return; rotation = q; forward = quaternion_rotate_vector(rotation, vector3(0,0,1)); up = quaternion_rotate_vector(rotation, vector3(0,1,0)); right = quaternion_rotate_vector(rotation, vector3(1,0,0));}- (bool)interpolateTo:(vector_t)pos withRotation:(quaternion_t)rot withSpeed:(float)speed cancelPrevious:(bool)cancel{ if(allowInterpolation && !cancel) return false; interpolationSpeed = speed; allowInterpolation = true; elapsedTime = 0.0f; initPosition = position; destPosition = pos; initRotation = rotation; destRotation = rot; return true;}- (void)moveForward:(double)amt{ if(allowInterpolation) return; position.x += forward.x * amt; position.y += forward.y * amt; position.z += forward.z * amt;}- (void)moveRight:(double)amt{ if(allowInterpolation) return; position.x -= right.x * amt; position.y -= right.y * amt; position.z -= right.z * amt;}- (void)moveUp:(double)amt{ if(allowInterpolation) return; position.x += up.x * amt; position.y += up.y * amt; position.z += up.z * amt;}- (void)moveTo:(vector_t)pos{ if(allowInterpolation) return; position = pos;}@end