LWJGL
May 23, 2012, 02:51:51 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: GL11 3D World Render Problems.  (Read 950 times)
Caironater
Newbie
*
Posts: 6


« on: October 24, 2011, 18:45:48 »

Am I forgetting some vital thing here?
As far as i can see, it *should* render, but all I'm getting is the GL clear colour.
Code:
import org.lwjgl.opengl.GL11;

public class RenderManager
{
public RenderManager()
{
}

public void render()
{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
EntityPlayer player = getPlayer();
if (getIsInGame() && player != null)
{
GL11.glPushMatrix();
{
GL11.glTranslated(player.posX, player.posY, player.posZ);
GL11.glRotatef((float)player.pitch, 1.0F, 0.0F, 0.0F);
GL11.glRotatef((float)player.yaw, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float)player.roll, 0.0F, 0.0F, 1.0F);

GL11.glColor3f(1.0F, 0.0F, 0.0F);

GL11.glBegin(GL11.GL_QUADS);
{
GL11.glVertex3i(0, 0, 0);
GL11.glVertex3i(1000, 0, 0);
GL11.glVertex3i(1000, 0, 1000);
GL11.glVertex3i(0, 0, 1000);
}
GL11.glEnd();
}
GL11.glPopMatrix();
}
getCurrentGui().drawGui();
}
}
Logged
abcdef
Newbie
*
Posts: 27


« Reply #1 on: October 25, 2011, 01:52:29 »

Two things

Everytime you start the render loop you need to start from a common position. Currently everytime you translate and rotate you are just adding on to what you did before. To do this you need to glLoadIdentity() at the beginning of your loop (just after glClear is fine).

Also if you draw a large quad you may need to back up the camera so you can see it so you might want to set your initial camera position in infront of the quad, most people use a z translation at the beginning to accomplish this.
Logged
Caironater
Newbie
*
Posts: 6


« Reply #2 on: October 25, 2011, 02:13:38 »

Two things

Everytime you start the render loop you need to start from a common position. Currently everytime you translate and rotate you are just adding on to what you did before. To do this you need to glLoadIdentity() at the beginning of your loop (just after glClear is fine).

Also if you draw a large quad you may need to back up the camera so you can see it so you might want to set your initial camera position in infront of the quad, most people use a z translation at the beginning to accomplish this.

Woo!
Adding the glLoadIdentity() fixed it. Many thanks!
Logged
Caironater
Newbie
*
Posts: 6


« Reply #3 on: October 25, 2011, 16:08:39 »

Actually...
Using glLoadIdentity(); is messing with my GUI stuff. Now the Gui's are starting to draw from the centre of the screen, instead of the lower left. I could ofcourse just retranslate it so that it's fine, but that's a bit hacky.

EDIT: After trying to glTranslate it, it appears that it is also zoomed out or something. I've moved it backwards a fair way past the edge, and it hasn't shown the other edge yet :/
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!