public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glPushMatrix(); gl.glRotatef(20.0f, 1.0f, 0.0f, 0.0f); gl.glPushMatrix(); gl.glTranslatef(-0.75f, 0.5f, 0.0f); gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glut.glutSolidTorus(0.275f, 0.85f, 20, 20); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(-0.75f, -0.5f, 0.0f); gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f); glut.glutSolidCone(1.0f, 2.0f, 20, 20); gl.glPopMatrix(); gl.glPushMatrix(); gl.glTranslatef(0.75f, 0.0f, -1.0f); glut.glutSolidSphere(1.0f, 20, 20); gl.glPopMatrix(); gl.glPopMatrix(); gl.glFlush(); }
private void renderRedTeapot(GL2 gl, float x, float y, float z) { float mat[] = new float[4]; gl.glPushMatrix(); gl.glTranslatef(x, y, z); mat[0] = 0.1745f; mat[1] = 0.01175f; mat[2] = 0.01175f; mat[3] = 1.0f; gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, mat, 0); mat[0] = 0.61424f; mat[1] = 0.04136f; mat[2] = 0.04136f; gl.glMaterialfv(GL.GL_FRONT, GL2.GL_DIFFUSE, mat, 0); mat[0] = 0.727811f; mat[1] = 0.626959f; mat[2] = 0.626959f; gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, mat, 0); gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 0.6f * 128.0f); glut.glutSolidTeapot(1.0); gl.glPopMatrix(); }