mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-11 11:27:16 +07:00
Implemented frame delta with time steps
This commit is contained in:
parent
ac5ec5f0d8
commit
3803abb02b
@ -35,6 +35,7 @@ public class BIK {
|
|||||||
final int width;
|
final int width;
|
||||||
final int height;
|
final int height;
|
||||||
final float fps;
|
final float fps;
|
||||||
|
final float delta;
|
||||||
final int flags;
|
final int flags;
|
||||||
final int numTracks;
|
final int numTracks;
|
||||||
final BinkAudio[] tracks;
|
final BinkAudio[] tracks;
|
||||||
@ -96,7 +97,8 @@ public class BIK {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fps = (float) fpsDividend / fpsDivisor;
|
fps = (float) fpsDividend / fpsDivisor;
|
||||||
log.trace("fps: {} fps", fps);
|
delta = 1 / fps;
|
||||||
|
log.trace("fps: {} fps ({}s)", fps, delta);
|
||||||
|
|
||||||
flags = in.read32();
|
flags = in.read32();
|
||||||
if (log.traceEnabled()) log.tracef("flags: 0x%08x (%s)", flags, getFlagsString());
|
if (log.traceEnabled()) log.tracef("flags: 0x%08x (%s)", flags, getFlagsString());
|
||||||
|
@ -9,6 +9,8 @@ public class VideoPlayer implements Disposable {
|
|||||||
private BIK bik;
|
private BIK bik;
|
||||||
private AudioDevice[] audio;
|
private AudioDevice[] audio;
|
||||||
private float[][][] out;
|
private float[][][] out;
|
||||||
|
private int frame;
|
||||||
|
private float time, nextFrame;
|
||||||
|
|
||||||
public VideoPlayer() {
|
public VideoPlayer() {
|
||||||
|
|
||||||
@ -35,9 +37,12 @@ public class VideoPlayer implements Disposable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int f = 0;
|
|
||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
bik.decode(f++, audio, out[0]);
|
time += delta;
|
||||||
|
if (time > nextFrame) {
|
||||||
|
nextFrame += bik.delta;
|
||||||
|
bik.decode(frame++, audio, out[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Batch batch) {
|
public void draw(Batch batch) {
|
||||||
|
@ -10,6 +10,9 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
|||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
|
||||||
|
import com.riiablo.logger.Level;
|
||||||
|
import com.riiablo.logger.LogManager;
|
||||||
|
|
||||||
public class VideoTool extends ApplicationAdapter {
|
public class VideoTool extends ApplicationAdapter {
|
||||||
private static final String TAG = "VideoTool";
|
private static final String TAG = "VideoTool";
|
||||||
|
|
||||||
@ -30,6 +33,8 @@ public class VideoTool extends ApplicationAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
LogManager.setLevel("com.riiablo.video", Level.TRACE);
|
||||||
|
|
||||||
Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
|
Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user