Пример #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();
  }
Пример #2
0
 protected void popDestTextures() {
   try {
     currentDestTex = destTexStack.pop();
     currentFBO.setDrawBuffers(currentDestTex);
   } catch (EmptyStackException e) {
     System.out.println("Empty texture stack");
   }
 }
Пример #3
0
  protected void popFramebuffer() {
    if (!popFramebufferEnabled) return;

    try {
      currentFBO = fboStack.pop();
      currentFBO.bind();
    } catch (EmptyStackException e) {
      System.out.println("Empty framebuffer stack");
    }
  }
Пример #4
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();
  }
Пример #5
0
  public void clearTex(int glid, int target, 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);

    gl.glClearColor(r, g, b, a);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    popFramebuffer();
  }
Пример #6
0
 protected void setDestTextures(GLTexture[] destTex, int n) {
   currentDestTex = destTex;
   currentFBO.setDrawBuffers(currentDestTex, n);
 }
Пример #7
0
  protected void setFramebuffer(GLFramebufferObject fbo) {
    if (framebufferFixed) return;

    currentFBO = fbo;
    currentFBO.bind();
  }