Bei JOGL hat man ja den Animator... der die Display() Funktion schön regelmässig aufruft (Thread).
Nun bin ich dabei mit LWJGL auch eine smooth Objektschieberei zu realisieren. Ich arbeite bei JOGL und LWJGL mit der üblichen TICK Variable um bei verschiedenen FPS Zeiten eine konstante Move-Geschwindigkeit der Objekte zu erreichen. Ich habe VSync an (60 Hz), meine Routine rennt unter LWJGL/JOGL ungebremst (ohne Thread), hat 11 Objekte auf dem Screen (1 davon bewegt sich) und es ruckelt
Den selben Code benutze ich bei JOGL... alles smoth
Hat jemand eine Idee für ein stückchen Code für eine smoothe Anmation?
Hier is meine TICK/FPS Routine (benutze ich auch bei JOGL):
Tick-Zeit bei JOGL: 0.015-0.017 (sehr konstant)
Tick-Zeit bei LWJGL: 0.016-0.035 (schwankt extrem, deshalb auch wohl die Ruckler)
[Java]
// ***********************
// ***********************
// *** **
// *** Tick **
// *** **
// ***********************
// ***********************
private static boolean logFPS = false;
// Variables used to calculate fps
private static long fps = 0;
private static long frames = 0;
private static long timeCounter = 0;
private static long timeNow = System.currentTimeMillis();
private static long oldTime = System.currentTimeMillis();
private static long ticktimeNow = System.nanoTime();
private static long tickoldTime = System.nanoTime();
private static float lastFrameTime = 0;
// Measure time elapsed since last frame renderer
// This is the heart variable of the engine
protected static float RENDER_TICK = 0; //(tick)
protected static void frameTimerInit(boolean log) {
logFPS = log;
frameTimeUpdate();
}
protected static void frameTimeUpdate() {
frames++;
timeNow = System.currentTimeMillis();
lastFrameTime = timeNow - oldTime;
ticktimeNow = System.nanoTime();
RENDER_TICK = (float)(ticktimeNow - tickoldTime)/1000000000; // (tick)
//System.out.println(RENDER_TICK); // 0.015 ist fluessige Animation (JOGL), ab > 0.02 ist ruckelig (LWJGL)!
oldTime = timeNow;
tickoldTime = ticktimeNow;
countFPS();
}
private static void countFPS() {
timeCounter += lastFrameTime;
if(timeCounter >= 1000) {
if(logFPS) Log.i("EngineLoop","FPS "+fps+" " +" - Entitys: " + boxesOnScreen);
fps = frames;
frames = 0;
timeCounter = 0;
}
}
[/Java]
Nun bin ich dabei mit LWJGL auch eine smooth Objektschieberei zu realisieren. Ich arbeite bei JOGL und LWJGL mit der üblichen TICK Variable um bei verschiedenen FPS Zeiten eine konstante Move-Geschwindigkeit der Objekte zu erreichen. Ich habe VSync an (60 Hz), meine Routine rennt unter LWJGL/JOGL ungebremst (ohne Thread), hat 11 Objekte auf dem Screen (1 davon bewegt sich) und es ruckelt
Den selben Code benutze ich bei JOGL... alles smoth
Hat jemand eine Idee für ein stückchen Code für eine smoothe Anmation?
Hier is meine TICK/FPS Routine (benutze ich auch bei JOGL):
Tick-Zeit bei JOGL: 0.015-0.017 (sehr konstant)
Tick-Zeit bei LWJGL: 0.016-0.035 (schwankt extrem, deshalb auch wohl die Ruckler)
[Java]
// ***********************
// ***********************
// *** **
// *** Tick **
// *** **
// ***********************
// ***********************
private static boolean logFPS = false;
// Variables used to calculate fps
private static long fps = 0;
private static long frames = 0;
private static long timeCounter = 0;
private static long timeNow = System.currentTimeMillis();
private static long oldTime = System.currentTimeMillis();
private static long ticktimeNow = System.nanoTime();
private static long tickoldTime = System.nanoTime();
private static float lastFrameTime = 0;
// Measure time elapsed since last frame renderer
// This is the heart variable of the engine
protected static float RENDER_TICK = 0; //(tick)
protected static void frameTimerInit(boolean log) {
logFPS = log;
frameTimeUpdate();
}
protected static void frameTimeUpdate() {
frames++;
timeNow = System.currentTimeMillis();
lastFrameTime = timeNow - oldTime;
ticktimeNow = System.nanoTime();
RENDER_TICK = (float)(ticktimeNow - tickoldTime)/1000000000; // (tick)
//System.out.println(RENDER_TICK); // 0.015 ist fluessige Animation (JOGL), ab > 0.02 ist ruckelig (LWJGL)!
oldTime = timeNow;
tickoldTime = ticktimeNow;
countFPS();
}
private static void countFPS() {
timeCounter += lastFrameTime;
if(timeCounter >= 1000) {
if(logFPS) Log.i("EngineLoop","FPS "+fps+" " +" - Entitys: " + boxesOnScreen);
fps = frames;
frames = 0;
timeCounter = 0;
}
}
[/Java]
Zuletzt bearbeitet: