LibGDX - Drawing to a FrameBuffer does not work

So I'm trying to make custom buttons, for which I need to combine different parts of the button background. To do this I figured using a FrameBuffer would work, however it did not give viable results. Therefore I attempted to test my FrameBuffer drawing method, by writing a simple test method, which returns a texture that is drawn to the display at every render() call. This method is here (note that it is a test method, so it may be a little poorly optimized):

    private Texture test()
    BitmapFont f = ReverseBlade.fontTitle;

    FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, (int)f.getBounds("Hi").width, (int)f.getBounds("Hi").height, false);
    Batch b = ReverseBlade.batch;
    OrthographicCamera c = new OrthographicCamera(fbo.getWidth(), fbo.getHeight());



    f.draw(b, "Hi", 0, 0);


    Texture t = fbo.getColorBufferTexture();



    return t;

However, nothing is displayed. The screen is dark... I have tried without the camera and multiple other variations that I can no longer remember. What am I doing wrong?

Half Solution What I ended up having to do is to make a new Matrix4 object for the FrameBuffer like this:

Matrix4 m = new Matrix4();
m.setToOrtho2D(0, 0, fbo.getWidth(), fbo.getHeight());

However, this makes everything that is drawn be upside down, like this: Why? I don't know...


I think the fbo.dispose() call is destroying more than you want.

See the source and notice where it destroys the colorTexture, which is the result of getColorBufferTexture().

I think this could be considered a bug in Libgdx. The color texture is generally something that should have a very different lifetime than the FBO, so cleaning up the texture seems a bit too aggressive. However, trying to figure out which cases to clean the texture up is probably complicated.....

Need Your Help

How to get list of monthly periods?

c# date-arithmetic

I have starting date and number of months. I need to create specific number of monthly periods for example:

iPhone - Cover Flow

iphone objective-c ios coverflow

I want to integrate the Cover Flow for the images display in my iPhone Application can anyone guide me how can i do this. I found lot of tutorials on Google but not a single one is helpful

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.