semi added guis

pull/12/head
hYdos 2020-02-26 07:49:52 +10:00
parent b51274b5c2
commit 47acf509aa
4 changed files with 54 additions and 11 deletions

View File

@ -0,0 +1,37 @@
package com.github.halotroop.litecraft.screens;
import java.util.*;
import com.github.hydos.ginger.engine.api.GingerRegister;
import com.github.hydos.ginger.engine.elements.GuiTexture;
import com.github.hydos.ginger.engine.screen.Screen;
/*
* YeS
*/
public class TitleScreen extends Screen
{
List<GuiTexture> elements;
public TitleScreen()
{
elements = new ArrayList<GuiTexture>();
//TODO: move over main menu ui elements from main class to here
}
@Override
public void render()
{
GingerRegister.getInstance().masterRenderer.renderGuis(elements);
}
@Override
public void tick()
{
}
}

View File

@ -58,7 +58,7 @@ public class Litecraft extends Game
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
ginger3D.setGlobalFont(font);
GUIText titleText = ginger3D.registerText("LiteCraft PRE-ALPHA build 1", 3, new Vector2f(0, 0), 1f, true, "PLAYBUTTON");
GUIText titleText = ginger3D.registerText("LiteCraft build 1", 3, new Vector2f(0, 0), 1f, true, "PLAYBUTTON");
titleText.setBorderWidth(0.5f);
Light sun = new Light(new Vector3f(100, 105, -100), new Vector3f(1.3f, 1.3f, 1.3f), new Vector3f(0.0001f, 0.0001f, 0.0001f));
@ -88,7 +88,7 @@ public class Litecraft extends Game
}
oldWindowWidth = Window.width;
oldWindowHeight = Window.height;
ginger3D.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
ginger3D.gingerRegister.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
if (isInWorld)
{ ginger3D.renderWithoutTerrain(this, world); }
ginger3D.renderOverlays(this);

View File

@ -17,7 +17,6 @@ import com.github.hydos.ginger.engine.utils.Loader;
public class Ginger
{
public MasterRenderer masterRenderer;
public GingerRegister gingerRegister;
public MousePicker picker;
public FontType globalFont;
@ -35,14 +34,14 @@ public class Ginger
Window.stop();
PostProcessing.cleanUp();
ParticleMaster.cleanUp();
masterRenderer.cleanUp();
gingerRegister.masterRenderer.cleanUp();
TextMaster.cleanUp();
Loader.cleanUp();
}
public void openScreen(Screen screen)
{
gingerRegister.currentScreen = screen;
}
public void postRender()
@ -65,27 +64,30 @@ public class Ginger
public void render(Game game)
{
GingerUtils.preRenderScene(masterRenderer);
GingerUtils.preRenderScene(gingerRegister.masterRenderer);
contrastFbo.bindFBO();
masterRenderer.renderScene(game.data.entities, game.data.normalMapEntities, game.data.flatTerrains, game.data.lights, game.data.camera, game.data.clippingPlane);
gingerRegister.masterRenderer.renderScene(game.data.entities, game.data.normalMapEntities, game.data.flatTerrains, game.data.lights, game.data.camera, game.data.clippingPlane);
ParticleMaster.renderParticles(game.data.camera);
contrastFbo.unbindFBO();
contrastFbo.handler.render(contrastFbo.colorTexture);
if (game.data.handleGuis)
{ renderOverlays(game); }
if(gingerRegister.currentScreen != null) {
gingerRegister.currentScreen.render();
}
}
public void renderOverlays(Game game)
{
masterRenderer.renderGuis(game.data.guis);
gingerRegister.masterRenderer.renderGuis(game.data.guis);
TextMaster.render();
}
public void renderWithoutTerrain(Game game, World world)
{
GingerUtils.preRenderScene(masterRenderer);
GingerUtils.preRenderScene(gingerRegister.masterRenderer);
contrastFbo.bindFBO();
masterRenderer.renderSceneNoTerrain(game.data.entities, game.data.normalMapEntities, game.data.lights, game.data.camera, game.data.clippingPlane, world);
gingerRegister.masterRenderer.renderSceneNoTerrain(game.data.entities, game.data.normalMapEntities, game.data.lights, game.data.camera, game.data.clippingPlane, world);
ParticleMaster.renderParticles(game.data.camera);
contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
@ -103,7 +105,7 @@ public class Ginger
timer = new Timer(game.data.tickSpeed);
timer.addTickListener(gameTickListener);
contrastFbo = new Fbo(new ContrastChanger());
this.masterRenderer = masterRenderer;
gingerRegister.masterRenderer = masterRenderer;
picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix(), null);
PostProcessing.init();
ParticleMaster.init(masterRenderer.getProjectionMatrix());

View File

@ -6,11 +6,14 @@ import com.github.hydos.ginger.engine.api.game.Game;
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.font.GUIText;
import com.github.hydos.ginger.engine.postprocessing.Fbo;
import com.github.hydos.ginger.engine.render.MasterRenderer;
import com.github.hydos.ginger.engine.screen.Screen;
/** Used if a game wants to access engine variables safely */
public class GingerRegister
{
private static GingerRegister INSTANCE;
public MasterRenderer masterRenderer;
public static GingerRegister getInstance()
{ return INSTANCE; }
public List<GUIText> texts;
@ -18,6 +21,7 @@ public class GingerRegister
public List<Fbo> fbos;
public Game game;
public Screen currentScreen;
public GingerRegister()
{ INSTANCE = this; }