Пример #1
0
  public void copyTex(GLTexture srcTex, GLTexture destTex) {
    float uscale = srcTex.getMaxTextureCoordS();
    float vscale = srcTex.getMaxTextureCoordT();

    float cx = 0.0f;
    float sx = +1.0f;
    if (destTex.isFlippedX()) {
      cx = 1.0f;
      sx = -1.0f;
    }

    float cy = 0.0f;
    float sy = +1.0f;
    if (destTex.isFlippedY()) {
      cy = 1.0f;
      sy = -1.0f;
    }

    gl.glEnable(srcTex.getTextureTarget());

    gl.glActiveTexture(GL.GL_TEXTURE0);
    gl.glBindTexture(srcTex.getTextureTarget(), srcTex.getTextureID());

    pushFramebuffer();
    setFramebuffer(FBO);
    FBO.setDrawBuffer(destTex.getTextureTarget(), destTex.getTextureID());

    saveView();
    setOrthographicView(destTex.width, destTex.height);
    gl.glEnable(srcTex.getTextureTarget());
    gl.glActiveTexture(GL.GL_TEXTURE0);
    gl.glBindTexture(srcTex.getTextureTarget(), srcTex.getTextureID());
    gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glBegin(GL.GL_QUADS);
    gl.glTexCoord2f((cx + sx * 0.0f) * uscale, (cy + sy * 0.0f) * vscale);
    gl.glVertex2f(0.0f, 0.0f);

    gl.glTexCoord2f((cx + sx * 1.0f) * uscale, (cy + sy * 0.0f) * vscale);
    gl.glVertex2f(srcTex.width, 0.0f);

    gl.glTexCoord2f((cx + sx * 1.0f) * uscale, (cy + sy * 1.0f) * vscale);
    gl.glVertex2f(srcTex.width, srcTex.height);

    gl.glTexCoord2f((cx + sx * 0.0f) * uscale, (cy + sy * 1.0f) * vscale);
    gl.glVertex2f(0.0f, srcTex.height);
    gl.glEnd();
    gl.glBindTexture(srcTex.getTextureTarget(), 0);
    restoreView();

    popFramebuffer();
  }
Пример #2
0
  /** paint the portal using gl. */
  public void paint(GL gl, GLDrawable glc) {

    if (fill != null) {
      setColor(gl, fill);
      gl.glDisable(GL.GL_TEXTURE_2D);
    }
    gl.glLineWidth(lineWidth());
    gl.glBegin(GL.GL_LINES); // draw each wall
    for (int i = 0; i < pts2d.size(); i++) {
      Point2D p = (Point2D) (pts2d.get(i));
      gl.glVertex2d(p.x, p.y);
    }
    gl.glEnd();

    if (pts2d.size() == 4) {
      /* Connect mid point of the two line segments with dotted line*/
      gl.glLineStipple(1, (short) 0x0F0F);
      gl.glEnable(GL.GL_LINE_STIPPLE);
      gl.glLineWidth(1);
      gl.glBegin(GL.GL_LINES);
      Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      mid = pts2d.get(2).interp(pts2d.get(3), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      gl.glEnd();
      gl.glDisable(GL.GL_LINE_STIPPLE);
    }
  }
Пример #3
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();
  }
 public void init(GLAutoDrawable drawable) {
   GL gl = drawable.getGL();
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadMatrixd(this._nyar.getGlProjectionMatrix(), 0);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   Animator animator = new Animator(drawable);
   animator.start();
   return;
 }
Пример #5
0
 void texsel(int id) {
   if (id != sh.curtex) {
     HavenPanel.texmiss++;
     if (id == -1) {
       gl.glDisable(GL.GL_TEXTURE_2D);
     } else {
       gl.glEnable(GL.GL_TEXTURE_2D);
       gl.glBindTexture(GL.GL_TEXTURE_2D, id);
     }
     sh.curtex = id;
   } else {
     HavenPanel.texhit++;
   }
 }
Пример #6
0
 protected void enableBlend() {
   blendEnabled = true;
   gl.glEnable(GL.GL_BLEND);
 }