[SOLVED] Create 2d Image from 3d Scene

I thought it was not necessary… Anyway, I tried this, same result :

        Image img = Utils.createFrameBufferImage( mazetexture.getFrameBuffer() );
        Main.ref_renderer.readFrameBuffer(mazetexture.getFrameBuffer(), img.getData(0));
        Texture2D newimg = new Texture2D( img );
        mazebackgroundImage.getMaterial().setTexture("ColorMap" , newimg );

Then the frame buffer hasn’t been rendered to yet when you call that.

Either way, it’s important to remember that this is the key line:

Without this, how else would any data ever get to your image?!?!?!?!?!?

Without it your code:
-creates an empty image compatible with the frame buffer
-???
-sticks it into a texture.

Anyway, for whatever reason you may need to render one more frame before capturing the image or something.

Thats weird…

@Override public void update(float tpf) {
    if(!mazetextureAplied && mazetexture.getTexture() !=null) {
        mazetextureAplied=true;

        Image img = Utils.createFrameBufferImage( mazetexture.getFrameBuffer() );
        Main.ref_renderer.readFrameBuffer(mazetexture.getFrameBuffer(), img.getData(0));
        Texture2D newimg = new Texture2D( img );
        mazebackgroundImage.getMaterial().setTexture("ColorMap" , newimg );

        //mazebackgroundImage.getMaterial().setTexture("ColorMap" , mazetexture.getTexture() ); <<== If I uncomment this line this works...

    }
}

The texture seens to be valid when this codes runs, if I comment this lines and uncoment the directly gettexture it shows the linked image in screen…

Maybe I need to call something like buffer.flush or something ?

Maybe you need to render the frame twice as I suggested. Yes, it’s weird. Render it twice.

Thats very odd, but works !

@Override public void update(float tpf) {
    if(mazetextureApliedCounter<2 && mazetexture.getTexture() !=null) {
        mazetextureApliedCounter=mazetextureApliedCounter+1;

        Image img = Utils.createFrameBufferImage( mazetexture.getFrameBuffer() );
        Main.ref_renderer.readFrameBuffer(mazetexture.getFrameBuffer(), img.getData(0));
        Texture2D newimg = new Texture2D( img );
        mazebackgroundImage.getMaterial().setTexture("ColorMap" , newimg );
        if(mazetextureApliedCounter==2) mazetexture.cleanUp();
    }
}

My friend, just you to know this stuffs :slight_smile:
Thanks again !