1591
News / Re: LWJGL 2.0 is out!
« on: October 29, 2008, 12:09:20 am »
Or the lack of a Keyboard.next() check, or both, FYI.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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;
}
public float calculateAngle(SimpleVector s1, SimpleVector s2) {
s1=s1.normalize();//TRIED WITH AND WITHOUT THESE
s2=s2.normalize();
SimpleVector p13d = Interact2D.project3D2D(theCamera, buffer, s1);
Point p1 = new Point((int)p13d.x, (int)p13d.y);
SimpleVector p23d = Interact2D.project3D2D(theCamera, buffer, s2);
Point p2 = new Point((int)p23d.x, (int)p23d.y);
float pa=(float)p1.x*(float)p2.x+(float)p1.y*(float)p2.y;
// Inaccuracies may cause NaN...fix this:
if (pa<-1)
pa=-1;
else if (pa>1)
pa=1;
return (float) Math.acos(pa);
}