GL only. The latest hardware attempt was single-threaded. It still crashes. It's very weird because I've had a lot of success with the hardware renderer in the past, and I can't see anything wrong with this code. All ENTER is doing in this version is flipping gameOn.
private void draw() {
// buffer.clearZBufferOnly();
buffer.clear(Color.black);
xWing.rotateAxis(xWing.getXAxis(), rotationStored.x);
xWing.rotateAxis(xWing.getYAxis(), rotationStored.y);
xWing.rotateAxis(xWing.getZAxis(), rotationStored.z);
if (!cameraOnTie)
follow();
rotationStored.x = 0;
rotationStored.y = 0;
rotationStored.z = 0;
buffer.update();
theWorld.renderScene(buffer);
theWorld.draw(buffer);
drawAxisRep();
if (!openGL)
buffer.display(this.getGraphics());
else buffer.displayGLOnly();
}
public static void main(String[] args) {
boolean hardware = false;
if (args != null && args.length > 0) {
if (args[0].equalsIgnoreCase("OpenGL"))
hardware = true;
}
RogueSquadron instance = new RogueSquadron(hardware);
if (instance.openGL) {
instance.buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
try {
Keyboard.create();
}
catch (Exception e) {System.out.println("Keyboard failed: "+e.getMessage());}
glLoop(instance);
Keyboard.destroy();
instance.buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
instance.buffer.dispose();
}
}
private static void glLoop(RogueSquadron instance) {
int keyCode;
instance.buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
instance.buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
instance.draw();
while (!Display.isCloseRequested()) {
keyCode = Keyboard.getEventKey();
instance.keyPressed(keyCode);
if (instance.gameOn) {
instance.moveTowards(instance.xWing, instance.targetCone.getTransformedCenter(), .01f);
instance.follow();
if (instance.wingsHaveChanged)
instance.changeWings();
try {
Thread.sleep(50);
}
catch (InterruptedException e) {}
}
}
instance.gameOn = false;
}