onRender()'s 'delta' param renamed to better reflect its purpose

This commit is contained in:
Gered 2013-12-30 15:46:12 -05:00
parent 8def4a12d6
commit 216ee98acc
14 changed files with 29 additions and 33 deletions

View file

@ -60,12 +60,12 @@ public abstract class GameApp implements Disposable {
viewportContext.onResize(width, height); viewportContext.onResize(width, height);
} }
public void onRender(float delta) { public void onRender(float interpolation) {
viewportContext.onPreRender(); viewportContext.onPreRender();
spriteBatch.setProjectionMatrix(viewportContext.getOrthographicCamera().combined); spriteBatch.setProjectionMatrix(viewportContext.getOrthographicCamera().combined);
spriteBatch.setPixelScale(viewportContext.pixelScaler.getScale()); spriteBatch.setPixelScale(viewportContext.pixelScaler.getScale());
stateManager.onRender(delta); stateManager.onRender(interpolation);
viewportContext.onPostRender(); viewportContext.onPostRender();
} }

View file

@ -6,5 +6,5 @@ public interface GameLooper {
int getUpdateFrequency(); int getUpdateFrequency();
float getUpdateDelta(); float getUpdateDelta();
float getRenderDelta(); float getRenderInterpolation();
} }

View file

@ -8,10 +8,10 @@ public class GdxGameAppListener implements ApplicationListener, GameLooper {
int updateFrequency; int updateFrequency;
float maxFrameTime; float maxFrameTime;
float accumulator; float accumulator = 0.0f;
float updateDelta = 0.0f; float updateDelta = 0.0f;
float renderDelta = 0.0f; float renderInterpolation = 0.0f;
Class<? extends GameApp> gameAppType; Class<? extends GameApp> gameAppType;
GameApp gameApp; GameApp gameApp;
@ -65,10 +65,10 @@ public class GdxGameAppListener implements ApplicationListener, GameLooper {
accumulator -= updateDelta; accumulator -= updateDelta;
} }
renderDelta = accumulator / updateDelta; renderInterpolation = accumulator / updateDelta;
gameApp.onUpdateFrame(frameTime); gameApp.onUpdateFrame(frameTime);
gameApp.onRender(renderDelta); gameApp.onRender(renderInterpolation);
} }
@Override @Override
@ -109,7 +109,7 @@ public class GdxGameAppListener implements ApplicationListener, GameLooper {
} }
@Override @Override
public float getRenderDelta() { public float getRenderInterpolation() {
return renderDelta; return renderInterpolation;
} }
} }

View file

@ -25,7 +25,7 @@ public abstract class ComponentSystem extends EventHandler implements Disposable
public void onResize() { public void onResize() {
} }
public void onRender(float delta) { public void onRender(float interpolation) {
} }
public void onUpdateGameState(float delta) { public void onUpdateGameState(float delta) {

View file

@ -307,9 +307,9 @@ public class EntityManager implements Disposable {
componentSystems.get(i).onResize(); componentSystems.get(i).onResize();
} }
public void onRender(float delta) { public void onRender(float interpolation) {
for (int i = 0; i < componentSystems.size; ++i) for (int i = 0; i < componentSystems.size; ++i)
componentSystems.get(i).onRender(delta); componentSystems.get(i).onRender(interpolation);
} }
public void onUpdateGameState(float delta) { public void onUpdateGameState(float delta) {

View file

@ -6,10 +6,6 @@ import ca.blarg.gdx.graphics.SolidColorTextureCache;
import ca.blarg.gdx.graphics.ViewportContext; import ca.blarg.gdx.graphics.ViewportContext;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import ca.blarg.gdx.Services;
import ca.blarg.gdx.graphics.ExtendedSpriteBatch;
import ca.blarg.gdx.graphics.SolidColorTextureCache;
import ca.blarg.gdx.graphics.ViewportContext;
public class DimScreenEffect extends ScreenEffect public class DimScreenEffect extends ScreenEffect
{ {
@ -38,7 +34,7 @@ public class DimScreenEffect extends ScreenEffect
} }
@Override @Override
public void onRender(float delta) public void onRender(float interpolation)
{ {
renderColor.set(color); renderColor.set(color);
renderColor.a = alpha; renderColor.a = alpha;

View file

@ -65,7 +65,7 @@ public class FadeScreenEffect extends ScreenEffect
} }
@Override @Override
public void onRender(float delta) public void onRender(float interpolation)
{ {
Texture texture = solidColorTextures.get(Color.WHITE); Texture texture = solidColorTextures.get(Color.WHITE);
color.a = alpha; color.a = alpha;

View file

@ -41,7 +41,7 @@ public class FlashScreenEffect extends ScreenEffect
} }
@Override @Override
public void onRender(float delta) public void onRender(float interpolation)
{ {
Texture texture = solidColorTextures.get(Color.WHITE); Texture texture = solidColorTextures.get(Color.WHITE);
color.a = alpha; color.a = alpha;

View file

@ -25,7 +25,7 @@ public abstract class ScreenEffect implements Disposable
public void onResize() { public void onResize() {
} }
public void onRender(float delta) { public void onRender(float interpolation) {
} }
public void onUpdateGameState(float delta) { public void onUpdateGameState(float delta) {

View file

@ -103,25 +103,25 @@ public class ScreenEffectManager implements Disposable
effects.get(i).effect.onResize(); effects.get(i).effect.onResize();
} }
public void onRenderLocal(float delta) { public void onRenderLocal(float interpolation) {
if (numLocalEffects == 0) if (numLocalEffects == 0)
return; return;
for (int i = 0; i < effects.size(); ++i) { for (int i = 0; i < effects.size(); ++i) {
EffectInfo effectInfo = effects.get(i); EffectInfo effectInfo = effects.get(i);
if (effectInfo.isLocal) if (effectInfo.isLocal)
effectInfo.effect.onRender(delta); effectInfo.effect.onRender(interpolation);
} }
} }
public void onRenderGlobal(float delta) { public void onRenderGlobal(float interpolation) {
if (numGlobalEffects == 0) if (numGlobalEffects == 0)
return; return;
for (int i = 0; i < effects.size(); ++i) { for (int i = 0; i < effects.size(); ++i) {
EffectInfo effectInfo = effects.get(i); EffectInfo effectInfo = effects.get(i);
if (!effectInfo.isLocal) if (!effectInfo.isLocal)
effectInfo.effect.onRender(delta); effectInfo.effect.onRender(interpolation);
} }
} }

View file

@ -54,7 +54,7 @@ public abstract class GameProcess extends EventHandler implements Disposable {
public void onResize() { public void onResize() {
} }
public void onRender(float delta) { public void onRender(float interpolation) {
} }
public void onUpdateGameState(float delta) { public void onUpdateGameState(float delta) {

View file

@ -188,11 +188,11 @@ public class ProcessManager implements Disposable {
} }
} }
public void onRender(float delta) { public void onRender(float interpolation) {
for (int i = 0; i < processes.size(); ++i) { for (int i = 0; i < processes.size(); ++i) {
ProcessInfo processInfo = processes.get(i); ProcessInfo processInfo = processes.get(i);
if (!processInfo.isInactive) if (!processInfo.isInactive)
processInfo.process.onRender(delta); processInfo.process.onRender(interpolation);
} }
} }

View file

@ -79,12 +79,12 @@ public abstract class GameState extends EventHandler implements Disposable {
effectManager.onResize(); effectManager.onResize();
} }
public void onRender(float delta) { public void onRender(float interpolation) {
// switch it up and do effects before processes here so that processes // switch it up and do effects before processes here so that processes
// (which would commonly be used for UI overlay elements) don't get // (which would commonly be used for UI overlay elements) don't get
// overwritten by local effects (e.g. flashes, etc.) // overwritten by local effects (e.g. flashes, etc.)
effectManager.onRenderLocal(delta); effectManager.onRenderLocal(interpolation);
processManager.onRender(delta); processManager.onRender(interpolation);
} }
public void onUpdateGameState(float delta) { public void onUpdateGameState(float delta) {

View file

@ -253,12 +253,12 @@ public class StateManager implements Disposable {
} }
} }
public void onRender(float delta) { public void onRender(float interpolation) {
for (int i = getTopNonOverlayIndex(); i != -1 && i < states.size(); ++i) { for (int i = getTopNonOverlayIndex(); i != -1 && i < states.size(); ++i) {
StateInfo stateInfo = states.get(i); StateInfo stateInfo = states.get(i);
if (!stateInfo.isInactive) { if (!stateInfo.isInactive) {
stateInfo.state.onRender(delta); stateInfo.state.onRender(interpolation);
stateInfo.state.effectManager.onRenderGlobal(delta); stateInfo.state.effectManager.onRenderGlobal(interpolation);
} }
} }
} }