opengl - Ambiguous results with Frame Buffers in libgdx -
i getting next weird results framebuffer class in libgdx.
here code producing result:
// rendering code @override public void render(float delta) { gdx.gl.glclear(gl20.gl_color_buffer_bit | gl20.gl_depth_buffer_bit); stage.act(); stage.draw(); fbo.begin(); batch.begin(); batch.draw(heart, 0, 0); batch.end(); fbo.end(); test = new image(fbo.getcolorbuffertexture()); test.setposition(256, 256); stage.addactor(test); } //this initialization code @override public void show() { stage = new stage(gdx.graphics.getwidth(), gdx.graphics.getheight(), false); atlas = assets.getatlas(); batch = new spritebatch(); background = new image(atlas.findregion("background")); background.setfillparent(true); heart = atlas.findregion("fluttering"); fbo = new framebuffer(pixmap.format.rgba8888, heart.getregionwidth(), heart.getregionheight(), false); stage.addactor(background); image temp = new image(new textureregion(heart)); stage.addactor(temp); }
why getting heart drew on frame buffer flipped , smaller original 1 though frame buffer width , height same of image (71 x 72).
your spritebatch using wrong projection matrix. since rendering custom sized framebuffer have manually set one.
projectionmatrix = new matrix4(); projectionmatrix.settoortho2d(0, 0, heart.getregionwidth(), heart.getregionheight()); batch.setprojectionmatrix(projectionmatrix);
opengl opengl-es libgdx framebuffer fbo
No comments:
Post a Comment