Example #1
0
  /** Draws circular particle using a display list. */
  public void display(GL gl) {
    if (PARTICLE_DISPLAY_LIST < 0) { // MAKE DISPLAY LIST:
      int displayListIndex = gl.glGenLists(1);
      gl.glNewList(displayListIndex, GL.GL_COMPILE);
      drawParticle(gl, new Point3d(), radius); // /particle at origin
      gl.glEndList();
      System.out.println("MADE LIST " + displayListIndex + " : " + gl.glIsList(displayListIndex));
      PARTICLE_DISPLAY_LIST = displayListIndex;
    }

    // / COLOR: DEFAULT WHITE; GREEN IF HIGHLIGHTED; ADD RED IF PINNED
    Color3f c = new Color3f(1, 1, 1); // default: white
    if (pin) {
      c.x = 1f; // add red
      c.y *= 0.2f;
      c.z = 0;
    }
    if (highlight) {
      c.y = 1;
      c.z = 0;
    }
    if (GooParticle.class.isInstance(this)) {
      c.x = 0;
      c.y = 0;
      // now its blue
    }

    gl.glColor3f(c.x, c.y, c.z);

    // / DRAW ORIGIN-CIRCLE TRANSLATED TO "p":
    gl.glPushMatrix();
    gl.glTranslated(x.x, x.y, x.z);
    gl.glCallList(PARTICLE_DISPLAY_LIST);
    gl.glPopMatrix();
  }
Example #2
0
  /** @see OpenGLTab#init() */
  void init() {
    GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    // fog color should be the same as the clear color
    // to look appropriate
    float[] fogColor = {1.0f, 1.0f, 1.0f, 1.0f};
    GL.glFogfv(GL.GL_FOG_COLOR, fogColor);
    GL.glHint(GL.GL_FOG_HINT, GL.GL_DONT_CARE);
    GL.glFogf(GL.GL_FOG_START, 0);
    GL.glFogf(GL.GL_FOG_DENSITY, 0.0f);
    // set the end of the start distance; anything > 15
    // units from the camera will be covered in fog
    GL.glFogf(GL.GL_FOG_END, 15);
    GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[0]);
    GL.glEnable(GL.GL_FOG);
    GL.glEnable(GL.GL_DEPTH_TEST);

    cubeListIndexBase = GL.glGenLists(1);
    createCube();
  }