OffscreenRenderer (Librarian !)

I am using http://www.jmonkeyengine.com/wiki/doku.php?id=offscreen_renderer to achieve a minimap.

I changed your code to work with JME 1.0 (ahem, I only fixed the logging).

As far as I can see this is ment to work like that:

I have a primary renderer which renders the overall scene.

The offscreenrenderer uses that as it's parentrenderer.

After instantiating the OffscreenRenderer turns black and that's it.

After playing around I foudn the offending line in the constructor:

EXTFramebufferObject.glBindFramebufferEXT(

EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fboID);

I am sorry, so far FBOs are book with seven seals to me so I don't have the slightest clue what could be going wrong here.

If you are using multiple threads then it could be an issue of not calling your offscreen renderer method from openGL thread. Another possibility is that your system doesn’t support a configuration of FBO you are trying to use.



Try running a test for all texture renderers and see if your screen blacks out or not.

http://www.jmonkeyengine.com/jmeforum/index.php?topic=6211.0

Your testprogram shows no problems.

I also don't think that the graphicscard is a problem, it's a GeForce 7950 GT on Ubunut with recent drivers.

The rendering shouldn't be a problem. I am only creating the renderer. I am not rendering anyhting to it.

The creation also happens before anything is started.

Also the javadoc for glGenFramebuffersEXT is missing so I don't know what the parameter does that is passed in.

If the test is working the problem is likely somewhere in your code.



Are using multiple threads? If so, make sure that you create the renderer in OpenGL thread.

Do you initialize DisplaySystem prior initializing TextureRenderer?

I am trying to reproduce the problem in a smaller program.

Our main application uses multiple threads but everything is happening in the OpenGL thread and FBOs are the only problem we are having (TextureStates are working for example).

Look in which thread your TextureRenderer is initialized. If its initialized outside of OpenGL thread, wrap the initialization like this:


      Future<Object> future = GameTaskQueueManager.getManager().update(
            new Callable<Object>()
      {
         public Object call() throws Exception {
            textureRenderer = DisplaySystem.getDisplaySystem().createTextureRenderer();
                                // more setup here
            return null;
         }
      });

      try {
         // wait for OpenGL thread
         future.get();
      } catch (InterruptedException e) {
         log.log(Level.SEVERE, "Unexpected interrupt.", e);
      } catch (ExecutionException e) {
         log.log(Level.SEVERE, "Unexpected exception.", e);
      }

                // continue with other initialization that can be done outside OpenGL thread

The TextureRendering is working.

It is Librarians OffscreenRenderer that I can't get to work.

Textures and Render to Texture is working.

But I am debugging my threads right now.

Have you checked that the displayed color (black in your case) changes accordingly to changes made with OffScreenRenderer.setBackgroundColor()? (black is the default color)

If the color changes, my guess is that it's a camera problem (which you can reposition using the OffscreenRenderer.getCamera() method). Default camera settings are those:


camera = new LWJGLCamera(width, height, this, true);
        camera.setFrustum(1.0f, 1000.0f, -0.50f, 0.50f, 0.50f, -0.50f);
        Vector3f loc = new Vector3f(0.0f, 0.0f, 0.0f);
        Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
        Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
        Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
        camera.setFrame(loc, left, up, dir);



As a side note, this class works EXACTLY like the TextureRenderer class: you instantiate it, initialize it (bg color, camera,...), and give it a node to render from time to time (don't try to render in every loop pass like your main renderer, grabScreenContent() is just too slow I believe). To debug it, try to call the render() method only once and see what comes out of the getImageData() method (IntBuffer). Then convert it to your image format (I'll update the code to output a JMEImage in the future)

The funny thing is that I got it working in a sandbox with all my stuff.

I have no idea what's going wrong i my other app.