Added a newFrame() method to UniformBindingManager
to signal the beginning of a frame. Currently this just grabs the time and tpf values once so as to avoid per-material Float allocation and time drift within a frame. RenderManager now calls this at the beginning of the root-level render() method.
This commit is contained in:
parent
852ae28605
commit
c0465b73a8
@ -1035,6 +1035,7 @@ public class RenderManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.shader = renderer.getCaps().contains(Caps.GLSL100);
|
this.shader = renderer.getCaps().contains(Caps.GLSL100);
|
||||||
|
uniformBindingManager.newFrame();
|
||||||
|
|
||||||
for (int i = 0; i < preViewPorts.size(); i++) {
|
for (int i = 0; i < preViewPorts.size(); i++) {
|
||||||
ViewPort vp = preViewPorts.get(i);
|
ViewPort vp = preViewPorts.get(i);
|
||||||
|
@ -51,7 +51,8 @@ import java.util.List;
|
|||||||
public class UniformBindingManager {
|
public class UniformBindingManager {
|
||||||
|
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private float near, far;
|
private Float near, far;
|
||||||
|
private Float time, tpf;
|
||||||
private int viewX, viewY, viewWidth, viewHeight;
|
private int viewX, viewY, viewWidth, viewHeight;
|
||||||
private Vector3f camUp = new Vector3f(),
|
private Vector3f camUp = new Vector3f(),
|
||||||
camLeft = new Vector3f(),
|
camLeft = new Vector3f(),
|
||||||
@ -196,10 +197,10 @@ public class UniformBindingManager {
|
|||||||
u.setValue(VarType.Vector3, camUp);
|
u.setValue(VarType.Vector3, camUp);
|
||||||
break;
|
break;
|
||||||
case Time:
|
case Time:
|
||||||
u.setValue(VarType.Float, timer.getTimeInSeconds());
|
u.setValue(VarType.Float, time);
|
||||||
break;
|
break;
|
||||||
case Tpf:
|
case Tpf:
|
||||||
u.setValue(VarType.Float, timer.getTimePerFrame());
|
u.setValue(VarType.Float, tpf);
|
||||||
break;
|
break;
|
||||||
case FrameRate:
|
case FrameRate:
|
||||||
u.setValue(VarType.Float, timer.getFrameRate());
|
u.setValue(VarType.Float, timer.getFrameRate());
|
||||||
@ -251,4 +252,15 @@ public class UniformBindingManager {
|
|||||||
this.viewWidth = viewWidth;
|
this.viewWidth = viewWidth;
|
||||||
this.viewHeight = viewHeight;
|
this.viewHeight = viewHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only. Called by the RenderManager at the beginning of a
|
||||||
|
* new application frame.
|
||||||
|
*/
|
||||||
|
public void newFrame() {
|
||||||
|
// Avoid per-material Float allocations and lock in the
|
||||||
|
// time for this frame to avoid inter-frame drift.
|
||||||
|
time = timer.getTimeInSeconds();
|
||||||
|
tpf = timer.getTimePerFrame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user