PDA

View Full Version : Moving a Camera using gluLookAt



codelyoko373
03-07-2018, 05:26 PM
I want to first state that I am basically a complete beginner at this. What I'm trying to do is simply get the camera I have currently to move to the side or up or down depending on the key I press. I thought it would be a simple process of changing the Camera's eye X and Y position which is what I did:


void Camera::Keyboard(unsigned char key, int x, int y)
{
if (key == 'a')
{
position.X -= cameraSpeed;
}
if (key == 'd')
{
position.X += cameraSpeed;
}
if (key == 'w')
{
position.Y += cameraSpeed;
}
if (key == 's')
{
position.Y -= cameraSpeed;
}
}

Though this hasn't worked as I thought it would where instead of moving side to side, up and down, it seems to rotate around a point but in a strange way:
https://i.imgur.com/ac8Cxzo.mp4

I know I've done something wrong, that's clear though I was wondering if someone would be able to help me achieve what I want since truthfully I don't have a clue.