Can't get depth buffer

I found some code on her ( lex's texture renderer code ) and i modified to try and get the depth buffer and draw it on the screen but it just shows up completely white. Any ideas?



import java.text.DecimalFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.lwjgl.opengl.RenderTexture;

import com.jme.app.SimpleGame;
import com.jme.image.Texture;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.renderer.TextureRenderer;
import com.jme.renderer.lwjgl.LWJGLPbufferTextureRenderer;
import com.jme.renderer.lwjgl.LWJGLRenderer;
import com.jme.renderer.lwjgl.LWJGLTextureRenderer;
import com.jme.scene.SceneElement;
import com.jme.scene.Text;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;

public class ShadowMappingTest extends SimpleGame {

    private KeyBindingManager keyboard = KeyBindingManager
            .getKeyBindingManager();
   
    private String switchMode = "switchMode";
   
    private enum Mode{ COPY_TEXTURE, PBUFFER, FBO, DISABLED };
    private Mode mode;
   
    private int width;
    private int height;
   
    private Quad sampleObject;
    private Quad fullscreenQuad;
    private TextureState fullScreenTextureState;
   
    private TextureRenderer fboRenderer;
    //private TextureRenderer pbufferRenderer;
   
    private Texture fboTexture;
    //private Texture pbufferTexture;
    private Texture copyTexture;

    private long timeSpent = 0;
    private long start = 0;
    private float runs = 0;
   
    private DecimalFormat format = new DecimalFormat("0.000");
   
    @Override
    protected void simpleInitGame() {
        width = display.getWidth();
        height = display.getHeight();

        sampleObject = new Quad("Sample", 10, 10);
        sampleObject.updateRenderState();

        fullscreenQuad = new Quad("FullScreenQuad", width, height);
        fullscreenQuad.setLocalTranslation(width / 2.0f, height / 2.0f, 0);
        fullscreenQuad.updateWorldVectors();

        fullscreenQuad.setRenderQueueMode(Renderer.QUEUE_ORTHO);
        fullScreenTextureState = display.getRenderer().createTextureState();
        fullscreenQuad.setRenderState(fullScreenTextureState);

        fullscreenQuad.setCullMode(SceneElement.CULL_NEVER);
        fullscreenQuad.setTextureCombineMode(TextureState.REPLACE);
        fullscreenQuad.setLightCombineMode(LightState.OFF);

        fullscreenQuad.updateRenderState();
       
        keyboard.add(switchMode, KeyInput.KEY_SPACE);
       
        initRenderers();
        fullScreenTextureState.setTexture(copyTexture);
        mode = Mode.COPY_TEXTURE;
       
        Text info = Text.createDefaultTextLabel( "infoKeys" );
      info.setTextureCombineMode( TextureState.REPLACE );
      info.setLocalTranslation(0, display.getHeight() - 20, 0);
      info.print("Press SPACE to toggle between different renderers.");
        fpsNode.attachChild(info);
    }
   
    private void initRenderers() {
       if (!(display.getRenderer() instanceof LWJGLRenderer)) {
          System.err.println("Only LWJGLRenderer can be tested. Exiting...");
          System.exit(0);
       }
       
       // fbo renderer
       fboRenderer = new LWJGLTextureRenderer(width, height,
                (LWJGLRenderer) display.getRenderer());

        fboRenderer.setBackgroundColor(new ColorRGBA(0, 0, 0, 1.0f));
        fboRenderer.setCamera(cam);

        fboTexture = makeRenderTexture();
        fboRenderer.setupTexture(fboTexture);
       
        // copy texture
        copyTexture = makeRenderTexture();
        fboRenderer.setupTexture(copyTexture);
       
        // pbuffer renderer
        /*RenderTexture renderTexture = new RenderTexture(false, true, true,
              false, RenderTexture.RENDER_TEXTURE_2D, 0);
       
        pbufferRenderer = new LWJGLPbufferTextureRenderer(width, height,
                (LWJGLRenderer) display.getRenderer(), renderTexture);
       
        pbufferRenderer.setBackgroundColor(new ColorRGBA(0, 0, 0, 1.0f));
        pbufferRenderer.setCamera(cam);
       
        pbufferTexture = makeRenderTexture();
        pbufferRenderer.setupTexture(pbufferTexture);*/
    }
   
    private Texture makeRenderTexture() {
       Texture texture = new Texture();
        texture.setWrap(Texture.WM_CLAMP_S_CLAMP_T);
        texture.setFilter(Texture.FM_NEAREST);
        texture.setMipmapState(Texture.MM_NONE);
        texture.setRTTSource(Texture.RTT_SOURCE_DEPTH);
        return texture;
    }

    protected void simpleRender() {
       Renderer mainRenderer = display.getRenderer();
        // *********** TIMING ***********
        // wait for opengl
        mainRenderer.finish();

        start = System.nanoTime();
        // *********** /TIMING ***********

        if (mode == Mode.COPY_TEXTURE) {
            // draw quad and copy to texture
           mainRenderer.draw(sampleObject);
           mainRenderer.renderQueue();
            fboRenderer.copyToTexture(copyTexture, width, height);
            // clear the buffer... You need to do this or your rendered
            // stuff will bleed into your real scene.
            mainRenderer.clearBuffers();
        }
        else if (mode == Mode.FBO) {
           
            fboRenderer.render(sampleObject, fboTexture);
        }

        fullscreenQuad.onDraw(mainRenderer);

        // *********** TIMING ***********
        // force queue to render and wait for finish so we can get complete
        // timing info.
        mainRenderer.renderQueue();
        mainRenderer.finish();
        timeSpent += (System.nanoTime() - start);
        runs++;
        // *********** /TIMING ***********
    }
   
    protected void simpleUpdate() {
       updateBuffer.setLength(0);
       updateBuffer.append("Renderer: ");
       updateBuffer.append(mode);
       updateBuffer.append(". FPS: ");
       updateBuffer.append(format.format(timer.getFrameRate()));
       updateBuffer.append(". Average TPF: ");
       updateBuffer.append(format.format(timeSpent / runs / 1e6d));
       updateBuffer.append(" ms. Runs: ");
       updateBuffer.append((int) runs);
       
        fps.print( updateBuffer );
    }

    protected void updateInput() {
        super.updateInput();

        if (keyboard.isValidCommand(switchMode, false)) {
           switchMode();
           
            runs = 0;
            timeSpent = 0;
        }
    }
   
    private void switchMode() {
       switch(mode) {
       
       /*case COPY_TEXTURE:
          mode = Mode.PBUFFER;
          fullScreenTextureState.setTexture(pbufferTexture);
          if (pbufferRenderer.isSupported()) break;*/
          
       case PBUFFER:
          mode = Mode.FBO;
          fullScreenTextureState.setTexture(fboTexture);
          if (fboRenderer.isSupported()) break;
          
       case FBO:
          mode = Mode.DISABLED;
          break;
          
       default:
          mode = Mode.COPY_TEXTURE;
         fullScreenTextureState.setTexture(copyTexture);
       }
    }
   
    protected void cleanup() {
       fboRenderer.cleanup();
       //pbufferRenderer.cleanup();
       super.cleanup();
    }

    public static void main(String[] args) {
        Logger.getLogger("").setLevel(Level.WARNING);

        ShadowMappingTest game = new ShadowMappingTest();
        game.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
        game.start();
    }

}

solved :stuck_out_tongue: