Пример #1
0
  private static void setupShadowRenderTexture() {
    if (shadowPassInterval <= 0) {
      return;
    }

    // depth
    glDeleteTextures(sfbDepthTexture);
    sfbDepthTexture = glGenTextures();
    glBindTexture(GL_TEXTURE_2D, sfbDepthTexture);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    ByteBuffer buffer = ByteBuffer.allocateDirect(shadowMapWidth * shadowMapHeight * 4);
    glTexImage2D(
        GL_TEXTURE_2D,
        0,
        GL_DEPTH_COMPONENT,
        shadowMapWidth,
        shadowMapHeight,
        0,
        GL_DEPTH_COMPONENT,
        GL11.GL_FLOAT,
        buffer);
  }
Пример #2
0
  private static void setupRenderTextures() {
    glDeleteTextures(dfbTextures);
    glGenTextures(dfbTextures);

    for (int i = 0; i < colorAttachments; ++i) {
      glBindTexture(GL_TEXTURE_2D, dfbTextures.get(i));
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      if (i == 1) { // depth buffer
        ByteBuffer buffer = ByteBuffer.allocateDirect(renderWidth * renderHeight * 4 * 4);
        glTexImage2D(
            GL_TEXTURE_2D,
            0,
            GL_RGB32F_ARB,
            renderWidth,
            renderHeight,
            0,
            GL_RGBA,
            GL11.GL_FLOAT,
            buffer);
      } else {
        ByteBuffer buffer = ByteBuffer.allocateDirect(renderWidth * renderHeight * 4);
        glTexImage2D(
            GL_TEXTURE_2D,
            0,
            GL_RGBA,
            renderWidth,
            renderHeight,
            0,
            GL_RGBA,
            GL_UNSIGNED_BYTE,
            buffer);
      }
    }
  }