**1**

# gluLookAt

###
#1
Members - Reputation: **100**

Posted 23 January 2011 - 06:40 AM

I'm only starting to get to grips with 3D and I've rendering various simple 2D and 3D shapes in OpenGL. In almost all the tutorials I've seen coordinates specified in the -1.0f to 1.0f range, I assumed (after doing some reading) the coordinates are specified like that and not, for example (50.0f, 10.0f, -15.0f) because the camera (by default) is centred around the origin and anything at those coordinate would not be visible. Is that correct?

My question relating to gluLookAt() is that if I want to start specifying objects that are away from the origin (as in my example coordinates above) is gluLookAt() the correct way to move away from the origin and be able to draw / view a larger area?

Thanks,

T.

###
#2
Members - Reputation: **1977**

Posted 23 January 2011 - 08:57 AM

No, that's not really correct. I'm not sure what tutorials you've been looking at, but if the coordinates were limited to the range [-1, 1], I imagine it was just to keep things simple (for example, if you leave the projection matrix at identity, coordinates in that range will all be 'on screen', provided the points fall between the near and far planes). In general though, there are no constraints on or particular rules or guidelines regarding coordinate ranges, at least not beyond the usual concerns regarding numerical precision, depth range precision, and so on.I'm only starting to get to grips with 3D and I've rendering various simple 2D and 3D shapes in OpenGL. In almost all the tutorials I've seen coordinates specified in the -1.0f to 1.0f range, I assumed (after doing some reading) the coordinates are specified like that and not, for example (50.0f, 10.0f, -15.0f) because the camera (by default) is centred around the origin and anything at those coordinate would not be visible. Is that correct?

There's nothing special about gluLookAt() or any other similar function. All that matters is what ends up at the top of the modelview matrix stack (assuming fixed function, which I assume you're using since you're using gluLookAt()). gluLookAt() is one of many ways you can manipulate the matrix stack, but there's nothing special about that function in particular.My question relating to gluLookAt() is that if I want to start specifying objects that are away from the origin (as in my example coordinates above) is gluLookAt() the correct way to move away from the origin and be able to draw / view a larger area?

###
#3
Members - Reputation: **100**

Posted 23 January 2011 - 02:35 PM

No, that's not really correct. I'm not sure what tutorials you've been looking at, but if the coordinates were limited to the range [-1, 1], I imagine it was just to keep things simple (for example, if you leave the projection matrix at identity, coordinates in that range will all be 'on screen', provided the points fall between the near and far planes). In general though, there are no constraints on or particular rules or guidelines regarding coordinate ranges, at least not beyond the usual concerns regarding numerical precision, depth range precision, and so on.

I'm only starting to get to grips with 3D and I've rendering various simple 2D and 3D shapes in OpenGL. In almost all the tutorials I've seen coordinates specified in the -1.0f to 1.0f range, I assumed (after doing some reading) the coordinates are specified like that and not, for example (50.0f, 10.0f, -15.0f) because the camera (by default) is centred around the origin and anything at those coordinate would not be visible. Is that correct?There's nothing special about gluLookAt() or any other similar function. All that matters is what ends up at the top of the modelview matrix stack (assuming fixed function, which I assume you're using since you're using gluLookAt()). gluLookAt() is one of many ways you can manipulate the matrix stack, but there's nothing special about that function in particular.My question relating to gluLookAt() is that if I want to start specifying objects that are away from the origin (as in my example coordinates above) is gluLookAt() the correct way to move away from the origin and be able to draw / view a larger area?

Thanks for replying jyk. I think spending some more time tinkering with the various matrix operations will help me understand what exactly is going on.