Skip to content

Instantly share code, notes, and snippets.

@Tom-Ski
Last active October 23, 2017 07:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Tom-Ski/b513ef545342a850551e13f0e608e505 to your computer and use it in GitHub Desktop.
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