I am also having a problem with texturing. My cube is just showing up as one color instead of showing any texture.
Code Select
private World world;
private FrameBuffer buffer;
private Object3D box;
public static void main(String[] args) throws Exception {
new HelloWorld().loop();
}
public HelloWorld() throws Exception {
world = new World();
world.setAmbientLight(0, 255, 0);
TextureManager.getInstance().addTexture("box", new Texture("res/grass.png"));
box = Primitives.getBox(4f, 4f);
box.build();
box.setTexture("box");
world.addObject(box);
world.getCamera().setPosition(50, -50, -5);
world.getCamera().lookAt(box.getTransformedCenter());
}
private void loop() throws Exception {
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
while (!org.lwjgl.opengl.Display.isCloseRequested()) {
box.rotateY(0.01f);
buffer.clear(java.awt.Color.BLUE);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}