LWJGL Forum

Programming => OpenGL => Topic started by: NickyP101 on May 03, 2005, 12:26:56

Title: Building Room
Post by: NickyP101 on May 03, 2005, 12:26:56
Haha ok im trying to build a room, here is what i have:



public void render() {

      gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);          // Clear The Screen And The Depth Buffer

gl.glLoadIdentity();

gl.glTranslatef(0.0f, 0.0f, -6.0f);

//Build Room

gl.glBegin(gl.GL_QUADS);

gl.glNormal3f(0.0f, 0.0f, 1.0f);


gl.glColor3f(0.0f,1.0f,0.0f);

gl.glVertex3f(-2.0f, 2.0f, -8.0f); //Draw Back Wall - Top Left
gl.glVertex3f(-2.0f, -2.0f, -8.0f); //Draw Back Wall - Bottom Left
gl.glVertex3f( 2.0f, 2.0f, -8.0f); //Draw Back Wall - Top Right
gl.glVertex3f( 2.0f, -2.0f, -8.0f); //Draw Back Wall - Bottom Right

gl.glEnd();


gl.glBegin(gl.GL_QUADS);
gl.glNormal3f(1.0f, 0.0f, 0.0f);


gl.glColor3f(1.0f,0.0f,0.0f);

gl.glVertex3f( -2.0f, 2.0f, 0.0f); //Draw Left Wall - Top Left
gl.glVertex3f( -2.0f, -2.0f, 0.0f); //Draw Left Wall - Bottom Left
gl.glVertex3f( -2.0f, 2.0f,-8.0f); //Draw Left Wall - Top Right
gl.glVertex3f( -2.0f, -2.0f,-8.0f); //Draw Left Wall - Bottom Right


gl.glEnd();


gl.glBegin(gl.GL_QUADS);


gl.glNormal3f(-1.0f, 0.0f, 0.0f);

gl.glColor3f(0.0f,0.0f,1.0f);

gl.glVertex3f( 2.0f, 2.0f,-8.0f); //Draw Right Wall - Top Left
gl.glVertex3f( 2.0f, -2.0f,-8.0f); //Draw Right Wall - Bottom Left
gl.glVertex3f( 2.0f, 2.0f, 0.0f); //Draw Right Wall - Top Right
gl.glVertex3f( 2.0f, -2.0f, 0.0f); //Draw Right Wall - Bottom Right


gl.glEnd();

gl.glBegin(gl.GL_QUADS);


gl.glNormal3f(0.0f, 1.0f, 0.0f);

gl.glColor3f(1.0f,1.0f,1.0f);

gl.glVertex3f( -2.0f,-2.0f,-8.0f); //Draw Floor - Top Left
gl.glVertex3f( -2.0f,-2.0f, 0.0f); //Draw Floor - Bottom Left
gl.glVertex3f(  2.0f,-2.0f,-8.0f); //Draw Floor - Top Right
gl.glVertex3f(  2.0f,-2.0f, 0.0f); //Draw Floor - Bottom Right


gl.glEnd();






  }





Its not working quiet correctly, the walls seem to be in the correct position, but on each wall it looks like a triangle has been cut out of it. I cant show u a screenshot because i dont know how lol. Please take a quick look at the code, it might be something soo simple, im just beggining since yesterday lol alot more fun that 2D although i feel like im cheating lol i did some dynamic lighting in 2D using pure java no OpenGL or anything lol pixel by pixel lighting etc, lots of fun, in OpenGL i just set up a light lol LOVE IT!.

Cheers, Nick


Title: Building Room
Post by: NickyP101 on May 03, 2005, 12:32:03
Its ok figured it out, have to draw the QUADS clockwise from top left to top right to bottom right to bottom left :)

Thanks anyway!
Title: Building Room
Post by: Phydeaux314 on May 10, 2005, 01:56:55
More accurately, the quads do not need to be clockwise or whatnot, they need to have the points in order for each. That means hitting each corner in order.