NeHe Lesson 3

back to index

Another very simple change:

public void display(GLAutoDrawable drawable) {
// like int DrawGLScene(GLvoid)
GL gl = drawable.getGL();

gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);    // Clear The Screen And The Depth Buffer
gl.glLoadIdentity();                    // Reset The Current Modelview Matrix

gl.glTranslatef(-1.5f,0.0f,-6.0f);                // Left 1.5 Then Into Screen Six Units

gl.glBegin(GL.GL_TRIANGLES);
gl.glColor3f(1.0f,0.0f,0.0f);            // Set The Color To Red
gl.glVertex3f( 0.0f, 1.0f, 0.0f);
gl.glColor3f(0.0f,1.0f,0.0f);            // Set The Color To Green
gl.glVertex3f(-1.0f,-1.0f, 0.0f);
gl.glColor3f(0.0f,0.0f,1.0f);            // Set The Color To Blue
gl.glVertex3f( 1.0f,-1.0f, 0.0f);            // Right And Down One Unit (Bottom Right)
gl.glEnd();                        // Done Drawing A Triangl.gle

gl.glTranslatef(3.0f,0.0f,0.0f);
gl.glColor3f(0.5f,0.5f,1.0f);                // Set The Color To Blue One Time Only
gl.glBegin(GL.GL_QUADS);                    // Start Drawing Quads
gl.glVertex3f(-1.0f, 1.0f, 0.0f);            // Left And Up 1 Unit (Top Left)
gl.glVertex3f( 1.0f, 1.0f, 0.0f);            // Right And Up 1 Unit (Top Right)
gl.glVertex3f( 1.0f,-1.0f, 0.0f);            // Right And Down One Unit (Bottom Right)
gl.glVertex3f(-1.0f,-1.0f, 0.0f);            // Left And Down One Unit (Bottom Left)
gl.glEnd();
}