Game Development Reference
In-Depth Information
7. Now, we need a Texture2D class to store the data in, so we create a class called
offScreenTexture with the same width and height as before and set
MinFilter to Trilinear :
final Texture2D offScreenTexture = new
Texture2D(width, height, Image.Format.RGB8);
offScreenTexture.setMinFilter(Texture.MinFilter.Trilinear);
8. A FrameBuffer class is needed as a medium for the data, so we create one
with the same width and height, and 1 sample, as shown in the following code:
FrameBuffer offScreenBuffer = new FrameBuffer(width,
height, 1);
9. We set DepthBuffer to be Image.Format.Depth and offScreenTex-
ture to be ColorTexture :
offScreenBuffer.setDepthBuffer(Image.Format.Depth);
offScreenBuffer.setColorTexture(offScreenTexture);
10. Then, we set outPutFrameBuffer of offScreenView to be
offScreenBuffer :
offScreenView.setOutputFrameBuffer(offScreenBuffer);
11. Unless the scene we supplied already has some lights, we should add at least one
Light class to it.
12. Then, we attach the scene to offScreenView :
offScreenView.attachScene(scene);
13. To store the texture, we can add it to AssetManager with the following line:
((DesktopAssetManager)app.getAssetManager()).addToCache(
new TextureKey(scene.getName()+"_mini.png", true),
offScreenTexture);
14. Now, we can do the actual rendering by calling the application's renderMan-
ager and renderViewPort methods:
app.getRenderManager().renderViewPort(offScreenView,
0);
Search WWH ::




Custom Search