示例#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
  /*
   * Initialize fog
   */
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    glu = new GLU();
    //
    float fogColor[] = {0.0f, 0.25f, 0.25f, 1.0f};
    f1 = 1.0f;
    f2 = 5.0f;
    f3 = 10.0f;

    gl.glEnable(GL2.GL_FOG);
    gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_EXP);
    gl.glFogfv(GL2.GL_FOG_COLOR, fogColor, 0);
    gl.glFogf(GL2.GL_FOG_DENSITY, 0.25f);
    gl.glHint(GL2.GL_FOG_HINT, GL.GL_DONT_CARE);
    gl.glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FOG_COORDINATE);
    gl.glClearColor(0.0f, 0.25f, 0.25f, 1.0f); /* fog color */
  }