Created
July 20, 2012 16:54
-
-
Save rectalogic/3151867 to your computer and use it in GitHub Desktop.
multisample offscreen rendering in TestRenderToMemory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/test/jme3test/post/TestRenderToMemory.java | |
=================================================================== | |
--- src/test/jme3test/post/TestRenderToMemory.java (revision 9561) | |
+++ src/test/jme3test/post/TestRenderToMemory.java (working copy) | |
@@ -75,6 +75,7 @@ | |
private float angle = 0; | |
private FrameBuffer offBuffer; | |
+ private FrameBuffer resolveBuffer; | |
private ViewPort offView; | |
private Texture2D offTex; | |
private Camera offCamera; | |
@@ -158,7 +159,9 @@ | |
public void updateImageContents(){ | |
cpuBuf.clear(); | |
- renderer.readFrameBuffer(offBuffer, cpuBuf); | |
+ // resolve multisampled framebuffer | |
+ renderer.copyFrameBuffer(offBuffer, resolveBuffer, false); | |
+ renderer.readFrameBuffer(resolveBuffer, cpuBuf); | |
synchronized (image) { | |
Screenshots.convertScreenShot(cpuBuf, image); | |
@@ -180,8 +183,10 @@ | |
// frame buffer | |
offView.addProcessor(this); | |
- // create offscreen framebuffer | |
- offBuffer = new FrameBuffer(width, height, 1); | |
+ // create multisampled offscreen framebuffer | |
+ offBuffer = new FrameBuffer(width, height, 4); | |
+ // create single sampled resolve framebuffer | |
+ resolveBuffer = new FrameBuffer(width, height, 1); | |
//setup framebuffer's cam | |
offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f); | |
@@ -195,6 +200,7 @@ | |
// this is faster for gpu -> cpu copies | |
offBuffer.setDepthBuffer(Format.Depth); | |
offBuffer.setColorBuffer(Format.RGBA8); | |
+ resolveBuffer.setColorBuffer(Format.RGBA8); | |
// offBuffer.setColorTexture(offTex); | |
//set viewport to render to offscreen framebuffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment