[SOLVED] Pixmap from FBO texture?

Anything libgdx related goes here!

[SOLVED] Pixmap from FBO texture?

Postby anigart » Fri Aug 10, 2018 8:30 pm


I'm using a FrameBuffer to compose character sprites that have various overlays (in the form of AtlasSprites), each with Sprite coloring applied. When the FBO is fully composed, I'm creating a new Sprite from its TextureRegion and render it on the screen (adding transparency or other effects as needed).

Now I would like to get a Pixmap from this, to determine whether a pixel in the sprite's bounds is colored or not (for mouse rollover detection). This technique works fine for Sprites that are not created via FBO, using non_fbo_sprite.getTexture().getTextureData().consumePixmap(). However, calling this method on a Sprite that was created via FBO, an error message comes up saying that this type of TextureData does not produce a Pixmap.

Is there a workaround to produce a Pixmap from a Sprite (or its Texture) that was composed via FBO?



Figured it out: ScreenUtils.getFrameBufferPixmap() does exactly that...
Posts: 17
Joined: Sun Jul 31, 2016 10:40 pm

Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest