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);
 }
示例#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);
 }
示例#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);
   }
 }
示例#9
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glGenRenderbuffers(int n, IntBuffer renderbuffers) {
   EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
 }
示例#10
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glGenFramebuffers(int n, IntBuffer framebuffers) {
   EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
 }
示例#11
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glFramebufferTexture2D(
     int target, int attachment, int textarget, int texture, int level) {
   EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
 }
示例#12
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glFramebufferRenderbuffer(
     int target, int attachment, int renderbuffertarget, int renderbuffer) {
   EXTFramebufferObject.glFramebufferRenderbufferEXT(
       target, attachment, renderbuffertarget, renderbuffer);
 }
示例#13
0
 public void free() {
   EXTFramebufferObject.glDeleteRenderbuffersEXT(this.id);
 }
示例#14
0
文件: GdxGL20.java 项目: hanchao/vtm
 public boolean glIsRenderbuffer(int renderbuffer) {
   return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
 }
示例#15
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params) {
   EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
 }
示例#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);
  }
示例#17
0
 protected static void unbind() {
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0);
 }
示例#18
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glGenerateMipmap(int target) {
   EXTFramebufferObject.glGenerateMipmapEXT(target);
 }
示例#19
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glBindFramebuffer(int target, int framebuffer) {
   EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
 }
示例#20
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glGetFramebufferAttachmentParameteriv(
     int target, int attachment, int pname, IntBuffer params) {
   EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target, attachment, pname, params);
 }
示例#21
0
 protected void bind() {
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, this.id);
 }
示例#22
0
文件: GdxGL20.java 项目: hanchao/vtm
 public boolean glIsFramebuffer(int framebuffer) {
   return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
 }
示例#23
0
文件: GdxGL20.java 项目: hanchao/vtm
 public int glCheckFramebufferStatus(int target) {
   return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
 }
示例#24
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glRenderbufferStorage(int target, int internalformat, int width, int height) {
   EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
 }
示例#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();
 }
示例#26
0
文件: GdxGL20.java 项目: hanchao/vtm
 public void glBindRenderbuffer(int target, int renderbuffer) {
   EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
 }
示例#27
0
 RenderBuffer() {
   assert (this.isSupported());
   this.id = EXTFramebufferObject.glGenRenderbuffersEXT();
 }