Ejemplo n.º 1
0
  public void paintTex(int glid, int target, int w, int h, int color) {
    float r, g, b, a;
    int ir, ig, ib, ia;

    ia = (color >> 24) & 0xff;
    ir = (color >> 16) & 0xff;
    ig = (color >> 8) & 0xff;
    ib = color & 0xff;

    a = ia / 255.0f;
    r = ir / 255.0f;
    g = ig / 255.0f;
    b = ib / 255.0f;

    pushFramebuffer();
    setFramebuffer(FBO);
    FBO.setDrawBuffer(target, glid);

    saveView();
    setOrthographicView(w, h);
    gl.glColor4f(r, g, b, a);
    gl.glBegin(GL.GL_QUADS);
    gl.glVertex2f(0.0f, 0.0f);
    gl.glVertex2f(w, 0.0f);
    gl.glVertex2f(w, h);
    gl.glVertex2f(0.0f, h);
    gl.glEnd();
    restoreView();

    popFramebuffer();
  }
Ejemplo n.º 2
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();
  }