Antialiased rendering to Framebuffer object

Hi there!

I’m trying to incorporate a post processing shader in my first project. So I set up a FrameBuffer, drawing onto it, and then drawing a texture from it onto screen.

But when I render directly on screen, I get this:

When I render using FrameBuffer, I get this:

Notice how different edges of bricks look. As far as I understand, in the second case there is no texture filtering? Or what is causing this is more tricky?

I’m using LibGdx.

Textures are loaded like this:

brickTexture = new Texture(Gdx.files.internal(BRICK));

FrameBuffer setup:

        frameBuffer = FrameBuffer.createFrameBuffer(

And my render() method:

    public void render(float delta) {

        if (paused) {
        } else {

        frameBuffer.begin();, 0, 0, 1);;

        if (paused) {
        } else {

        viewport.apply();, 0, 0, 1);;

        batch.draw(frameBuffer.getColorBufferTexture(), 0, WORLD_HEIGHT, WORLD_WIDTH, -WORLD_HEIGHT);

Okay, maybe my question is incorrect…

Ho do i render to FBO with multisampling?

Ok, guys, according to the link below AND official documentation for OpenGL 4.6, antialiasing is disabled by default for Framebuffer objects (i.e. created by user).

But is it possible to enable it via standard libGDX api? Or do I really need to somehow enable it manually for a FBO I created? I just can’t get it because when I create libGDX FBO, it is created without multisampling, right? So I can’t modify parameters of an already created FBO… And does this in turn mean that I should create an FBO manually, using API calls? If yes, then it seems that I can’t, because both GL20 and GL30 classes does not contain functions mentioned in the example here:

So how do I do this “simple” thing?

Have you had a look at their GitHub issues page?
MSAA for FBOs is an open feature request.
It looks like, since libGDX’s GL abstraction/interface does not yet expose OpenGL 3.2, your only option is to go directly down to LWJGL’s classes and static methods, such as org.lwjgl.opengl.GL32. Doing this will of course bind you to Desktop-only, and will not work on Android or the Web.

To add a bit, MSAA is not something that you just “enable” on a framebuffer. MSAA requires storing multiple samples for each pixel, meaning it needs more memory. A framebuffer object does not contain any actual data; it just renders to textures. If you attach an MSAA texture to the FBO, rendering to it will happen with MSAA. To actually display an MSAA image, you need to resolve it, which usually means averaging the samples of each pixel together. All of this happens automatically when you request an MSAA default framebuffer but needs to be manually taken care of when using FBOs.

KaiHH, yes, after my last post I found that information. I also had read it before, but something just didn’t switch in my had. I also had found out that GL32 class of lwjgl contains required constants. But then goes next question.
If GL ES is a subset of GL, then I can use functions from GL if I know which ones exactly are supported by specific version of GL ES running on my current device (most likely mobile). Right? E.g.: my game knows that current backend is GL ES 3.1, so it can use some specific functions from GL32 which definitely are included in GL ES 3.1. Is this assumption correct?

theagentd, so MSAA depends on the texture bound to FBO, not FBO itself, nor textures (sprites) being rendered to the texture?

Like I said, when you use LWJGL, your application will ONLY work on Desktop.
This is the reason why libGDX has its own GL interface/API to be able to route the GL calls to different underlying implementations (LWJGL on Desktop, WebGL on Web, Android GL ES on Android).
Again, once you use LWJGL classes/methods directly, libGDX has no way of routing the GL calls to Android GL ES anymore and your application WILL NOT work on the Web or Android anymore. There is no way around this without hacking libGDX itself.

Oh, sorry for not understanding it for the first time.

And there is no library like lwjgl for GL ES? I mean, if lwjgl is used for Desktop, so then which library is used for Android?