I got same error. Its most probably that error is in my code, not in JPCT.
I modified "SimpleShadow.java" sample to put it in a canvas and render it at 640 * 480.
I got same error:.
The modified "SimpleShadow.java" code is this:
import java.awt.*;
import javax.swing.JFrame;
import java.awt.Canvas;
import com.threed.jpct.*;
import com.threed.jpct.util.*;
public class SimpleShadows extends JFrame{
private Canvas canvas = null;
private boolean fin = false;
private FrameBuffer fb = null;
private World world = null;
private Object3D plane = null;
private Object3D cube = null;
private Object3D sphere = null;
private Projector projector=null;
private ShadowHelper sh = null;
private Light sun=null;
public SimpleShadows() {
super("TEST JNJ");
Config.glColorDepth = 24;
Config.glFullscreen = false;
Config.farPlane = 1000;
Config.glShadowZBias = 0.8f;
Config.glTrilinear=true;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private void initStuff() throws Exception {
fb = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_NORMAL);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
world = new World();
plane = Primitives.getPlane(20, 30);
plane.rotateX((float) Math.PI / 2f);
cube=Primitives.getCube(15);
cube.setAdditionalColor(Color.RED);
cube.translate(0, -30, -10);
sphere=Primitives.getSphere(12);
sphere.translate(0, 0, -50);
sphere.setAdditionalColor(new Color(0,0,50));
world.addObject(sphere);
world.addObject(plane);
world.addObject(cube);
TextureManager tm = TextureManager.getInstance();
projector = new Projector();
sh = new ShadowHelper(world, fb, projector, 512);
sh.addCaster(cube);
sh.addReceiver(plane);
sh.addReceiver(sphere);
sh.setAmbientLight(new Color(30,30,30));
sh.setFiltering(true);
world.setAmbientLight(90,90,90);
world.buildAllObjects();
sun=new Light(world);
sun.setIntensity(50, 50, 50);
canvas = fb.enableGLCanvasRenderer();
System.out.println("listo canvas");
System.out.println("Poniendo canvas");
this.getContentPane().add(canvas);
}
private void doIt() throws Exception {
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 150);
cam.moveCamera(Camera.CAMERA_MOVEUP, 100);
cam.lookAt(plane.getTransformedCenter());
projector.setFOV(0.5f);
projector.setYFOV(0.5f);
SimpleVector pos=cube.getTransformedCenter();
projector.setPosition(pos);
projector.moveCamera(Camera.CAMERA_MOVEUP, 200);
projector.lookAt(pos);
SimpleVector offset=new SimpleVector(1,0,-1).normalize();
projector.moveCamera(offset, 215);
while (!fin) {
projector.lookAt(cube.getTransformedCenter());
offset.rotateY(0.007f);
projector.setPosition(pos);
projector.moveCamera(new SimpleVector(0,-1,0), 200);
projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());
sh.updateShadowMap();
fb.clear();
sh.drawScene();
fb.update();
fb.displayGLOnly();
canvas.repaint();
Thread.sleep(10);
}
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
fb.dispose();
System.exit(0);
}
public static void main(String[] args) throws Exception {
SimpleShadows cd = new SimpleShadows();
cd.initStuff();
cd.setVisible(true);
cd.pack();
cd.setBounds(new Rectangle(640,480));
cd.doIt();
}
}
Thanks very much.