Last active
October 23, 2017 07:43
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.badlogic.gdx.graphics.Pixmap; | |
import com.badlogic.gdx.graphics.Texture; | |
import com.badlogic.gdx.graphics.glutils.FrameBuffer; | |
import com.badlogic.gdx.graphics.glutils.GLFrameBuffer; | |
public class SubclassedFramebufferBuilder extends GLFrameBuffer.FrameBufferBuilder { | |
protected boolean keepColourTextures; | |
public SubclassedFramebufferBuilder (int width, int height) { | |
super(width, height); | |
} | |
public void keepColorTextures (boolean keepColorTextures) { | |
this.keepColourTextures = keepColorTextures; | |
} | |
@Override | |
public FrameBuffer build () { | |
return new FrameBuffer(this) { | |
@Override | |
protected void disposeColorTexture (Texture colorTexture) { | |
if (!keepColourTextures) { | |
super.disposeColorTexture(colorTexture); | |
} | |
} | |
}; | |
} | |
/** | |
* Example use to create a convenience method | |
*/ | |
public static FrameBuffer createBasicExtended (Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil, boolean keepColorTextures) { | |
SubclassedFramebufferBuilder frameBufferBuilder = new SubclassedFramebufferBuilder(width, height); | |
frameBufferBuilder.addBasicColorTextureAttachment(format); | |
frameBufferBuilder.keepColorTextures(keepColorTextures); | |
if (hasDepth) frameBufferBuilder.addDepthRenderBufferAttachment(); | |
if (hasStencil) frameBufferBuilder.addStencilRenderBufferAttachment(); | |
return frameBufferBuilder.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment