void read(ByteBuffer buffer) {
   EXTFramebufferObject.glBindFramebufferEXT(
       EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);
   buffer.position(0);
   GL11.glReadPixels(
       x0, y0, width, height, MipmapHelper.TEX_FORMAT, MipmapHelper.TEX_DATA_TYPE, buffer);
 }
Example #2
0
 public void activate() {
   if (framebuffer == INVALID_BUFFER) return; // Can't set this to active if it's not created yet
   if (useEXT)
     EXTFramebufferObject.glBindFramebufferEXT(
         EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer);
   else GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
   GL11.glViewport(0, 0, width, height);
 }
Example #3
0
 public void release() {
   if (framebuffer != INVALID_BUFFER) {
     if (useEXT)
       EXTFramebufferObject.glBindFramebufferEXT(
           EXTFramebufferObject.GL_FRAMEBUFFER_EXT, SCREEN_BUFFER);
     else GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER);
     GL11.glViewport(0, 0, width, height);
   }
 }
 void delete() {
   if (!deleted) {
     deleted = true;
     if (ownTexture) {
       GL11.glDeleteTextures(texture);
     }
     EXTFramebufferObject.glDeleteFramebuffersEXT(frameBuffer);
   }
 }
    private FBO(int texture, boolean ownTexture, int x0, int y0, int width, int height) {
      this.texture = texture;
      this.ownTexture = ownTexture;
      this.x0 = x0;
      this.y0 = y0;
      this.width = width;
      this.height = height;

      frameBuffer = EXTFramebufferObject.glGenFramebuffersEXT();
      if (frameBuffer < 0) {
        throw new RuntimeException("could not get framebuffer object");
      }
      GLAPI.glBindTexture(texture);
      EXTFramebufferObject.glBindFramebufferEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);
      EXTFramebufferObject.glFramebufferTexture2DEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
          EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
          GL11.GL_TEXTURE_2D,
          texture,
          0);
    }
    void unbind() {
      GL11.glPopAttrib();

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPopMatrix();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPopMatrix();

      if (lightmapEnabled) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_BLEND);
      GLAPI.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

      EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    }
    void bind() {
      EXTFramebufferObject.glBindFramebufferEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);

      GL11.glPushAttrib(glAttributes);
      GL11.glViewport(x0, y0, width, height);
      GL11.glEnable(GL11.GL_SCISSOR_TEST);
      GL11.glScissor(x0, y0, width, height);

      lightmapEnabled = false;
      if (gl13Supported) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        lightmapEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
        if (lightmapEnabled) {
          GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_DEPTH_TEST);
      GLAPI.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GLAPI.glAlphaFunc(GL11.GL_GREATER, 0.01f);
      if (useGL13) {
        GL11.glDisable(GL13.GL_MULTISAMPLE);
      }

      GLAPI.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
      GL11.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
    }
 public static boolean update(TextureAtlasSprite icon, boolean itemFrameRenderer) {
   if (!initialized) {
     logger.finer("deferring %s update until initialization finishes", IconAPI.getIconName(icon));
     return false;
   }
   if (!active) {
     return false;
   }
   int oldFB = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
   if (oldFB != 0 && warnCount < 10) {
     logger.finer(
         "rendering %s while non-default framebuffer %d is active",
         IconAPI.getIconName(icon), oldFB);
     warnCount++;
   }
   int oldTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
   try {
     FancyDial instance = getInstance(icon);
     return instance != null && instance.render(itemFrameRenderer);
   } finally {
     EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFB);
     GLAPI.glBindTexture(oldTexture);
   }
 }
Example #9
0
 public void glGenRenderbuffers(int n, IntBuffer renderbuffers) {
   EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
 }
Example #10
0
 public void glGenFramebuffers(int n, IntBuffer framebuffers) {
   EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
 }
Example #11
0
 public void glFramebufferTexture2D(
     int target, int attachment, int textarget, int texture, int level) {
   EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
 }
Example #12
0
 public void glFramebufferRenderbuffer(
     int target, int attachment, int renderbuffertarget, int renderbuffer) {
   EXTFramebufferObject.glFramebufferRenderbufferEXT(
       target, attachment, renderbuffertarget, renderbuffer);
 }
Example #13
0
 public void free() {
   EXTFramebufferObject.glDeleteRenderbuffersEXT(this.id);
 }
Example #14
0
 public boolean glIsRenderbuffer(int renderbuffer) {
   return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
 }
Example #15
0
 public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params) {
   EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
 }
Example #16
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);
  }
Example #17
0
 protected static void unbind() {
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0);
 }
Example #18
0
 public void glGenerateMipmap(int target) {
   EXTFramebufferObject.glGenerateMipmapEXT(target);
 }
Example #19
0
 public void glBindFramebuffer(int target, int framebuffer) {
   EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
 }
Example #20
0
 public void glGetFramebufferAttachmentParameteriv(
     int target, int attachment, int pname, IntBuffer params) {
   EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target, attachment, pname, params);
 }
Example #21
0
 protected void bind() {
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, this.id);
 }
Example #22
0
 public boolean glIsFramebuffer(int framebuffer) {
   return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
 }
Example #23
0
 public int glCheckFramebufferStatus(int target) {
   return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
 }
Example #24
0
 public void glRenderbufferStorage(int target, int internalformat, int width, int height) {
   EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
 }
Example #25
0
 public void initStorage(final int internalFormat, final int width, final int height) {
   this.bind();
   EXTFramebufferObject.glRenderbufferStorageEXT(
       EXTFramebufferObject.GL_RENDERBUFFER_EXT, internalFormat, width, height);
   RenderBuffer.unbind();
 }
Example #26
0
 public void glBindRenderbuffer(int target, int renderbuffer) {
   EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
 }
Example #27
0
 RenderBuffer() {
   assert (this.isSupported());
   this.id = EXTFramebufferObject.glGenRenderbuffersEXT();
 }