fix merge
commit
d01aebc4b5
|
@ -2,6 +2,7 @@ package com.github.halotroop.litecraft;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import org.joml.Vector4i;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.github.halotroop.litecraft.save.LitecraftSave;
|
||||
|
@ -31,19 +32,17 @@ public class Litecraft extends Game
|
|||
private LitecraftSave save;
|
||||
private Ginger ginger3D;
|
||||
private static Litecraft INSTANCE;
|
||||
|
||||
//temp stuff to test out fbo fixes
|
||||
int oldWindowWidth = Window.width;
|
||||
int oldWindowHeight = Window.height;
|
||||
|
||||
public int realFPS = 0;
|
||||
|
||||
private int fps, ups, tps;
|
||||
public int fps, ups, tps, binds;
|
||||
public Vector4i dbgStats;
|
||||
private long frameTimer;
|
||||
|
||||
public Litecraft()
|
||||
{
|
||||
INSTANCE = this;
|
||||
Litecraft.INSTANCE = this;
|
||||
dbgStats = new Vector4i();
|
||||
Constants.movementSpeed = 0.5f;
|
||||
Constants.turnSpeed = 0.00006f;
|
||||
Constants.gravity = new org.joml.Vector3f(0, -0.0000000005f, 0);
|
||||
|
@ -51,7 +50,6 @@ public class Litecraft extends Game
|
|||
Window.create(1200, 800, "LiteCraft", 60);
|
||||
KeyCallbackHandler.trackWindow(Window.window);
|
||||
MouseCallbackHandler.trackWindow(Window.window);
|
||||
|
||||
setupKeybinds();
|
||||
|
||||
Block b = Blocks.AIR; // make sure blocks are initialised
|
||||
|
@ -61,35 +59,26 @@ public class Litecraft extends Game
|
|||
TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png");
|
||||
StaticCube.scaleCube(1f);
|
||||
Player player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
|
||||
|
||||
Camera camera = new FirstPersonCamera(player);
|
||||
|
||||
player.isVisible = false;
|
||||
ginger3D = new Ginger();
|
||||
data = new GameData(player, camera, 20);
|
||||
data.handleGuis = false;
|
||||
ginger3D.setup(new MasterRenderer(camera), this);
|
||||
|
||||
ginger3D.setup(new MasterRenderer(camera), INSTANCE);
|
||||
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
|
||||
ginger3D.setGlobalFont(font);
|
||||
|
||||
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));
|
||||
data.lights.add(sun);
|
||||
data.entities.add(player);
|
||||
|
||||
oldWindowWidth = Window.width;
|
||||
oldWindowHeight = Window.height;
|
||||
|
||||
frameTimer = System.currentTimeMillis();
|
||||
|
||||
//start the game loop
|
||||
ginger3D.startGame();
|
||||
}
|
||||
|
||||
private void setupKeybinds()
|
||||
{
|
||||
Input.addPressCallback(Keybind.EXIT, this::exit);
|
||||
}
|
||||
{ Input.addPressCallback(Keybind.EXIT, this::exit); }
|
||||
|
||||
@Override
|
||||
public void exit()
|
||||
|
@ -102,34 +91,30 @@ public class Litecraft extends Game
|
|||
@Override
|
||||
public void render()
|
||||
{
|
||||
ups++;
|
||||
fps++;
|
||||
//FPS stuff sorry if i forget to remove whitespace
|
||||
if (System.currentTimeMillis() > frameTimer + 1000) // wait for one second
|
||||
{
|
||||
realFPS = fps;
|
||||
fps = 0;
|
||||
ups = 0;
|
||||
tps = 0;
|
||||
frameTimer += 1000; // reset the wait time
|
||||
this.dbgStats.set(fps, ups, tps, 0);
|
||||
this.fps = 0;
|
||||
this.ups = 0;
|
||||
this.tps = 0;
|
||||
this.frameTimer += 1000; // reset the wait time
|
||||
}
|
||||
|
||||
|
||||
if(ginger3D.gingerRegister.currentScreen == null) {
|
||||
if (ginger3D.gingerRegister.currentScreen == null)
|
||||
ginger3D.openScreen(new TitleScreen());
|
||||
}
|
||||
ginger3D.update(data);
|
||||
if (oldWindowHeight != Window.height || oldWindowWidth != Window.width)
|
||||
{
|
||||
ginger3D.contrastFbo.resizeFBOs();
|
||||
}
|
||||
oldWindowWidth = Window.width;
|
||||
oldWindowHeight = Window.height;
|
||||
ginger3D.gingerRegister.masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
|
||||
if (this.world != null)
|
||||
{ ginger3D.renderWorld(this, this.world); }
|
||||
ginger3D.renderWorld(this, this.world);
|
||||
ginger3D.renderOverlays(this);
|
||||
ginger3D.postRender();
|
||||
dbgStats.w = binds;
|
||||
this.binds = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,18 +123,15 @@ public class Litecraft extends Game
|
|||
Input.invokeAllListeners();
|
||||
data.player.updateMovement();
|
||||
tps++;
|
||||
|
||||
if(Window.isKeyDown(GLFW.GLFW_KEY_TAB)) {
|
||||
if (Window.isKeyDown(GLFW.GLFW_KEY_TAB))
|
||||
ginger3D.gingerRegister.wireframe = !ginger3D.gingerRegister.wireframe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Litecraft getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
public static Litecraft getInstance()
|
||||
{ return INSTANCE; }
|
||||
|
||||
public void onPlayButtonClick() {
|
||||
public void onPlayButtonClick()
|
||||
{
|
||||
if (world == null)
|
||||
{
|
||||
this.save = new LitecraftSave("test", false);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package com.github.halotroop.litecraft.screens;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.joml.Vector4i;
|
||||
|
||||
import com.github.halotroop.litecraft.Litecraft;
|
||||
import com.github.hydos.ginger.engine.api.*;
|
||||
import com.github.hydos.ginger.engine.api.Ginger;
|
||||
import com.github.hydos.ginger.engine.elements.GuiTexture;
|
||||
import com.github.hydos.ginger.engine.elements.buttons.TextureButton;
|
||||
import com.github.hydos.ginger.engine.font.*;
|
||||
import com.github.hydos.ginger.engine.font.GUIText;
|
||||
import com.github.hydos.ginger.engine.io.Window;
|
||||
import com.github.hydos.ginger.engine.math.vectors.Vector2f;
|
||||
import com.github.hydos.ginger.engine.screen.Screen;
|
||||
|
@ -33,15 +35,17 @@ public class TitleScreen extends Screen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render()
|
||||
public void render() // FIXME: This never gets called!!!
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
Vector4i dbg = Litecraft.getInstance().dbgStats;
|
||||
buildText.setText("FPS: "+dbg.x()+" UPS: "+dbg.y+" TPS: "+dbg.z+" Binds: "+dbg.w);
|
||||
playButton.update();
|
||||
buildText.setText("Fps: " + Litecraft.getInstance().realFPS);
|
||||
if (playButton.isClicked())
|
||||
{
|
||||
Window.lockMouse();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.github.halotroop.litecraft.types.block;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.github.halotroop.litecraft.world.Chunk;
|
||||
import com.github.hydos.ginger.engine.elements.objects.RenderObject;
|
||||
import com.github.hydos.ginger.engine.math.vectors.Vector3f;
|
||||
|
|
|
@ -4,13 +4,14 @@ import java.util.*;
|
|||
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import com.github.halotroop.litecraft.Litecraft;
|
||||
import com.github.halotroop.litecraft.types.block.BlockEntity;
|
||||
import com.github.hydos.ginger.engine.api.GingerRegister;
|
||||
import com.github.hydos.ginger.engine.elements.objects.RenderObject;
|
||||
import com.github.hydos.ginger.engine.io.Window;
|
||||
import com.github.hydos.ginger.engine.math.Maths;
|
||||
import com.github.hydos.ginger.engine.math.matrixes.Matrix4f;
|
||||
import com.github.hydos.ginger.engine.render.*;
|
||||
import com.github.hydos.ginger.engine.render.Renderer;
|
||||
import com.github.hydos.ginger.engine.render.models.*;
|
||||
import com.github.hydos.ginger.engine.render.shaders.StaticShader;
|
||||
import com.github.hydos.ginger.engine.render.texture.ModelTexture;
|
||||
|
@ -40,6 +41,7 @@ public class BlockRenderer extends Renderer
|
|||
GL20.glEnableVertexAttribArray(0);
|
||||
GL20.glEnableVertexAttribArray(1);
|
||||
GL20.glEnableVertexAttribArray(2);
|
||||
Litecraft.getInstance().binds++;
|
||||
}
|
||||
|
||||
private void prepTexture(ModelTexture texture, int textureID) {
|
||||
|
@ -90,6 +92,7 @@ public class BlockRenderer extends Renderer
|
|||
{
|
||||
if (entity != null && entity.getModel() != null) {
|
||||
prepTexture(entity.getModel().getTexture(), entity.getModel().getTexture().getTextureID());
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
prepBlockInstance(entity);
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.hydos.ginger.engine.api;
|
||||
|
||||
import com.github.halotroop.litecraft.Litecraft;
|
||||
import com.github.halotroop.litecraft.logic.Timer;
|
||||
import com.github.halotroop.litecraft.logic.Timer.TickListener;
|
||||
import com.github.halotroop.litecraft.world.World;
|
||||
|
@ -112,12 +113,14 @@ public class Ginger
|
|||
{
|
||||
while (!Window.closed())
|
||||
{
|
||||
Litecraft.getInstance().ups++;
|
||||
if (Window.isUpdating())
|
||||
{
|
||||
timer.tick();
|
||||
gingerRegister.game.render();
|
||||
}
|
||||
}
|
||||
Litecraft.getInstance().exit();
|
||||
}
|
||||
|
||||
public void update(GameData data)
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.github.hydos.ginger.engine.font;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import com.github.hydos.ginger.engine.api.*;
|
||||
import com.github.hydos.ginger.engine.api.Ginger;
|
||||
import com.github.hydos.ginger.engine.render.renderers.FontRenderer;
|
||||
import com.github.hydos.ginger.engine.utils.Loader;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import static org.lwjgl.system.MemoryStack.stackPush;
|
|||
import java.io.IOException;
|
||||
import java.nio.*;
|
||||
|
||||
import org.lwjgl.stb.STBImage;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import com.github.hydos.ginger.engine.render.tools.IOUtil;
|
||||
|
|
Loading…
Reference in New Issue