most of the rendering refactors

pull/12/head
hayden v 2020-03-02 14:33:27 +10:00
parent efbe206fcd
commit 722240a435
69 changed files with 183 additions and 717 deletions

View File

@ -7,18 +7,19 @@ import com.github.halotroop.litecraft.screens.*;
import com.github.halotroop.litecraft.types.block.Blocks;
import com.github.halotroop.litecraft.util.RelativeDirection;
import com.github.halotroop.litecraft.world.World;
import com.github.hydos.ginger.engine.openGL.Constants;
import com.github.hydos.ginger.engine.common.Constants;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.api.game.*;
import com.github.hydos.ginger.engine.common.cameras.*;
import com.github.hydos.ginger.engine.common.elements.objects.*;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.openGL.api.*;
import com.github.hydos.ginger.engine.openGL.api.game.*;
import com.github.hydos.ginger.engine.openGL.cameras.*;
import com.github.hydos.ginger.engine.openGL.elements.objects.*;
import com.github.hydos.ginger.engine.openGL.font.FontType;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.obj.ModelLoader;
import com.github.hydos.ginger.engine.openGL.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
import tk.valoeghese.gateways.client.io.*;
@ -27,7 +28,7 @@ public class Litecraft extends Game
private static Litecraft INSTANCE;
private World world;
private LitecraftSave save;
private Ginger engine;
private GingerGL engine;
public Player player;
private Camera camera;
public int fps, ups, tps;
@ -119,8 +120,8 @@ public class Litecraft extends Game
TexturedModel playerModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/stonebrick.png");
StaticCube.scaleCube(1f);
Light sun = new Light(new Vector3f(0, 105, 0), new Vector3f(0.9765625f, 0.98828125f, 0.05859375f), new Vector3f(0.002f, 0.002f, 0.002f));
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
this.engine = new Ginger();
FontType font = new FontType(GlLoader.loadFontAtlas("candara.png"), "candara.fnt");
this.engine = new GingerGL();
this.player = new Player(playerModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f));
this.camera = new FirstPersonCamera(player);
this.player.setVisible(false);

View File

@ -8,8 +8,8 @@ import org.joml.Vector3f;
import com.github.halotroop.litecraft.Litecraft;
import com.github.halotroop.litecraft.world.*;
import com.github.halotroop.litecraft.world.dimension.Dimension;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.objects.Player;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.Player;
import tk.valoeghese.sod.*;

View File

@ -2,15 +2,15 @@ package com.github.halotroop.litecraft.screens;
import org.joml.*;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.api.*;
import com.github.hydos.ginger.engine.openGL.font.GUIText;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.screen.Screen;
public class ExitGameScreen extends Screen
{
private GUIText infoText;
private Ginger ginger3D = Ginger.getInstance();
private GingerGL ginger3D = GingerGL.getInstance();
public ExitGameScreen()
{

View File

@ -3,6 +3,7 @@ package com.github.halotroop.litecraft.screens;
import org.joml.*;
import com.github.halotroop.litecraft.Litecraft;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.openGL.api.*;
import com.github.hydos.ginger.engine.openGL.font.GUIText;
import com.github.hydos.ginger.engine.openGL.screen.Screen;
@ -11,7 +12,7 @@ public class IngameHUD extends Screen
{
private GUIText debugText;
private GUIText positionText;
private Ginger ginger3D = Ginger.getInstance();
private GingerGL ginger3D = GingerGL.getInstance();
private Litecraft litecraft = Litecraft.getInstance();
public IngameHUD()

View File

@ -7,11 +7,11 @@ import org.joml.*;
import com.github.halotroop.litecraft.Litecraft;
import com.github.halotroop.litecraft.save.LitecraftSave;
import com.github.halotroop.litecraft.world.dimension.Dimensions;
import com.github.hydos.ginger.engine.openGL.api.Ginger;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.openGL.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.api.GingerGL;
import com.github.hydos.ginger.engine.openGL.font.GUIText;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.screen.Screen;
/**
@ -20,7 +20,7 @@ import com.github.hydos.ginger.engine.openGL.screen.Screen;
public class TitleScreen extends Screen
{
private GUIText debugText;
private Ginger ginger3D = Ginger.getInstance();
private GingerGL ginger3D = GingerGL.getInstance();
private TextureButton playButton;
private Litecraft litecraft = Litecraft.getInstance();

View File

@ -2,7 +2,7 @@ package com.github.halotroop.litecraft.types.block;
import java.util.*;
import com.github.hydos.ginger.engine.openGL.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
public class Block

View File

@ -3,7 +3,7 @@ package com.github.halotroop.litecraft.types.block;
import org.joml.Vector3f;
import com.github.halotroop.litecraft.world.Chunk;
import com.github.hydos.ginger.engine.openGL.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
public class BlockInstance extends RenderObject
{

View File

@ -2,7 +2,7 @@ package com.github.halotroop.litecraft.types.entity;
import org.joml.Vector3f;
import com.github.hydos.ginger.engine.openGL.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
public abstract class Entity extends RenderObject

View File

@ -15,8 +15,8 @@ import com.github.halotroop.litecraft.world.block.BlockRenderer;
import com.github.halotroop.litecraft.world.dimension.Dimension;
import com.github.halotroop.litecraft.world.gen.*;
import com.github.halotroop.litecraft.world.gen.modifier.WorldModifier;
import com.github.hydos.ginger.engine.openGL.elements.objects.Player;
import com.github.hydos.ginger.engine.openGL.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.elements.objects.Player;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import it.unimi.dsi.fastutil.longs.*;

View File

@ -6,14 +6,14 @@ import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.types.block.BlockInstance;
import com.github.halotroop.litecraft.world.Chunk;
import com.github.halotroop.litecraft.world.gen.WorldGenConstants;
import com.github.hydos.ginger.engine.openGL.api.GingerRegister;
import com.github.hydos.ginger.engine.openGL.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.openGL.render.Renderer;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import com.github.hydos.ginger.engine.openGL.render.shaders.StaticShader;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class BlockRenderer extends Renderer implements WorldGenConstants
{
@ -28,7 +28,7 @@ public class BlockRenderer extends Renderer implements WorldGenConstants
shader.start();
shader.loadProjectionMatrix(projectionMatrix);
shader.stop();
this.atlasID = Loader.createBlockAtlas();
this.atlasID = GlLoader.createBlockAtlas();
}
private void prepBlockInstance(RenderObject entity)

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL;
package com.github.hydos.ginger.engine.common;
import org.joml.Vector3f;

View File

@ -1,9 +1,9 @@
package com.github.hydos.ginger.engine.openGL.api;
package com.github.hydos.ginger.engine.common.api;
import java.util.*;
import com.github.hydos.ginger.engine.openGL.api.game.Game;
import com.github.hydos.ginger.engine.openGL.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.api.game.Game;
import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.openGL.font.GUIText;
import com.github.hydos.ginger.engine.openGL.postprocessing.Fbo;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.api.game;
package com.github.hydos.ginger.engine.common.api.game;
public abstract class Game
{

View File

@ -1,12 +1,12 @@
package com.github.hydos.ginger.engine.openGL.api.game;
package com.github.hydos.ginger.engine.common.api.game;
import java.util.*;
import org.joml.Vector4f;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.openGL.elements.objects.*;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.objects.*;
/**
* Used for storing essential engine game data so main class isn't messy

View File

@ -1,10 +1,10 @@
package com.github.hydos.ginger.engine.openGL.cameras;
package com.github.hydos.ginger.engine.common.cameras;
import org.joml.Vector3f;
import org.lwjgl.glfw.*;
import com.github.hydos.ginger.engine.openGL.elements.objects.Player;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.elements.objects.Player;
import com.github.hydos.ginger.engine.common.io.Window;
public class Camera
{

View File

@ -1,9 +1,9 @@
package com.github.hydos.ginger.engine.openGL.cameras;
package com.github.hydos.ginger.engine.common.cameras;
import org.joml.Vector3f;
import com.github.hydos.ginger.engine.openGL.elements.objects.Player;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.elements.objects.Player;
import com.github.hydos.ginger.engine.common.io.Window;
public class FirstPersonCamera extends Camera
{

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.elements;
package com.github.hydos.ginger.engine.common.elements;
import org.joml.Vector2f;

View File

@ -1,13 +1,13 @@
package com.github.hydos.ginger.engine.openGL.elements.buttons;
package com.github.hydos.ginger.engine.common.elements.buttons;
import java.util.List;
import org.joml.Vector2f;
import org.lwjgl.glfw.GLFW;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class TextureButton
{
@ -20,7 +20,7 @@ public class TextureButton
public TextureButton(String texture, Vector2f position, Vector2f scale)
{
resourceLocation = texture;
guiTexture = new GuiTexture(Loader.loadTextureDirectly(texture), position, scale);
guiTexture = new GuiTexture(GlLoader.loadTextureDirectly(texture), position, scale);
}
public void hide(List<GuiTexture> guiTextureList)

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.elements.objects;
package com.github.hydos.ginger.engine.common.elements.objects;
import org.joml.Vector3f;

View File

@ -1,13 +1,13 @@
package com.github.hydos.ginger.engine.openGL.elements.objects;
package com.github.hydos.ginger.engine.common.elements.objects;
import org.joml.Vector3f;
import com.github.halotroop.litecraft.Litecraft;
import com.github.halotroop.litecraft.util.RelativeDirection;
import com.github.halotroop.litecraft.world.gen.WorldGenConstants;
import com.github.hydos.ginger.engine.openGL.Constants;
import com.github.hydos.ginger.engine.openGL.api.GingerRegister;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.Constants;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
public class Player extends RenderObject implements WorldGenConstants

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.elements.objects;
package com.github.hydos.ginger.engine.common.elements.objects;
import org.joml.Vector3f;

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.io;
package com.github.hydos.ginger.engine.common.io;
import java.nio.*;
@ -7,7 +7,7 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.api.Ginger;
import com.github.hydos.ginger.engine.openGL.api.GingerGL;
import com.github.hydos.ginger.engine.openGL.render.texture.Image;
public class Window
@ -189,7 +189,7 @@ public class Window
// Hack to make the FBO update when the screen size is changed
if ((oldWindowHeight != Window.getHeight() || oldWindowWidth != Window.getWidth()) && Window.getHeight() > 10 && Window.getWidth() > 10)
{
Ginger.getInstance().contrastFbo.resizeFBOs();
GingerGL.getInstance().contrastFbo.resizeFBOs();
oldWindowWidth = Window.getWidth();
oldWindowHeight = Window.getHeight();
}

View File

@ -1,10 +1,10 @@
package com.github.hydos.ginger.engine.openGL.math;
package com.github.hydos.ginger.engine.common.math;
import java.lang.Math;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.common.cameras.Camera;
public class Maths
{

View File

@ -0,0 +1,5 @@
package com.github.hydos.ginger.engine.common.obj;
public class Material
{
}

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj;
package com.github.hydos.ginger.engine.common.obj;
public class Mesh
{

View File

@ -0,0 +1,22 @@
package com.github.hydos.ginger.engine.common.obj;
import com.github.hydos.ginger.engine.common.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import com.github.hydos.ginger.engine.openGL.render.texture.ModelTexture;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class ModelLoader
{
public static TexturedModel loadGenericCube(String cubeTexture)
{
Mesh data = StaticCube.getCube();
TexturedModel tm = new TexturedModel(GlLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(cubeTexture));
return tm;
}
public static TexturedModel loadModel(String objPath, String texturePath)
{
Mesh data = OBJFileLoader.loadModel(objPath);
return new TexturedModel(GlLoader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
}
}

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj;
package com.github.hydos.ginger.engine.common.obj;
import org.joml.*;
import org.lwjgl.assimp.*;

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj;
package com.github.hydos.ginger.engine.common.obj;
import org.joml.*;

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj.normals;
package com.github.hydos.ginger.engine.common.obj.normals;
public class ModelDataNM
{

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj.normals;
package com.github.hydos.ginger.engine.common.obj.normals;
import java.io.*;
import java.util.*;
@ -6,7 +6,7 @@ import java.util.*;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class NormalMappedObjLoader
{
@ -166,7 +166,7 @@ public class NormalMappedObjLoader
float furthest = convertDataToArrays(vertices, textures, normals, verticesArray,
texturesArray, normalsArray, tangentsArray);
int[] indicesArray = convertIndicesListToArray(indices);
return Loader.loadToVAO(verticesArray, indicesArray, normalsArray, tangentsArray, texturesArray);
return GlLoader.loadToVAO(verticesArray, indicesArray, normalsArray, tangentsArray, texturesArray);
}
private static VertexNM processVertex(String[] vertex, List<VertexNM> vertices,

View File

@ -1,4 +1,4 @@
package com.github.hydos.ginger.engine.openGL.obj.normals;
package com.github.hydos.ginger.engine.common.obj.normals;
import java.util.*;

View File

@ -0,0 +1 @@
package com.github.hydos.ginger.engine.common.obj.shapes;

View File

@ -1,6 +1,6 @@
package com.github.hydos.ginger.engine.openGL.obj.shapes;
package com.github.hydos.ginger.engine.common.obj.shapes;
import com.github.hydos.ginger.engine.openGL.obj.Mesh;
import com.github.hydos.ginger.engine.common.obj.Mesh;
public class StaticCube
{

View File

@ -5,22 +5,22 @@ import org.joml.Vector2f;
import com.github.halotroop.litecraft.Litecraft;
import com.github.halotroop.litecraft.logic.Timer;
import com.github.halotroop.litecraft.logic.Timer.TickListener;
import com.github.hydos.ginger.engine.openGL.api.game.*;
import com.github.hydos.ginger.engine.openGL.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.openGL.elements.objects.Player;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.api.game.*;
import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton;
import com.github.hydos.ginger.engine.common.elements.objects.Player;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.font.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.particle.ParticleMaster;
import com.github.hydos.ginger.engine.openGL.postprocessing.*;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;
import com.github.hydos.ginger.engine.openGL.render.tools.MousePicker;
import com.github.hydos.ginger.engine.openGL.screen.Screen;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
import com.github.hydos.multithreading.GingerThreading;
public class Ginger
public class GingerGL
{
private static Ginger INSTANCE;
private static GingerGL INSTANCE;
private GingerRegister registry;
public MousePicker picker;
public FontType globalFont;
@ -42,10 +42,9 @@ public class Ginger
{
Window.stop();
PostProcessing.cleanUp();
ParticleMaster.cleanUp();
registry.masterRenderer.cleanUp();
TextMaster.cleanUp();
Loader.cleanUp();
GlLoader.cleanUp();
}
public void openScreen(Screen screen)
@ -91,7 +90,6 @@ public class Ginger
GingerUtils.preRenderScene(registry.masterRenderer);
contrastFbo.bindFBO();
registry.masterRenderer.renderScene(data.entities, data.normalMapEntities, data.lights, data.camera, data.clippingPlane, game.getWorld());
ParticleMaster.renderParticles(data.camera);
contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
if (data.handleGuis) renderOverlays(game);
@ -112,7 +110,6 @@ public class Ginger
registry.masterRenderer = masterRenderer;
picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix());
PostProcessing.init();
ParticleMaster.init(masterRenderer.getProjectionMatrix());
}
public void startGameLoop()
@ -136,11 +133,10 @@ public class Ginger
registry.game.update();
picker.update();
GingerUtils.update();
ParticleMaster.update(data.camera);
Window.update();
Litecraft.getInstance().ups += 1;
}
public static Ginger getInstance()
public static GingerGL getInstance()
{ return INSTANCE; }
}

View File

@ -1,8 +1,8 @@
package com.github.hydos.ginger.engine.openGL.api;
import com.github.hydos.ginger.engine.common.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.obj.normals.NormalMappedObjLoader;
import com.github.hydos.ginger.engine.openGL.font.TextMaster;
import com.github.hydos.ginger.engine.openGL.obj.ModelLoader;
import com.github.hydos.ginger.engine.openGL.obj.normals.NormalMappedObjLoader;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;
import com.github.hydos.ginger.engine.openGL.render.models.*;
import com.github.hydos.ginger.engine.openGL.render.texture.ModelTexture;

View File

@ -3,7 +3,7 @@ package com.github.hydos.ginger.engine.openGL.font;
import java.io.*;
import java.util.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.io.Window;
/** Provides functionality for getting the values from a font file. */
public class MetaFile

View File

@ -2,9 +2,9 @@ package com.github.hydos.ginger.engine.openGL.font;
import java.util.*;
import com.github.hydos.ginger.engine.openGL.api.Ginger;
import com.github.hydos.ginger.engine.openGL.api.GingerGL;
import com.github.hydos.ginger.engine.openGL.render.renderers.FontRenderer;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class TextMaster
{
@ -21,7 +21,7 @@ public class TextMaster
{
FontType font = text.getFont();
TextMeshData data = font.loadText(text);
int vao = Loader.loadToVAO(data.getVertexPositions(), data.getTextureCoords());
int vao = GlLoader.loadToVAO(data.getVertexPositions(), data.getTextureCoords());
text.setMeshInfo(vao, data.getVertexCount());
List<GUIText> textBatch = texts.get(font);
if (textBatch == null)
@ -46,10 +46,10 @@ public class TextMaster
public static void render(GUIText buildText)
{
Map<FontType, List<GUIText>> oldTexts = texts;
List<GUIText> oldFontText = texts.get(Ginger.getInstance().globalFont);
List<GUIText> oldFontText = texts.get(GingerGL.getInstance().globalFont);
oldFontText.add(buildText);
texts.clear();
texts.put(Ginger.getInstance().globalFont, oldFontText);
texts.put(GingerGL.getInstance().globalFont, oldFontText);
texts = oldTexts;
}
}

View File

@ -1,5 +0,0 @@
package com.github.hydos.ginger.engine.openGL.obj;
public class Material
{
}

View File

@ -1,22 +0,0 @@
package com.github.hydos.ginger.engine.openGL.obj;
import com.github.hydos.ginger.engine.openGL.obj.shapes.StaticCube;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import com.github.hydos.ginger.engine.openGL.render.texture.ModelTexture;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
public class ModelLoader
{
public static TexturedModel loadGenericCube(String cubeTexture)
{
Mesh data = StaticCube.getCube();
TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(cubeTexture));
return tm;
}
public static TexturedModel loadModel(String objPath, String texturePath)
{
Mesh data = OBJFileLoader.loadModel(objPath);
return new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath));
}
}

View File

@ -1 +0,0 @@
package com.github.hydos.ginger.engine.openGL.obj.shapes;

View File

@ -1,32 +0,0 @@
package com.github.hydos.ginger.engine.openGL.particle;
import java.util.List;
public class InsertionSort
{
/** Sorts a list of particles so that the particles with the highest distance
* from the camera are first, and the particles with the shortest distance
* are last.
*
* @param list
* - the list of particles needing sorting. */
public static void sortHighToLow(List<Particle> list)
{
for (int i = 1; i < list.size(); i++)
{
Particle item = list.get(i);
if (item.getDistance() > list.get(i - 1).getDistance())
{ sortUpHighToLow(list, i); }
}
}
private static void sortUpHighToLow(List<Particle> list, int i)
{
Particle item = list.get(i);
int attemptPos = i - 1;
while (attemptPos != 0 && list.get(attemptPos - 1).getDistance() < item.getDistance())
{ attemptPos--; }
list.remove(i);
list.add(attemptPos, item);
}
}

View File

@ -1,96 +0,0 @@
package com.github.hydos.ginger.engine.openGL.particle;
import java.lang.Math;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.Constants;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.io.Window;
public class Particle
{
private Vector3f position;
private Vector3f velocity;
private float gravityEffect;
private float lifeLength;
private float rotation;
private Vector3f scale;
private Vector2f texOffset1 = new Vector2f();
private Vector2f texOffset2 = new Vector2f();
private float blend;
private ParticleTexture texture;
private float elapsedTime = 0;
private float distance;
public Particle(ParticleTexture texture, Vector3f position, Vector3f velocity, float gravityEffect, float lifeLength, float rotation,
Vector3f scale)
{
super();
this.position = position;
this.velocity = velocity;
this.gravityEffect = gravityEffect;
this.lifeLength = lifeLength;
this.rotation = rotation;
this.scale = scale;
this.texture = texture;
ParticleMaster.addParticle(this);
}
public float getBlend()
{ return blend; }
public float getDistance()
{ return distance; }
public Vector3f getPosition()
{ return position; }
public float getRotation()
{ return rotation; }
public Vector3f getScale()
{ return scale; }
public Vector2f getTexOffset1()
{ return texOffset1; }
public Vector2f getTexOffset2()
{ return texOffset2; }
public ParticleTexture getTexture()
{ return texture; }
private void setTextureOffset(Vector2f offset, int index)
{
int column = index % texture.getNumberOfRows();
int row = index / texture.getNumberOfRows();
offset.x = (float) column / texture.getNumberOfRows();
offset.y = (float) row / texture.getNumberOfRows();
}
public boolean update(Camera camera)
{
float time = (float) Window.getTime() / 1000000;
velocity.y += Constants.gravity.y() * gravityEffect * time;
Vector3f change = new Vector3f(velocity);
change.mul(time);
position.add(change, position);
distance = camera.getPosition().sub(position).lengthSquared();
elapsedTime += time;
updateTextureCoordInfo();
return elapsedTime < lifeLength;
}
private void updateTextureCoordInfo()
{
float lifeFactor = elapsedTime / lifeLength;
int stageCount = texture.getNumberOfRows() * texture.getNumberOfRows();
float atlasProgression = lifeFactor * stageCount;
int index1 = (int) Math.floor(atlasProgression);
int index2 = index1 < stageCount - 1 ? index1 + 1 : index1;
this.blend = atlasProgression % 1;
setTextureOffset(texOffset1, index1);
setTextureOffset(texOffset2, index2);
}
}

View File

@ -1,57 +0,0 @@
package com.github.hydos.ginger.engine.openGL.particle;
import java.util.*;
import java.util.Map.Entry;
import org.joml.Matrix4f;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.render.renderers.ParticleRenderer;
public class ParticleMaster
{
private static Map<ParticleTexture, List<Particle>> particles = new HashMap<ParticleTexture, List<Particle>>();
private static ParticleRenderer particleRenderer;
public static void addParticle(Particle particle)
{
List<Particle> list = particles.get(particle.getTexture());
if (list == null)
{
list = new ArrayList<Particle>();
particles.put(particle.getTexture(), list);
}
list.add(particle);
}
public static void cleanUp()
{ particleRenderer.cleanUp(); }
public static void init(Matrix4f projectionMatrix)
{ particleRenderer = new ParticleRenderer(projectionMatrix); }
public static void renderParticles(Camera camera)
{ particleRenderer.render(particles, camera); }
public static void update(Camera camera)
{
Iterator<Entry<ParticleTexture, List<Particle>>> mapIterator = particles.entrySet().iterator();
while (mapIterator.hasNext())
{
List<Particle> list = mapIterator.next().getValue();
Iterator<Particle> iterator = list.iterator();
while (iterator.hasNext())
{
Particle p = iterator.next();
boolean stillAlive = p.update(camera);
if (!stillAlive)
{
iterator.remove();
if (list.isEmpty())
{ mapIterator.remove(); }
}
}
InsertionSort.sortHighToLow(list);
}
}
}

View File

@ -1,137 +0,0 @@
package com.github.hydos.ginger.engine.openGL.particle;
import java.lang.Math;
import java.util.Random;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
public class ParticleSystem
{
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle)
{
float cosAngle = (float) Math.cos(angle);
Random random = new Random();
float theta = (float) (random.nextFloat() * 2f * Math.PI);
float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
float x = (float) (rootOneMinusZSquared * Math.cos(theta));
float y = (float) (rootOneMinusZSquared * Math.sin(theta));
Vector4f direction = new Vector4f(x, y, z, 1);
if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1))
{
Vector3f rotateAxis = coneDirection.cross(new Vector3f(0, 0, 1));
rotateAxis.normalize();
float rotateAngle = (float) Math.acos(coneDirection.dot(new Vector3f(0, 0, 1)));
Matrix4f rotationMatrix = new Matrix4f();
rotationMatrix.rotate(-rotateAngle, rotateAxis);
rotationMatrix.transform(direction);
}
else if (coneDirection.z == -1)
{ direction.z *= -1; }
return new Vector3f(direction.x, direction.y, direction.z);
}
private float pps, averageSpeed, gravityComplient, averageLifeLength, averageScale;
private float speedError, lifeError, scaleError = 0;
private boolean randomRotation = false;
private Vector3f direction;
private float directionDeviation = 0;
private ParticleTexture texture;
private Random random = new Random();
public ParticleSystem(ParticleTexture texture, float pps, float speed, float gravityComplient, float lifeLength, float scale)
{
this.pps = pps / 100000;
this.averageSpeed = speed;
this.gravityComplient = gravityComplient;
this.averageLifeLength = lifeLength;
this.averageScale = scale;
this.texture = texture;
}
private void emitParticle(Vector3f center)
{
Vector3f velocity = null;
if (direction != null)
{
velocity = generateRandomUnitVectorWithinCone(direction, directionDeviation);
}
else
{
velocity = generateRandomUnitVector();
}
velocity.normalize();
velocity.mul(generateValue(averageSpeed, speedError));
float scale = generateValue(averageScale, scaleError);
float lifeLength = generateValue(averageLifeLength, lifeError);
new Particle(texture, new Vector3f(center), velocity, gravityComplient, lifeLength, generateRotation(), new Vector3f(scale, scale, scale));
}
public void generateParticles(Vector3f systemCenter)
{
float delta = (float) Window.getTime();
float particlesToCreate = pps * delta;
int count = (int) Math.floor(particlesToCreate);
float partialParticle = particlesToCreate % 1;
for (int i = 0; i < count; i++)
{ emitParticle(systemCenter); }
if (Math.random() < partialParticle)
{ emitParticle(systemCenter); }
}
private Vector3f generateRandomUnitVector()
{
float theta = (float) (random.nextFloat() * 2f * Math.PI);
float z = (random.nextFloat() * 2) - 1;
float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
float x = (float) (rootOneMinusZSquared * Math.cos(theta));
float y = (float) (rootOneMinusZSquared * Math.sin(theta));
return new Vector3f(x, y, z);
}
private float generateRotation()
{
if (randomRotation)
{
return random.nextFloat() * 360f;
}
else
{
return 0;
}
}
private float generateValue(float average, float errorMargin)
{
float offset = (random.nextFloat() - 0.5f) * 2f * errorMargin;
return average + offset;
}
public void randomizeRotation()
{ randomRotation = true; }
/** @param direction - The average direction in which particles are emitted.
* @param deviation - A value between 0 and 1 indicating how far from the chosen direction particles can deviate. */
public void setDirection(Vector3f direction, float deviation)
{
this.direction = new Vector3f(direction);
this.directionDeviation = (float) (deviation * Math.PI);
}
/** @param error
* - A number between 0 and 1, where 0 means no error margin. */
public void setLifeError(float error)
{ this.lifeError = error * averageLifeLength; }
/** @param error
* - A number between 0 and 1, where 0 means no error margin. */
public void setScaleError(float error)
{ this.scaleError = error * averageScale; }
/** @param error
* - A number between 0 and 1, where 0 means no error margin. */
public void setSpeedError(float error)
{ this.speedError = error * averageSpeed; }
}

View File

@ -1,20 +0,0 @@
package com.github.hydos.ginger.engine.openGL.particle;
public class ParticleTexture
{
private int textureID;
private int numberOfRows;
public ParticleTexture(int textureID, int numberOfRows)
{
super();
this.textureID = textureID;
this.numberOfRows = numberOfRows;
}
public int getNumberOfRows()
{ return numberOfRows; }
public int getTextureID()
{ return textureID; }
}

View File

@ -8,8 +8,8 @@ import java.nio.ByteBuffer;
import org.lwjgl.glfw.*;
import org.lwjgl.system.Callback;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.fbo.FboCallbackHandler;
import com.github.hydos.ginger.engine.openGL.io.Window;
public class Fbo
{

View File

@ -3,7 +3,7 @@ package com.github.hydos.ginger.engine.openGL.postprocessing;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class PostProcessing
{
@ -33,7 +33,7 @@ public class PostProcessing
public static void init()
{
quad = Loader.loadToVAO(POSITIONS, 2);
quad = GlLoader.loadToVAO(POSITIONS, 2);
contrastChanger = new ContrastChanger();
}

View File

@ -8,10 +8,10 @@ import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.world.World;
import com.github.halotroop.litecraft.world.block.BlockRenderer;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.openGL.elements.objects.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.objects.*;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
import com.github.hydos.ginger.engine.openGL.render.renderers.*;
import com.github.hydos.ginger.engine.openGL.render.shaders.*;

View File

@ -5,12 +5,12 @@ import java.util.List;
import org.joml.Matrix4f;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.openGL.render.Renderer;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.render.shaders.GuiShader;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class GuiRenderer extends Renderer
{
@ -24,7 +24,7 @@ public class GuiRenderer extends Renderer
{
-1, 1, -1, -1, 1, 1, 1, -1
};
quad = Loader.loadToVAO(positions, 2);
quad = GlLoader.loadToVAO(positions, 2);
}
public void cleanUp()

View File

@ -5,10 +5,10 @@ import java.util.*;
import org.joml.*;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.objects.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.*;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.openGL.render.*;
import com.github.hydos.ginger.engine.openGL.render.models.*;
import com.github.hydos.ginger.engine.openGL.render.shaders.NormalMappingShader;

View File

@ -6,10 +6,10 @@ import org.joml.Matrix4f;
import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.types.block.BlockInstance;
import com.github.hydos.ginger.engine.openGL.api.GingerRegister;
import com.github.hydos.ginger.engine.openGL.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.api.GingerRegister;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.openGL.render.*;
import com.github.hydos.ginger.engine.openGL.render.models.*;
import com.github.hydos.ginger.engine.openGL.render.shaders.StaticShader;

View File

@ -1,156 +0,0 @@
package com.github.hydos.ginger.engine.openGL.render.renderers;
import java.lang.Math;
import java.nio.FloatBuffer;
import java.util.*;
import org.joml.*;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.openGL.particle.*;
import com.github.hydos.ginger.engine.openGL.render.Renderer;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.render.shaders.ParticleShader;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
public class ParticleRenderer extends Renderer
{
private static final float[] VERTICES =
{
-0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f, -0.5f
};
private static final int MAX_INSTANCES = 10000;
private static final int INSTANCE_DATA_LENGTH = 21;
private static final FloatBuffer buffer = BufferUtils.createFloatBuffer(MAX_INSTANCES * INSTANCE_DATA_LENGTH);
private RawModel quad;
private ParticleShader shader;
private int vbo;
private int pointer;
public ParticleRenderer(Matrix4f projectionMatrix)
{
quad = Loader.loadToVAO(VERTICES, 2);
this.vbo = Loader.createEmptyVbo(INSTANCE_DATA_LENGTH * MAX_INSTANCES);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 1, 4, INSTANCE_DATA_LENGTH, 0);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 2, 4, INSTANCE_DATA_LENGTH, 4);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 3, 4, INSTANCE_DATA_LENGTH, 8);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 4, 4, INSTANCE_DATA_LENGTH, 12);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 5, 4, INSTANCE_DATA_LENGTH, 16);
Loader.addInstancedAttribute(quad.getVaoID(), vbo, 6, 1, INSTANCE_DATA_LENGTH, 20);
shader = new ParticleShader();
shader.start();
shader.loadProjectionMatrix(projectionMatrix);
shader.stop();
}
private void bindTexture(ParticleTexture texture)
{
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
shader.loadNumberOfRows(texture.getNumberOfRows());
}
public void cleanUp()
{ shader.cleanUp(); }
private void finishRendering()
{
shader.stop();
GL30.glBindVertexArray(0);
GL11.glDisable(GL11.GL_BLEND);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(2);
GL20.glDisableVertexAttribArray(3);
GL20.glDisableVertexAttribArray(4);
GL20.glDisableVertexAttribArray(5);
GL20.glDisableVertexAttribArray(6);
}
private void prepare()
{
shader.start();
GL30.glBindVertexArray(quad.getVaoID());
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL20.glEnableVertexAttribArray(2);
GL20.glEnableVertexAttribArray(3);
GL20.glEnableVertexAttribArray(4);
GL20.glEnableVertexAttribArray(5);
GL20.glEnableVertexAttribArray(6);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);//TODO: add all particle effects into 1 texture to fix overlapping
}
public void render(Map<ParticleTexture, List<Particle>> particles, Camera camera)
{
Matrix4f viewMatrix = Maths.createViewMatrix(camera);
prepare();
for (ParticleTexture texture : particles.keySet())
{
bindTexture(texture);
List<Particle> particleList = particles.get(texture);
pointer = 0;
float[] vboData = new float[particleList.size() * INSTANCE_DATA_LENGTH];
for (Particle particle : particleList)
{
updateModelViewMatrix(particle.getPosition(), particle.getRotation(), particle.getScale().x, viewMatrix, vboData);
updateTexCoordInfo(particle, vboData);
}
Loader.updateVbo(vbo, vboData, buffer);
GL31.glDrawArraysInstanced(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount(), particleList.size());
}
finishRendering();
}
private void storeMatrixData(Matrix4f matrix, float[] vboData)
{
vboData[pointer++] = matrix.m00();
vboData[pointer++] = matrix.m01();
vboData[pointer++] = matrix.m02();
vboData[pointer++] = matrix.m03();
vboData[pointer++] = matrix.m10();
vboData[pointer++] = matrix.m11();
vboData[pointer++] = matrix.m12();
vboData[pointer++] = matrix.m13();
vboData[pointer++] = matrix.m20();
vboData[pointer++] = matrix.m21();
vboData[pointer++] = matrix.m22();
vboData[pointer++] = matrix.m23();
vboData[pointer++] = matrix.m30();
vboData[pointer++] = matrix.m31();
vboData[pointer++] = matrix.m32();
vboData[pointer++] = matrix.m33();
}
private void updateModelViewMatrix(Vector3f position, float rotation, float scale, Matrix4f viewMatrix, float[] vboData)
{
Matrix4f modelMatrix = new Matrix4f();
modelMatrix.translate(position, modelMatrix);
modelMatrix._m00(viewMatrix.m00());
modelMatrix._m01(viewMatrix.m10());
modelMatrix._m02(viewMatrix.m20());
modelMatrix._m10(viewMatrix.m01());
modelMatrix._m11(viewMatrix.m11());
modelMatrix._m12(viewMatrix.m21());
modelMatrix._m20(viewMatrix.m02());
modelMatrix._m21(viewMatrix.m12());
modelMatrix._m22(viewMatrix.m22());
modelMatrix.rotate((float) Math.toRadians(rotation), new Vector3f(0, 0, 1), modelMatrix);
modelMatrix.scale(new Vector3f(scale, scale, scale), modelMatrix);
Matrix4f modelViewMatrix = viewMatrix.mul(modelMatrix);
storeMatrixData(modelViewMatrix, vboData);
}
private void updateTexCoordInfo(Particle particle, float[] data)
{
data[pointer++] = particle.getTexOffset1().x;
data[pointer++] = particle.getTexOffset1().y;
data[pointer++] = particle.getTexOffset2().x;
data[pointer++] = particle.getTexOffset2().y;
data[pointer++] = particle.getBlend();
}
}

View File

@ -3,11 +3,11 @@ package com.github.hydos.ginger.engine.openGL.render.renderers;
import org.joml.Matrix4f;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.render.Renderer;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.render.shaders.SkyboxShader;
import com.github.hydos.ginger.engine.openGL.utils.Loader;
import com.github.hydos.ginger.engine.openGL.utils.GlLoader;
public class SkyboxRenderer extends Renderer
{
@ -62,8 +62,8 @@ public class SkyboxRenderer extends Renderer
public SkyboxRenderer(Matrix4f projectionMatrix)
{
cube = Loader.loadToVAO(VERTICES, 3);
texture = Loader.loadCubeMap(TEXTURE_FILES);
cube = GlLoader.loadToVAO(VERTICES, 3);
texture = GlLoader.loadCubeMap(TEXTURE_FILES);
shader = new SkyboxShader();
shader.start();
shader.loadProjectionMatrix(projectionMatrix);

View File

@ -4,7 +4,7 @@ import java.util.List;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.elements.objects.Light;
import com.github.hydos.ginger.engine.common.elements.objects.Light;
public class NormalMappingShader extends ShaderProgram
{

View File

@ -2,8 +2,8 @@ package com.github.hydos.ginger.engine.openGL.render.shaders;
import org.joml.Matrix4f;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.math.Maths;
public class SkyboxShader extends ShaderProgram
{

View File

@ -4,9 +4,9 @@ import java.util.List;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.objects.Light;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.Light;
import com.github.hydos.ginger.engine.common.math.Maths;
public class StaticShader extends ShaderProgram
{

View File

@ -4,9 +4,9 @@ import java.util.List;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.objects.Light;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.Light;
import com.github.hydos.ginger.engine.common.math.Maths;
public class TerrainShader extends ShaderProgram
{

View File

@ -2,9 +2,9 @@ package com.github.hydos.ginger.engine.openGL.render.tools;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.common.math.Maths;
public class MousePicker
{

View File

@ -2,7 +2,7 @@ package com.github.hydos.ginger.engine.openGL.screen;
import java.util.List;
import com.github.hydos.ginger.engine.openGL.elements.GuiTexture;
import com.github.hydos.ginger.engine.common.elements.GuiTexture;
public abstract class Screen
{

View File

@ -4,8 +4,8 @@ import java.lang.Math;
import org.joml.*;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;
/** Represents the 3D cuboidal area of the world in which objects will cast

View File

@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.io.Window;
/** The frame buffer for the shadow pass. This class sets up the depth texture
* which can be rendered to during the shadow render pass, producing a shadow

View File

@ -5,8 +5,8 @@ import java.util.*;
import org.joml.Matrix4f;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.openGL.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.openGL.math.Maths;
import com.github.hydos.ginger.engine.common.elements.objects.RenderObject;
import com.github.hydos.ginger.engine.common.math.Maths;
import com.github.hydos.ginger.engine.openGL.render.MasterRenderer;
import com.github.hydos.ginger.engine.openGL.render.models.*;

View File

@ -6,8 +6,8 @@ import java.util.*;
import org.joml.*;
import org.lwjgl.opengl.GL11;
import com.github.hydos.ginger.engine.openGL.cameras.Camera;
import com.github.hydos.ginger.engine.openGL.elements.objects.*;
import com.github.hydos.ginger.engine.common.cameras.Camera;
import com.github.hydos.ginger.engine.common.elements.objects.*;
import com.github.hydos.ginger.engine.openGL.render.models.TexturedModel;
/** This class is in charge of using all of the classes in the shadows package to

View File

@ -1,15 +0,0 @@
package com.github.hydos.ginger.engine.openGL.terrain;
public class TerrainTexture
{
private int textureID;
public TerrainTexture(int textureID)
{
super();
this.textureID = textureID;
}
public int getTextureID()
{ return textureID; }
}

View File

@ -1,30 +0,0 @@
package com.github.hydos.ginger.engine.openGL.terrain;
public class TerrainTexturePack
{
private TerrainTexture backgroundTexture;
private TerrainTexture rTexture;
private TerrainTexture gTexture;
private TerrainTexture bTexture;
public TerrainTexturePack(TerrainTexture backgroundTexture, TerrainTexture rTexture, TerrainTexture gTexture,
TerrainTexture bTexture)
{
this.backgroundTexture = backgroundTexture;
this.rTexture = rTexture;
this.gTexture = gTexture;
this.bTexture = bTexture;
}
public TerrainTexture getBackgroundTexture()
{ return backgroundTexture; }
public TerrainTexture getbTexture()
{ return bTexture; }
public TerrainTexture getgTexture()
{ return gTexture; }
public TerrainTexture getrTexture()
{ return rTexture; }
}

View File

@ -7,12 +7,11 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.*;
import com.github.halotroop.litecraft.types.block.*;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.openGL.render.models.RawModel;
import com.github.hydos.ginger.engine.openGL.render.texture.*;
import com.github.hydos.ginger.engine.openGL.terrain.TerrainTexture;
public class Loader
public class GlLoader
{
private static List<Integer> vaos = new ArrayList<Integer>();
private static List<Integer> vbos = new ArrayList<Integer>();
@ -100,9 +99,6 @@ public class Loader
return textureID;
}
public static TerrainTexture loadTerrainTexture(String string)
{ return new TerrainTexture(new ModelTexture("terrain/" + string).getTextureID()); }
public static int loadTexture(String path)
{ return loadTextureDirectly("/textures/" + path); }

View File

@ -0,0 +1,5 @@
package com.github.hydos.ginger.engine.vulkan.api;
public class GingerV {
}

View File

@ -0,0 +1,10 @@
package com.github.hydos.ginger.engine.vulkan.utils;
/**
*
* @author hayden
* used to load vulkan related objects such as textures
*
*/
public class VLoader {
}

View File

@ -3,7 +3,7 @@ package com.github.hydos.multithreading;
import java.util.*;
import com.github.halotroop.litecraft.Litecraft;
import com.github.hydos.ginger.engine.openGL.io.Window;
import com.github.hydos.ginger.engine.common.io.Window;
public class GingerThreading extends Thread
{