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);
 }
 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);
   }
 }