PDA

View Full Version : Screen isn't rendering anything.



Joshhua5
09-05-2012, 05:10 AM
I don't know why but the screen is rendering just while, with neither of the two planes appearing
It's set so one plane is above and one is below, I've looked through and can't see anything wrong with it.
I'm using LWJGL and java


public void Game() { float playerX = 0;
float playerY = 10;
float playerZ = 0;
float playerYaw = 0;
float playerPitch = 25;
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(-10, 10, -10, 10, 0.1f, 100f);
GL11.glEnable(GL11.GL_DEPTH_TEST);
while(!Display.isCloseRequested()){
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glClearColor(1, 1, 1, 1);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glTranslatef(playerX, playerY, playerZ);
GL11.glRotatef(playerPitch, 1, 0, 0);
GL11.glRotatef(playerYaw , 0, 1, 0);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex3f(-100, 30, -100);
GL11.glVertex3f(100, 30, -100);
GL11.glVertex3f(100, 30, 100);
GL11.glVertex3f(-100, 30, 100);
GL11.glEnd();



GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex3f(-100, 0, -100);
GL11.glVertex3f(100, 0, -100);
GL11.glVertex3f(100, 0, 100);
GL11.glVertex3f(-100, 0, 100);
GL11.glEnd();

if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
playerYaw += 1;
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT))
playerYaw -= 1;
if(Keyboard.isKeyDown(Keyboard.KEY_UP))
playerPitch += 1;
if(Keyboard.isKeyDown(Keyboard.KEY_DOWN))
playerPitch -= 1;

Display.update();
}
}

Joshhua5
09-05-2012, 11:07 PM
Bumpinginging

Joshhua5
09-06-2012, 08:00 AM
This is the Ortho matrix
Anything wrong with it?
GL11.glOrtho(-1f,10f, -1f,10f, -1f, 20f);
* 5.5 0 0 0.81
* 0 5.5 0 0.81
* 0 0 -0.095 0.9
* 0 0 0 1

menzel
09-06-2012, 10:40 AM
Looks fine, but you destroy your projection matrix in your loop:



GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glTranslatef(playerX, playerY, playerZ); GL11.glRotatef(playerPitch, 1, 0, 0); GL11.glRotatef(playerYaw , 0, 1, 0);


Is there a reason why you still use the fixed function pipeline?

Dan Bartlett
09-06-2012, 02:31 PM
Unless you've change the current colour somewhere you haven't shown, you'll be drawing white rectangles on a white background, so you can't see anything.

You should probably also be applying your camera (inverse) transformation to your model-view matrix, rather than to projection matrix: http://sjbaker.org/steve/omniv/projection_abuse.html