Render Overlays without asking for an instance of the game

liteCraft
Caroline Bell 2020-03-04 12:54:06 -08:00
parent 4969939fdc
commit 8d6220386f
4 changed files with 5 additions and 8 deletions

View File

@ -81,7 +81,7 @@ public class Litecraft extends Game
// If there's a world, render it!
if (this.world != null) renderWorld(this);
// Render any overlays (GUIs, HUDs)
this.engine.renderOverlays(this);
this.engine.renderOverlays();
// Put what's stored in the inactive framebuffer on the screen
Window.swapBuffers();
}
@ -104,7 +104,6 @@ public class Litecraft extends Game
((GingerGL)engine).getRegistry().masterRenderer.renderScene(data.entities, data.normalMapEntities, data.lights, data.camera, data.clippingPlane);
((GingerGL)engine).contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(((GingerGL)engine).contrastFbo.colorTexture);
if (data.handleGuis) ((GingerGL)engine).renderOverlays(game);
}
public void update()

View File

@ -1,6 +1,5 @@
package com.github.hydos.ginger.engine.common.api;
import com.github.hydos.ginger.engine.common.api.game.Game;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.screen.Screen;
import com.github.hydos.ginger.engine.common.util.Timer;
@ -50,5 +49,5 @@ public abstract class GingerEngine
public abstract void openScreen(Screen screen);
public abstract void renderOverlays(Game game);
public abstract void renderOverlays();
}

View File

@ -83,8 +83,7 @@ public class StaticCube
public static Mesh getCube()
{
if (mesh == null)
{ mesh = new Mesh(vertices, textureCoords, new float[vertices.length], indices, vertices.length); }
if (mesh == null) mesh = new Mesh(vertices, textureCoords, new float[vertices.length], indices, vertices.length);
return mesh;
}
}

View File

@ -60,9 +60,9 @@ public class GingerGL extends GingerEngine
return text;
}
public void renderOverlays(Game game)
public void renderOverlays()
{
getRegistry().masterRenderer.renderGuis(game.data.guis);
getRegistry().masterRenderer.renderGuis(getRegistry().game.data.guis);
if (getRegistry().currentScreen != null) getRegistry().masterRenderer.renderGuis(getRegistry().currentScreen.elements);
TextMaster.render();
}