Hi,
is it possible to render a GUI component (located in gui bucket and rendered orthogonal) to render to a texture. I tried the sample code from the TestRenderToTexture but i didn’t succeed. I only see a very small stripe of the component.
I simply want to know, if this can be done this way or not.
The code is:
[java]
Camera offCamera = new Camera(512, 512);
ViewPort offView = GUIManager.getInstance().getRenderManager().createPreView(“Offscreen View”, offCamera);
offView.setClearFlags(true, true, true);
offView.setBackgroundColor(ColorRGBA.Black);
// create offscreen framebuffer
FrameBuffer offBuffer = new FrameBuffer(512, 512, 1);
// setup framebuffer’s cam
offCamera.setFrustumPerspective(45f, 1f, 1f,1000f);
offCamera.setLocation(new Vector3f(0f, 0f, -1f));
offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Z);
// setup framebuffer’s texture
Texture2D offTex = new Texture2D(512, 512, Format.ABGR8);
offTex.setMinFilter(Texture.MinFilter.Trilinear);
offTex.setMagFilter(Texture.MagFilter.Bilinear);
// setup framebuffer to use texture
offBuffer.setDepthBuffer(Format.Depth16);
offBuffer.setColorTexture(offTex);
// set viewport to render to offscreen framebuffer
offView.setOutputFrameBuffer(offBuffer);
offView.attachScene(dragComponent.getVisibleNode());
//set the texture to the gui component
setBackgroundTexture(offTex);
[/java]
FYI: I need this to implement drag and drop indication for a gui lib.
Which size is your compoent? 512x512?
I’m using render-to-texture and display the resulting texture as a NiftyImage, so yes, it’s possible.
Make sure the component you’re using has the correct translation and rotation.
Edit: i read your requirement backwards, i’m afraid.