예제 #1
0
파일: dof.java 프로젝트: jzy3d/glredbook
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    glut = new GLUT();
    //
    float ambient[] = new float[] {0.0f, 0.0f, 0.0f, 1.0f};
    float diffuse[] = new float[] {1.0f, 1.0f, 1.0f, 1.0f};
    float specular[] = new float[] {1.0f, 1.0f, 1.0f, 1.0f};
    float position[] = new float[] {0.0f, 3.0f, 3.0f, 0.0f};

    float lmodel_ambient[] = new float[] {0.2f, 0.2f, 0.2f, 1.0f};
    float local_view[] = new float[] {0.0f};

    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, ambient, 0);
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0);
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, position, 0);

    gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient, 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(GL.GL_DEPTH_TEST);

    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
    /* make teapot display list */
    teapotList = gl.glGenLists(1);
    gl.glNewList(teapotList, GL2.GL_COMPILE);
    glut.glutSolidTeapot(0.5f);
    gl.glEndList();
  }
예제 #2
0
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    glut = new GLUT();
    //
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    makeStripeImage();

    gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);

    gl.glGenTextures(1, texName, 0);
    gl.glBindTexture(GL2.GL_TEXTURE_1D, texName[0]);

    gl.glTexParameterf(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
    gl.glTexParameterf(
        GL2.GL_TEXTURE_1D, //
        GL2.GL_TEXTURE_MAG_FILTER,
        GL.GL_LINEAR);
    gl.glTexParameterf(
        GL2.GL_TEXTURE_1D, //
        GL2.GL_TEXTURE_MIN_FILTER,
        GL.GL_LINEAR);
    gl.glTexImage1D(
        GL2.GL_TEXTURE_1D,
        0,
        GL2.GL_RGBA,
        stripeImageWidth, //
        0,
        GL2.GL_RGB,
        GL.GL_UNSIGNED_BYTE,
        stripeImageBuf);

    gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
    currentCoeff = xequalzero;
    currentGenMode = GL2.GL_OBJECT_LINEAR;
    currentPlane = GL2.GL_OBJECT_PLANE;
    gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
    gl.glTexGendv(GL2.GL_S, GL2.GL_OBJECT_PLANE, currentCoeff, 0);

    // gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LESS);
    gl.glEnable(GL2.GL_TEXTURE_GEN_S);
    gl.glEnable(GL2.GL_TEXTURE_1D);
    gl.glEnable(GL.GL_CULL_FACE);
    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glEnable(GL2.GL_AUTO_NORMAL);
    gl.glEnable(GL2.GL_NORMALIZE);
    gl.glFrontFace(GL.GL_CW);
    gl.glCullFace(GL.GL_BACK);
    gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 64.0f);
  }