Creating my own LWJGLCamera


I'm working on implementing simple shadow mapping for displaying something like a torch carried by the player.

For this, I have to implement depth-map offline rendering from the perspective of the light source. This requires me creating my own camera. However, when I try using the camera I just created (no matter whether I use it for my render-to-texture code or as the target for the render window), I get the OpenGL error "Invalid value (1281)":

SEVERE: Main game loop broken by uncaught exception
org.lwjgl.opengl.OpenGLException: Invalid value (1281)
   at org.lwjgl.opengl.Util.checkGLError(
   at org.lwjgl.opengl.Display.swapBuffers(
   at org.lwjgl.opengl.Display.update(
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(Unknown Source)
   at Source)

This is the code for creating the camera:

           playerCam = new LWJGLCamera(1024,1024,this);
           playerCam.setFrustumPerspective(180f, 1f, 0.1f, 1000f);

I'm updating its position in the update method:

      playerCam.setFrame(node.getWorldTranslation().add(0f,0f,2f), node.getWorldRotation());

In my render method, I'm setting the camera right before actually rendering the rootNode:


I'm calling updateRenderState on my rootNode on every update. Did I miss anything there? The only example for multiple views I found was re-using the single camera object, but that's not what I want (I'd have to reset the camera on every frame)...

Have you tried calling a valid DisplaySystem from a valid renderer to create the cam

see BaseSimpleGame

cam = display.getRenderer().createCamera( display.getWidth(), display.getHeight() )

Thanks, I don't know how I missed that method… however, it didn't solve the problem.

EDIT: Found the issue. Apple's OpenGL debug utility (big plus for that one!) told me that the following call caused the error:

glFrustum(-4.37114e-08, 4.37114e-08, -4.37114e-08, 4.37114e-08, 1, 1000)

Turns out that having a field of view of 180