Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX Draw with Anti-Aliasing to a non-default FrameBuffer [RESOLVED]  (Read 7864 times)
0 Members and 1 Guest are viewing this topic.
Offline DaGamesta

Junior Newbie

Exp: 2 years

« Posted 2015-05-19 16:20:02 »

To be short and to the point, I draw to a FrameBuffer I create and then export the contents of that FrameBuffer to a Texture, in order to save me processing power on phones by pre-rendering my image. However, MSAA is only performed by OpenGL 20 on the default FrameBuffer, if I understand correctly.

Therefore, is it possible to get cross-platform Anti-Aliasing of any kind on a non-default FrameBuffer, and how can I accomplish this? I am sorry if this is a very general question, but I hardly know anything about OpenGL itself. I've looked into it a little bit, but LibGDX doesn't always seem to have all the functions that I see available (e.g., glGetTexImage, since I'm not sure how to actually retrieve the texture as a Libgdx Texture), or there just plain isn't much documentation (as far as my searches have taken me) on how to apply Anti-Aliasing through a non-default FrameBuffer in OpenGL through LibGDX.

TLDR; How do I use Cross Platform Anti-Aliasing on an FBO through LibGDX?

Since this question has to do with problems related to my attempt to speed up my rendering, I am putting it in Performance Tuning. Please move this thread to the proper sub-forum if I'm incorrect.


EDIT: According to, MSAA with FBO is impossible on Android devices, but that was back in 2012.  Even if it's still impossible on some Android devices due to hardware restrictions or something like that, is it possible to use MSAA through LibGDX with devices that do support it on FBO, or failing that, is any anti-aliasing (preferably not FSAA as that uses a lot of resources) possible on FBO through LibGDX?
Offline Riven

« JGO Overlord »

Medals: 1371
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #1 - Posted 2015-05-20 21:53:54 »

If everything else fails, you can always do it manually. Render to a texture that is a multiple of the size desired. Then let the GPU generate mipmaps and copy that mipmap layer into a texture, or downsample it yourself. It's much more computationally expensive than proper AA, but as it's part of a pre-rendering effort, you can probably get away with this simple workaround.

Don't forget you can also simply use the draw-(frame)buffer to compose these pre-rendered textures/sprites: clear buffer, draw sprite content, copy to texture, clear buffer, start rendering actually visible content. This is how everybody did it prior to FBOs / pbuffers.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline DaGamesta

Junior Newbie

Exp: 2 years

« Reply #2 - Posted 2015-05-21 05:19:35 »

Thank you Riven, it didn't occur to me that I could do it manually like that, I'm kind of new to LibGDX, never even mind OpenGL.

I tried downsampling and am indeed getting a clearer image.  Better yet, since I'm mostly just pasting a bunch of much smaller sprites with various rotations onto this bigger texture, I'm just downsampling the rotated versions of the smaller sprites as opposed to downsampling the entire thing.  Not really sure if there's a limit on texture sizes.

I'm not really sure how exactly the second method works, or that I really understand the difference between a "draw-(frame)buffer" and an FBO.

All in all, the downsampling method works as a sufficient replacement for MSAA, thank you very much for the advice. Smiley
Pages: [1]
  ignore  |  Print  

mercenarius (4 views)
2020-06-04 19:26:01

mercenarius (2 views)
2020-06-04 19:13:43

Riven (850 views)
2019-09-04 15:33:17

hadezbladez (5834 views)
2018-11-16 13:46:03

hadezbladez (2635 views)
2018-11-16 13:41:33

hadezbladez (6251 views)
2018-11-16 13:35:35

hadezbladez (1504 views)
2018-11-16 13:32:03

EgonOlsen (4739 views)
2018-06-10 19:43:48

EgonOlsen (5797 views)
2018-06-10 19:43:44

EgonOlsen (3282 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!