I set to sleep longer, so I can see, firstly, the red cone was shown up once on the left side and disappeared, then the cyan one was shown up on the right side once and disappeared, then red one again, so I can not get both red one and cyan one on the screen at the same time. Therefore, I attached two photos...
The tested code is simple as below:
import com.threed.jpct._
import org.lwjgl.opengl.GL11
class HelloWorld {
var world:World = null
var cameraLeft:Camera = null
var cameraRight:Camera = null
var cone:Object3D = null
def AnaglyphExample = {
world = new World
val tm: TextureManager = TextureManager.getInstance()
tm.addTexture("Cone", new Texture("textures/jplogo.jpg"))
cone = Primitives.getCone(32,1f)
cone.setTexture("Cone")
cone.setEnvmapped(Object3D.ENVMAP_ENABLED)
cone.build()
world.addObject(cone)
val buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL)
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE)
buffer.enableRenderer(IRenderer.RENDERER_OPENGL)
while (!org.lwjgl.opengl.Display.isCloseRequested) {
buffer.clear()
cameraLeft = world.getCamera
cameraLeft.setPosition(0.2f, -0f, -10f)
GL11.glColorMask(true,false,false,true)
world.renderScene(buffer)
world.draw(buffer)
buffer.update()
buffer.displayGLOnly()
Thread.sleep(1000)
buffer.clearZBufferOnly()
cameraRight = world.getCamera
cameraRight.setPosition(-0.2f,-0f,-10f)
GL11.glColorMask(false,true,true,true)
world.renderScene(buffer)
world.draw(buffer)
buffer.update()
buffer.displayGLOnly()
Thread.sleep(1000)
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL)
buffer.dispose()
System.exit(0)
}
}
object HelloWorld{
def main (args: Array[String]) {
val app = new HelloWorld
app.AnaglyphExample
}
}
[attachment deleted by admin]