Jump to content
  • Advertisement
Sign in to follow this  

Camera trouble

This topic is 4157 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I need some help with my camera viewing. I've been reading tutorials on how to set up the viewing transformation, so I modelled my camera after that now, but to no avail... This is the camera class:
public class Camera {
	private Point position;
	private Point focusPoint;
	private Vector[] orientation;

	public Camera() {
		position = new Point(0,0,5);
		focusPoint = new Point(0,0,0);
		orientation = new Vector[3];
		// forward.
		orientation[0] = new Vector(0,0,-1);
		// right.
		orientation[1] = new Vector(1,0,0);
		// up.
		orientation[2] = new Vector(0,1,0);
	// Move camera with WASD-keys.
	public void update() {
		if (Keyboard.isKeyDown(Keyboard.KEY_A)){
			position.x -= 5;
			focusPoint.x -= 5;
		if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
			position.x += 5;
			focusPoint.x += 5;
		if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
			position.y += 5;
			focusPoint.y += 5;
		if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
			position.y -= 5;
			focusPoint.y -= 5;

	public void render(Entity e) {

	public Point getPosition() {
		return position;

The thought is that it should be positioned at (0,0,5), looking at (0,0,0) with up-vector (0,1,0). Quite straightforward. Now, There is a quad in the origin created like so:
public void render() {
	GL11.glVertex3i(-50, -50, 0);
	GL11.glVertex3i(50, -50, 0);
	GL11.glVertex3i(50, 50, 0);
	GL11.glVertex3i(-50, 50, 0);

And this is called through the render() method in camera above as it should. The problem is that I can't see anything, the screen is black. I am using LWJGL to set up the display like this:

Does anyone have a clue as to what might be wrong? I've been trying to get it right for a couple of days now. Thank you in advance, David

Share this post

Link to post
Share on other sites
Do you set the viewport anywhere?
Did you enable back face culling, so is your quad in the right order CCW or CW?
Whats your clear color and what color does your quad receive?

Share this post

Link to post
Share on other sites
No, I have not set the viewport, at least not manually, I assumed it was done in Display.create(). I have not enabled back face culling either, unless it is also done in the Display routine. The clear color, hmm, well the quad is white, so I assume the clear color is white (I do clear the color in each frame). I can get the quad to show if I don't do the gluLookAt routine. It then shows up in the left bottom of the screen, but I only see the top right quarter of it.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!