Exemplo n.º 1
2
  public static void setClearColor(float red, float green, float blue) {
    clearColor[0] = red;
    clearColor[1] = green;
    clearColor[2] = blue;

    if (isShadowPass) {
      glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      return;
    }

    glDrawBuffers(dfbDrawBuffers);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(GL_COLOR_ATTACHMENT0_EXT);
    glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(GL_COLOR_ATTACHMENT1_EXT);
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDrawBuffers(dfbDrawBuffers);
  }
Exemplo n.º 2
0
  public static void endRender() {
    if (isShadowPass) {
      return;
    }

    glPushMatrix();

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glDisable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);

    // composite

    glDisable(GL_BLEND);

    useProgram(ProgramComposite);

    glDrawBuffers(dfbDrawBuffers);

    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(0));
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(1));
    glActiveTexture(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(2));
    glActiveTexture(GL_TEXTURE3);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(3));

    if (colorAttachments >= 5) {
      glActiveTexture(GL_TEXTURE4);
      glBindTexture(GL_TEXTURE_2D, dfbTextures.get(4));
      if (colorAttachments >= 6) {
        glActiveTexture(GL_TEXTURE5);
        glBindTexture(GL_TEXTURE_2D, dfbTextures.get(5));
        if (colorAttachments >= 7) {
          glActiveTexture(GL_TEXTURE6);
          glBindTexture(GL_TEXTURE_2D, dfbTextures.get(6));
        }
      }
    }

    if (shadowPassInterval > 0) {
      glActiveTexture(GL_TEXTURE7);
      glBindTexture(GL_TEXTURE_2D, sfbDepthTexture);
    }

    glActiveTexture(GL_TEXTURE0);

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(0.0f, 0.0f, 0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(1.0f, 0.0f, 0.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f(1.0f, 1.0f, 0.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(0.0f, 1.0f, 0.0f);
    glEnd();

    // final

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    useProgram(ProgramFinal);

    glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(0));
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(1));
    glActiveTexture(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(2));
    glActiveTexture(GL_TEXTURE3);
    glBindTexture(GL_TEXTURE_2D, dfbTextures.get(3));

    if (colorAttachments >= 5) {
      glActiveTexture(GL_TEXTURE4);
      glBindTexture(GL_TEXTURE_2D, dfbTextures.get(4));
      if (colorAttachments >= 6) {
        glActiveTexture(GL_TEXTURE5);
        glBindTexture(GL_TEXTURE_2D, dfbTextures.get(5));
        if (colorAttachments >= 7) {
          glActiveTexture(GL_TEXTURE6);
          glBindTexture(GL_TEXTURE_2D, dfbTextures.get(6));
        }
      }
    }

    if (shadowPassInterval > 0) {
      glActiveTexture(GL_TEXTURE7);
      glBindTexture(GL_TEXTURE_2D, sfbDepthTexture);
    }

    glActiveTexture(GL_TEXTURE0);

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(0.0f, 0.0f, 0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(1.0f, 0.0f, 0.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f(1.0f, 1.0f, 0.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(0.0f, 1.0f, 0.0f);
    glEnd();

    glEnable(GL_BLEND);

    glPopMatrix();

    useProgram(ProgramNone);
  }