Jump to content
  • Advertisement
Sign in to follow this  
Corale

Camera trouble

This topic is 4080 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) {
		Project.gluLookAt(position.x,position.y,position.z,
				focusPoint.x,focusPoint.y,focusPoint.z,		
		orientation[2].x,orientation[2].y,orientation[2].z);
		e.render();
	}

	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.glPushMatrix();
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex3i(-50, -50, 0);
	GL11.glVertex3i(50, -50, 0);
	GL11.glVertex3i(50, 50, 0);
	GL11.glVertex3i(-50, 50, 0);
	GL11.glEnd();
	GL11.glPopMatrix();
}


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:
Display.setFullscreen(true);
Display.setVSyncEnabled(true);
Display.create();


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
Advertisement
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!