Пример #1
0
  /*
   * Initialize z-buffer, projection matrix, light source, and lighting model.
   * Do not specify a material property here.
   */
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    glut = new GLUT();
    //
    float position[] = {0.0f, 3.0f, 3.0f, 0.0f};
    float local_view[] = {0.0f};

    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LESS);

    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, position, 0);
    gl.glLightModelfv(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, local_view, 0);

    gl.glFrontFace(GL.GL_CW);
    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glEnable(GL2.GL_AUTO_NORMAL);
    gl.glEnable(GL2.GL_NORMALIZE);
    gl.glEnable(GL2.GL_FOG);
    {
      float fogColor[] = {0.5f, 0.5f, 0.5f, 1.0f};

      fogMode = GL2.GL_EXP;
      gl.glFogi(GL2.GL_FOG_MODE, fogMode);
      gl.glFogfv(GL2.GL_FOG_COLOR, fogColor, 0);
      gl.glFogf(GL2.GL_FOG_DENSITY, 0.35f);
      gl.glHint(GL2.GL_FOG_HINT, GL.GL_DONT_CARE);

      gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    }
  }
Пример #2
0
 @Override
 public void init(GLAutoDrawable glDrawable) {
   GL2 gl = glDrawable.getGL().getGL2();
   gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   gl.glClearDepth(1.0f);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glDepthFunc(GL.GL_LEQUAL);
   gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
 }