LibGDX FrameBuffer -



LibGDX FrameBuffer -

i'm trying create game build spaceship parts, , fly around , such.

i create ship series of components (from textureatlas instance). i'd draw ship it's component textures, , save drawn ship 1 big texture. (so don't have draw 50 component textures, 1 ship texture. best way go this?

i've been trying using framebuffer. i've been able draw components texture, , draw texture screen, no matter seek texture ends solid background size of frame buffer. it's clear command can't clear transparency. here's drawing code have @ moment. ship sprite save framebuffer texture to.

public void render(){ if (ship == null){ int screenwidth = gdx.graphics.getwidth(); int screenheight = gdx.graphics.getheight(); spritebatch fb = new spritebatch(); framebuffer fbo = new framebuffer(format.rgb888, screenwidth, screenheight, false); fbo.begin(); fb.enableblending(); gdx.gl.glblendfuncseparate(gl20.gl_src_alpha, gl20.gl_one_minus_src_alpha, gl20.gl_one, gl20.gl_one_minus_src_alpha); gdx.gl.glclearcolor(1, 0, 1, 0); gdx.gl.glclear(gl20.gl_color_buffer_bit); fb.begin(); atlas.createsprite("0").draw(fb); fb.end(); fbo.end(); ship = new sprite(fbo.getcolorbuffertexture()); ship.setposition(0, -screenheight); } gdx.gl.glclearcolor(1, 0, 0, 1); gdx.gl.glclear(gl20.gl_color_buffer_bit); batch.begin(); batch.enableblending(); batch.setblendfunction(gl20.gl_one, gl20.gl_zero); ship.draw(batch); batch.end(); } }

the problem here lies in line:

framebuffer fbo = new framebuffer(format.rgb888, screenwidth, screenheight, false);

specifically format.rgb888. line saying framebuffer should red (8 bits) followed green (8 bits) followed blue (8 bits). notice however, format doesn't have bits alpha (transparency). in order transparency out of frame buffer, instead want utilize format.rgba8888, includes additional 8 bits alpha.

hope helps.

libgdx

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -