1
Support / JPCT Hello World
« on: June 11, 2006, 01:12:16 pm »
JPCT looks like just what I need, but I'm having trouble putting together a minimal sample to explore. The two sample programs go far beyond what I need and I'd rather start from a "Hello World" sample and build up. Can anyone point me to a simple example that shows just a primitive (eg. a box) using the software renderer?
Here's my code, which doesn't work:
All I get is a blank (yellow) screen.
What I want to see is a white box on a yellow background.
Any help appreciated. Thanks, Redstop.
Here's my code, which doesn't work:
Code: [Select]
// this is done once, just in case shapes must have a texture
// must they?
TextureManager tm = TextureManager.getInstance();
tm.addTexture("default", tm.getDummyTexture()); // should be white
// here's the paint:
public void paint(Graphics g)
{
Dimension sz = getSize();
World w = new World();
// just copied from the sample
w.getLights().setOverbrightLighting(
Lights.OVERBRIGHT_LIGHTING_DISABLED);
w.getLights().setRGBScale(Lights.RGB_SCALE_2X);
w.setAmbientLight(25, 30, 30);
// these just copied from the car example
// no idea if ambient light is sufficient
w.addLight(new SimpleVector(0, -150, 0), 25, 22, 19);
w.addLight(new SimpleVector(-1000, -150, 1000), 22, 5, 4);
w.addLight(new SimpleVector(1000, -150, -1000), 4, 2, 22);
Object3D box = Primitives.getBox(100, 100);
box.setOrigin(new SimpleVector(200,200,200));
box.setVisibility(true); // is this the default?
box.setTexture("default"); // will it take dummy texture otherwise?
w.addObject(box);
w.getCamera().lookAt(box.getOrigin());
FrameBuffer buffer=new FrameBuffer(sz.width, sz.height,
FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
// I found staring at an empty black screen
// after each attempt at getting this to work too depressing
buffer.clear(Color.yellow);
w.renderScene(buffer);
buffer.update();
buffer.display(g);
}
All I get is a blank (yellow) screen.
What I want to see is a white box on a yellow background.
Any help appreciated. Thanks, Redstop.