コード例 #1
0
ファイル: GdxGL20.java プロジェクト: hanchao/vtm
 public int glCheckFramebufferStatus(int target) {
   return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
 }
コード例 #2
0
  @Override
  public void writeGPU() {
    if (framebuffer != INVALID_BUFFER)
      throw new IllegalStateException("Framebuffer already created!");

    // Create the color buffer for this renderTexture
    textureID = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexImage2D(
        GL11.GL_TEXTURE_2D,
        0,
        GL11.GL_RGBA8,
        width,
        height,
        0,
        GL11.GL_RGBA,
        GL11.GL_INT,
        (java.nio.ByteBuffer) null); // Create the texture data

    if (useEXT) {
      framebuffer = EXTFramebufferObject.glGenFramebuffersEXT();

      EXTFramebufferObject.glBindFramebufferEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

      EXTFramebufferObject.glFramebufferTexture2DEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
          EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
          GL11.GL_TEXTURE_2D,
          textureID,
          0);

      if (useDepthBuffer) {
        depthTarget = GL30.glGenRenderbuffers();
        EXTFramebufferObject.glBindRenderbufferEXT(
            EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthTarget);
        EXTFramebufferObject.glRenderbufferStorageEXT(
            EXTFramebufferObject.GL_RENDERBUFFER_EXT,
            GL11.GL_DEPTH_COMPONENT,
            this.getWidth(),
            this.getHeight());
        EXTFramebufferObject.glFramebufferRenderbufferEXT(
            EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
            GL30.GL_DEPTH_ATTACHMENT,
            EXTFramebufferObject.GL_RENDERBUFFER_EXT,
            depthTarget);
      }

      if (EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT)
          != EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT) {
        System.out.println("ERROR: Framebuffer not complete");
        throw new ComputerIsPotatoException("Framebuffer not complete");
      }

    } else {
      framebuffer = GL30.glGenFramebuffers();
      GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

      GL30.glFramebufferTexture2D(
          GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureID, 0);

      if (useDepthBuffer) {
        depthTarget = GL30.glGenRenderbuffers();
        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthTarget);
        GL30.glRenderbufferStorage(
            GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, this.getWidth(), this.getHeight());
        GL30.glFramebufferRenderbuffer(
            GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthTarget);
      }
      GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER);

      if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) {
        System.out.println("ERROR: Framebuffer not complete");
        throw new ComputerIsPotatoException("Framebuffer not complete");
      }
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
  }