Splitscreen + Macbook

Hi all, it's me again…

I've been figuring out how to implement a splitscreen for my race game and came to my ming, after some research here, to render two textures and show them ORTHO for the final image… Dunno if this is too much for the rasterizers or if there's another way to do it…

The problem I found is that (again) the crappy OpenGL support on macbooks (not PRO), implementing OpenGL v 1.2 only…

I got this error in TestSpatialLookAt:

SEVERE: Exception
java.lang.RuntimeException: FrameBuffer: 1, has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception
   at com.jme.renderer.lwjgl.LWJGLTextureRenderer.checkFBOComplete(LWJGLTextureRenderer.java:437)
   at com.jme.renderer.lwjgl.LWJGLTextureRenderer.render(LWJGLTextureRenderer.java:328)
   at com.jme.renderer.lwjgl.LWJGLTextureRenderer.render(LWJGLTextureRenderer.java:278)
   at jmetest.renderer.TestSpatialLookAt.simpleRender(TestSpatialLookAt.java:153)
   at com.jme.app.SimpleGame.render(SimpleGame.java:95)
   at com.jme.app.BaseGame.start(BaseGame.java:82)
   at jmetest.renderer.TestSpatialLookAt.main(TestSpatialLookAt.java:117)
1/Set/2007 18:43:59 class jmetest.renderer.TestSpatialLookAt start()
SEVERE: Exception in game loop
org.lwjgl.opengl.OpenGLException: Invalid framebuffer operation (1286)
   at org.lwjgl.opengl.Util.checkGLError(Util.java:53)
   at org.lwjgl.opengl.Display.swapBuffers(Display.java:591)
   at org.lwjgl.opengl.Display.update(Display.java:609)
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(LWJGLRenderer.java:514)
   at com.jme.app.BaseGame.start(BaseGame.java:85)
   at jmetest.renderer.TestSpatialLookAt.main(TestSpatialLookAt.java:117)
1/Set/2007 18:43:59 com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
1/Set/2007 18:43:59 com.jme.app.BaseGame start
INFO: Application ending.

Is it something I shoull try to investigate or isn't possible to do it with only 1.2 + some ARBs?

You could drop the render to texture approach and use viewports instead, but it'd be nice if you could fix RTT on mac.

I'll start digging into the RTT stuff and try to implement the two sequencial rendering with different viewports.

Ok, Half work done in splitscreen, hahaha:

Created two cameras with half the screen height:

camera = display.getRenderer().createCamera(display.getWidth(), display.getHeight()/2);
camera2 = display.getRenderer().createCamera(display.getWidth(), display.getHeight()/2);

Made this, so the first camera will be on top:


And when rendering, I do:



The problem is that when the second camera gets rendered, it clears what's been rendered by the first one. I know both are being rendered because of the increased load and consequent lower framerate, and because if I comment some lines I can render them separately... Each one in its correct part of the screen. I am not calling clearBuffers() twice... I coded this in StandarGame for testing and I'm sure it's being called only once.

Am I missing something? How can I render the second one without blacking the first one? I'll try to put some screenshots in a subsequent post.

Put a breakpoint on every invocation of glCear or something… my guess is it's still being called somewhere.

llama said:

You could drop the render to texture approach and use viewports instead, but it'd be nice if you could fix RTT on mac.

AFAIK, rtt works fine on both Intel and PPC macs as of the last patch I did about a week ago...  If there is a small test showing it *not* working, I'd be happy to work on any additional fixes.

OK, two cameras set and working… The solution was to update each camera before drawing the scene graph:



Now, another issue:

I'm creating two ChaseCameras, one for each camera and with it's own target... The controls are working fine, both for keyboard and joysticks... The problem is that the second ChaseCamera gets influenced by the first one somehow. The second folows the target (camera location OK), but keeps looking to somewhere the target of the first Chaser is heading. Both chasers are being updated together, synchronized with physics and before the two separete drawings.

Here is a screenshot showing the results, look at the lower viewport to see the car not being chased correctly:

Maybe the problem here is that one of the cameras (i.e. the first one) is influencing the second one because they are attached both to the same node, or even worse, one is a child of the other one…  :? Could you try changing that or even removing your first camera while processing your second one?

BTW, nice screen shot.  :wink:

The cameras are not attached to any Node, they are simple Cameras (not CameraNodes), controlled by two separate InputHandlers (ChaseCameras), each one with its own target Node. I'll look at something like this though.

It is strange… ChaseCamera has a

cam.lookAt(targetPos, worldUpVec);

line in update. Perhaps you could debug this by introducing a couple of println statements in ChaseCamera to print the position of the camera, its direction and the position of the node to follow. Perhaps your second node is off or this is being screwed up by something else.