diff --git a/Caroline's Java Formatting Preference.xml b/Caroline's Java Formatting Preference.xml index 4602731..9a6ad9c 100644 --- a/Caroline's Java Formatting Preference.xml +++ b/Caroline's Java Formatting Preference.xml @@ -80,7 +80,7 @@ - + @@ -362,366 +362,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index 5de4a52..ce0a96c 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -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.api.*; -import com.github.hydos.ginger.engine.api.game.*; -import com.github.hydos.ginger.engine.cameras.*; -import com.github.hydos.ginger.engine.elements.objects.*; -import com.github.hydos.ginger.engine.font.FontType; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.obj.ModelLoader; -import com.github.hydos.ginger.engine.obj.shapes.StaticCube; -import com.github.hydos.ginger.engine.render.MasterRenderer; -import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.engine.utils.Loader; -import com.github.hydos.ginger.main.settings.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.font.FontType; +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.render.MasterRenderer; +import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; +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); diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index 902575d..7c5d6df 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -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.cameras.Camera; -import com.github.hydos.ginger.engine.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.*; diff --git a/src/main/java/com/github/halotroop/litecraft/screens/ExitGameScreen.java b/src/main/java/com/github/halotroop/litecraft/screens/ExitGameScreen.java index b224952..e41fb08 100644 --- a/src/main/java/com/github/halotroop/litecraft/screens/ExitGameScreen.java +++ b/src/main/java/com/github/halotroop/litecraft/screens/ExitGameScreen.java @@ -2,15 +2,15 @@ package com.github.halotroop.litecraft.screens; import org.joml.*; -import com.github.hydos.ginger.engine.api.*; -import com.github.hydos.ginger.engine.font.GUIText; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.screen.Screen; +import com.github.hydos.ginger.engine.common.font.GUIText; +import com.github.hydos.ginger.engine.common.io.Window; +import com.github.hydos.ginger.engine.common.screen.Screen; +import com.github.hydos.ginger.engine.opengl.api.*; public class ExitGameScreen extends Screen { private GUIText infoText; - private Ginger ginger3D = Ginger.getInstance(); + private GingerGL ginger3D = GingerGL.getInstance(); public ExitGameScreen() { diff --git a/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java b/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java index 2ebd503..07bdb86 100644 --- a/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java +++ b/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java @@ -3,15 +3,16 @@ package com.github.halotroop.litecraft.screens; import org.joml.*; import com.github.halotroop.litecraft.Litecraft; -import com.github.hydos.ginger.engine.api.*; -import com.github.hydos.ginger.engine.font.GUIText; -import com.github.hydos.ginger.engine.screen.Screen; +import com.github.hydos.ginger.engine.common.api.GingerRegister; +import com.github.hydos.ginger.engine.common.font.GUIText; +import com.github.hydos.ginger.engine.common.screen.Screen; +import com.github.hydos.ginger.engine.opengl.api.*; 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() diff --git a/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java b/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java index 1865002..9ced4bf 100644 --- a/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java +++ b/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java @@ -7,12 +7,12 @@ 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.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.GUIText; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.screen.Screen; +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.font.GUIText; +import com.github.hydos.ginger.engine.common.io.Window; +import com.github.hydos.ginger.engine.common.screen.Screen; +import com.github.hydos.ginger.engine.opengl.api.GingerGL; /** * YeS @@ -20,7 +20,7 @@ import com.github.hydos.ginger.engine.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(); diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java index 0b5e564..0882b9e 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java @@ -2,8 +2,8 @@ package com.github.halotroop.litecraft.types.block; import java.util.*; -import com.github.hydos.ginger.engine.obj.ModelLoader; -import com.github.hydos.ginger.engine.render.models.TexturedModel; +import com.github.hydos.ginger.engine.common.obj.ModelLoader; +import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; public class Block { @@ -13,7 +13,7 @@ public class Block private boolean fullCube = true; private float caveCarveThreshold = -1f; // cannot carve private final String identifier; - + public Properties(String identifier) { this.identifier = identifier; } @@ -36,10 +36,11 @@ public class Block } } - public final TexturedModel model; + public TexturedModel model; private final boolean visible, fullCube; private final float caveCarveThreshold; public final String identifier; + public String texture; public boolean isFullCube() { return this.fullCube; } @@ -54,7 +55,10 @@ public class Block { this((TexturedModel) null, properties); } protected Block(String texture, Properties properties) - { this(ModelLoader.loadGenericCube(texture), properties); } + { + this(ModelLoader.loadGenericCube("block/"+texture), properties); + this.texture = texture; + } protected Block(TexturedModel model, Properties properties) { @@ -63,9 +67,20 @@ public class Block this.fullCube = properties.fullCube; this.identifier = properties.identifier; this.caveCarveThreshold = properties.caveCarveThreshold; + if(model != null) { + this.texture = model.getTexture().getTexture().getLocation(); + }else { + this.texture = "DONTLOAD"; + } IDENTIFIER_TO_BLOCK.put(this.identifier, this); + Blocks.blocks.add(this); } - + + public void updateBlockModelData() { + System.out.println("Updating block with texture at block/"+texture); + this.model = ModelLoader.loadGenericCube("block/"+texture); + } + public static final Block getBlock(String identifier) { return IDENTIFIER_TO_BLOCK.get(identifier); } diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/BlockInstance.java b/src/main/java/com/github/halotroop/litecraft/types/block/BlockInstance.java index 254f8e7..39185c0 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/BlockInstance.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/BlockInstance.java @@ -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.elements.objects.RenderObject; +import com.github.hydos.ginger.engine.common.elements.objects.RenderObject; public class BlockInstance extends RenderObject { diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java index d215f77..6a2eff3 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java @@ -1,16 +1,21 @@ package com.github.halotroop.litecraft.types.block; +import java.util.ArrayList; + import com.github.halotroop.litecraft.types.block.Block.Properties; public final class Blocks { + + public static ArrayList blocks = new ArrayList(); + public static final Block AIR = new Block(new Properties("air").visible(false).fullCube(false)); - public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png").caveCarveThreshold(0.04f)); - public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt").caveCarveThreshold(0.04f)); - public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite").caveCarveThreshold(0.08f)); - public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite").caveCarveThreshold(0.05f)); - public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite").caveCarveThreshold(0.06f)); - public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss").caveCarveThreshold(0.09f)); + public static final Block GRASS = new Block(new Properties("cubes/soil/grass/grass_top.png").caveCarveThreshold(0.04f)); + public static final Block DIRT = new Block("cubes/soil/dirt.png", new Properties("dirt").caveCarveThreshold(0.04f)); + public static final Block ANDESITE = new Block("cubes/stone/basic/andesite.png", new Properties("andesite").caveCarveThreshold(0.08f)); + public static final Block DIORITE = new Block("cubes/stone/basic/diorite.png", new Properties("diorite").caveCarveThreshold(0.05f)); + public static final Block GRANITE = new Block("cubes/stone/basic/granite.png", new Properties("granite").caveCarveThreshold(0.06f)); + public static final Block GNEISS = new Block("cubes/stone/basic/gneiss.png", new Properties("gneiss").caveCarveThreshold(0.09f)); public static Block init() { diff --git a/src/main/java/com/github/halotroop/litecraft/types/entity/Entity.java b/src/main/java/com/github/halotroop/litecraft/types/entity/Entity.java index 72325cd..dc6b0d6 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/entity/Entity.java +++ b/src/main/java/com/github/halotroop/litecraft/types/entity/Entity.java @@ -2,8 +2,8 @@ package com.github.halotroop.litecraft.types.entity; import org.joml.Vector3f; -import com.github.hydos.ginger.engine.elements.objects.RenderObject; -import com.github.hydos.ginger.engine.render.models.TexturedModel; +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 { diff --git a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java index f7061f4..71b8037 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -35,11 +35,14 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable private boolean fullyGenerated = false; public final int dimension; private boolean dirty = true; +<<<<<<< HEAD private World world; /** * A holder for the rendered blocks in this chunk. This array is *NOT* safe to use for getting BIs at a position! * It can vary in size from 0 to 512 elements long and must only be read linearly. */ +======= +>>>>>>> liteCraft private BlockInstance[] renderedBlocks = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; public Chunk(World world, int chunkX, int chunkY, int chunkZ, int dimension) @@ -51,7 +54,6 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable this.chunkStartY = chunkY << POS_SHIFT; this.chunkStartZ = chunkZ << POS_SHIFT; this.dimension = dimension; - this.world = world; } public boolean doRender() diff --git a/src/main/java/com/github/halotroop/litecraft/world/World.java b/src/main/java/com/github/halotroop/litecraft/world/World.java index e513e3e..39a2743 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -16,9 +16,9 @@ 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.elements.objects.Player; -import com.github.hydos.ginger.engine.obj.ModelLoader; -import com.github.hydos.ginger.engine.render.models.TexturedModel; +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.*; diff --git a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java index 8be52e9..fc19eb9 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java +++ b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java @@ -6,18 +6,24 @@ 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.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.render.Renderer; -import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.engine.render.shaders.StaticShader; +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.GlLoader; public class BlockRenderer extends Renderer implements WorldGenConstants { +<<<<<<< HEAD public StaticShader shader; +======= + private StaticShader shader; + public int atlasID; +>>>>>>> liteCraft public BlockRenderer(StaticShader shader, Matrix4f projectionMatrix) { @@ -25,11 +31,13 @@ public class BlockRenderer extends Renderer implements WorldGenConstants shader.start(); shader.loadProjectionMatrix(projectionMatrix); shader.stop(); + this.atlasID = GlLoader.createBlockAtlas(); } private void prepBlockInstance(RenderObject entity) { - Matrix4f transformationMatrix = Maths.createTransformationMatrix(entity.getPosition(), entity.getRotX(), entity.getRotY(), entity.getRotZ(), entity.getScale()); + Matrix4f transformationMatrix = Maths.createTransformationMatrix(entity.getPosition(), entity.getRotX(), + entity.getRotY(), entity.getRotZ(), entity.getScale()); shader.loadTransformationMatrix(transformationMatrix); } @@ -48,30 +56,35 @@ public class BlockRenderer extends Renderer implements WorldGenConstants GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); } - - public void enableWireframe() { - if (GingerRegister.getInstance().wireframe) - GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); - } - - public void disableWireframe() { - if (GingerRegister.getInstance().wireframe) - GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); - } - - public void prepareRender() { - //TODO: combine VBOS + + public void enableWireframe() + { if (GingerRegister.getInstance().wireframe) + GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } + + public void disableWireframe() + { if (GingerRegister.getInstance().wireframe) + GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); } + + public void prepareRender() + { + // TODO: combine VBOS shader.start(); shader.loadSkyColour(Window.getColour()); shader.loadViewMatrix(GingerRegister.getInstance().game.data.camera); shader.loadFakeLightingVariable(true); shader.loadShine(1, 1); GL13.glActiveTexture(GL13.GL_TEXTURE0); +<<<<<<< HEAD // enableWireframe(); +======= + GL11.glBindTexture(GL11.GL_TEXTURE_2D, atlasID); + enableWireframe(); +>>>>>>> liteCraft } public void render(BlockInstance[] renderList) { +<<<<<<< HEAD // prepareRender(); for (BlockInstance entity : renderList) { @@ -86,5 +99,24 @@ public class BlockRenderer extends Renderer implements WorldGenConstants // disableWireframe(); // shader.stop(); +======= + prepareRender(); + for (int x = 0; x < CHUNK_SIZE; x++) + for (int y = 0; y < CHUNK_SIZE; y++) + for (int z = 0; z < CHUNK_SIZE; z++) + { + BlockInstance entity = renderList[Chunk.index(x, y, z)]; + if (entity != null && entity.getModel() != null) + { + TexturedModel blockModel = entity.getModel(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); + prepBlockInstance(entity); + GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), + GL11.GL_UNSIGNED_INT, 0); + } + } + disableWireframe(); + shader.stop(); +>>>>>>> liteCraft } } diff --git a/src/main/java/com/github/hydos/ginger/main/settings/Constants.java b/src/main/java/com/github/hydos/ginger/engine/common/Constants.java similarity index 83% rename from src/main/java/com/github/hydos/ginger/main/settings/Constants.java rename to src/main/java/com/github/hydos/ginger/engine/common/Constants.java index 2422081..6b0bee7 100644 --- a/src/main/java/com/github/hydos/ginger/main/settings/Constants.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/Constants.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.main.settings; +package com.github.hydos.ginger.engine.common; import org.joml.Vector3f; diff --git a/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java b/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java similarity index 70% rename from src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java rename to src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java index 7436a79..fc19743 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java @@ -1,13 +1,23 @@ -package com.github.hydos.ginger.engine.api; +package com.github.hydos.ginger.engine.common.api; import java.util.*; +<<<<<<< HEAD:src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java 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; +======= +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.common.font.GUIText; +import com.github.hydos.ginger.engine.common.screen.Screen; +import com.github.hydos.ginger.engine.opengl.postprocessing.Fbo; +import com.github.hydos.ginger.engine.opengl.render.MasterRenderer; +import com.github.hydos.multithreading.GingerThreading; +>>>>>>> liteCraft:src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java /** Used if a game wants to access engine variables safely */ public class GingerRegister diff --git a/src/main/java/com/github/hydos/ginger/engine/api/game/Game.java b/src/main/java/com/github/hydos/ginger/engine/common/api/game/Game.java similarity index 77% rename from src/main/java/com/github/hydos/ginger/engine/api/game/Game.java rename to src/main/java/com/github/hydos/ginger/engine/common/api/game/Game.java index 6fe5909..61b5e8f 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/game/Game.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/api/game/Game.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.api.game; +package com.github.hydos.ginger.engine.common.api.game; public abstract class Game { diff --git a/src/main/java/com/github/hydos/ginger/engine/api/game/GameData.java b/src/main/java/com/github/hydos/ginger/engine/common/api/game/GameData.java similarity index 77% rename from src/main/java/com/github/hydos/ginger/engine/api/game/GameData.java rename to src/main/java/com/github/hydos/ginger/engine/common/api/game/GameData.java index 9fe8e3f..a667789 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/game/GameData.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/api/game/GameData.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.api.game; +package com.github.hydos.ginger.engine.common.api.game; import java.util.*; import org.joml.Vector4f; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.elements.GuiTexture; -import com.github.hydos.ginger.engine.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 diff --git a/src/main/java/com/github/hydos/ginger/engine/cameras/Camera.java b/src/main/java/com/github/hydos/ginger/engine/common/cameras/Camera.java similarity index 93% rename from src/main/java/com/github/hydos/ginger/engine/cameras/Camera.java rename to src/main/java/com/github/hydos/ginger/engine/common/cameras/Camera.java index 5e38d5d..0ac7b34 100644 --- a/src/main/java/com/github/hydos/ginger/engine/cameras/Camera.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/cameras/Camera.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.cameras; +package com.github.hydos.ginger.engine.common.cameras; import org.joml.Vector3f; import org.lwjgl.glfw.*; -import com.github.hydos.ginger.engine.elements.objects.Player; -import com.github.hydos.ginger.engine.io.Window; +import com.github.hydos.ginger.engine.common.elements.objects.Player; +import com.github.hydos.ginger.engine.common.io.Window; public class Camera { diff --git a/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java b/src/main/java/com/github/hydos/ginger/engine/common/cameras/FirstPersonCamera.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java rename to src/main/java/com/github/hydos/ginger/engine/common/cameras/FirstPersonCamera.java index 81a2c4f..e887491 100644 --- a/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/cameras/FirstPersonCamera.java @@ -1,9 +1,9 @@ -package com.github.hydos.ginger.engine.cameras; +package com.github.hydos.ginger.engine.common.cameras; import org.joml.Vector3f; -import com.github.hydos.ginger.engine.elements.objects.Player; -import com.github.hydos.ginger.engine.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 { diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/GuiTexture.java b/src/main/java/com/github/hydos/ginger/engine/common/elements/GuiTexture.java similarity index 91% rename from src/main/java/com/github/hydos/ginger/engine/elements/GuiTexture.java rename to src/main/java/com/github/hydos/ginger/engine/common/elements/GuiTexture.java index ed902d8..dfbb62b 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/GuiTexture.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/elements/GuiTexture.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.elements; +package com.github.hydos.ginger.engine.common.elements; import org.joml.Vector2f; diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/buttons/TextureButton.java b/src/main/java/com/github/hydos/ginger/engine/common/elements/buttons/TextureButton.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/elements/buttons/TextureButton.java rename to src/main/java/com/github/hydos/ginger/engine/common/elements/buttons/TextureButton.java index 0617dc0..ea9adb8 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/buttons/TextureButton.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/elements/buttons/TextureButton.java @@ -1,13 +1,13 @@ -package com.github.hydos.ginger.engine.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.elements.GuiTexture; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.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 guiTextureList) diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Light.java b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Light.java similarity index 92% rename from src/main/java/com/github/hydos/ginger/engine/elements/objects/Light.java rename to src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Light.java index f04277c..28928e4 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Light.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Light.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.elements.objects; +package com.github.hydos.ginger.engine.common.elements.objects; import org.joml.Vector3f; diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Player.java similarity index 89% rename from src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java rename to src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Player.java index 8373de2..992ce5b 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/Player.java @@ -1,14 +1,14 @@ -package com.github.hydos.ginger.engine.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.api.GingerRegister; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.main.settings.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.io.Window; +import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; public class Player extends RenderObject implements WorldGenConstants { diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/objects/RenderObject.java b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/RenderObject.java similarity index 92% rename from src/main/java/com/github/hydos/ginger/engine/elements/objects/RenderObject.java rename to src/main/java/com/github/hydos/ginger/engine/common/elements/objects/RenderObject.java index 2b6f74a..b473240 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/objects/RenderObject.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/elements/objects/RenderObject.java @@ -1,8 +1,8 @@ -package com.github.hydos.ginger.engine.elements.objects; +package com.github.hydos.ginger.engine.common.elements.objects; import org.joml.Vector3f; -import com.github.hydos.ginger.engine.render.models.TexturedModel; +import com.github.hydos.ginger.engine.opengl.render.models.TexturedModel; public class RenderObject { diff --git a/src/main/java/com/github/hydos/ginger/engine/fbo/FboCallbackHandler.java b/src/main/java/com/github/hydos/ginger/engine/common/fbo/FboCallbackHandler.java similarity index 73% rename from src/main/java/com/github/hydos/ginger/engine/fbo/FboCallbackHandler.java rename to src/main/java/com/github/hydos/ginger/engine/common/fbo/FboCallbackHandler.java index e4a92de..8281895 100644 --- a/src/main/java/com/github/hydos/ginger/engine/fbo/FboCallbackHandler.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/fbo/FboCallbackHandler.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.fbo; +package com.github.hydos.ginger.engine.common.fbo; public abstract class FboCallbackHandler { diff --git a/src/main/java/com/github/hydos/ginger/engine/font/Character.java b/src/main/java/com/github/hydos/ginger/engine/common/font/Character.java similarity index 98% rename from src/main/java/com/github/hydos/ginger/engine/font/Character.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/Character.java index 4bd60f5..daf9fea 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/Character.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/Character.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; /** Simple data structure class holding information about a certain glyph in the * font texture atlas. All sizes are for a font-size of 1. */ diff --git a/src/main/java/com/github/hydos/ginger/engine/font/FontType.java b/src/main/java/com/github/hydos/ginger/engine/common/font/FontType.java similarity index 96% rename from src/main/java/com/github/hydos/ginger/engine/font/FontType.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/FontType.java index 6b9d2f7..f98d74c 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/FontType.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/FontType.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; /** Represents a font. It holds the font's texture atlas as well as having the * ability to create the quad vertices for any text using this font. */ diff --git a/src/main/java/com/github/hydos/ginger/engine/font/GUIText.java b/src/main/java/com/github/hydos/ginger/engine/common/font/GUIText.java similarity index 99% rename from src/main/java/com/github/hydos/ginger/engine/font/GUIText.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/GUIText.java index 26ba47d..13ca683 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/GUIText.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/GUIText.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import org.joml.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/font/Line.java b/src/main/java/com/github/hydos/ginger/engine/common/font/Line.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/font/Line.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/Line.java index acbf30d..d610a5e 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/Line.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/Line.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import java.util.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/font/MetaFile.java b/src/main/java/com/github/hydos/ginger/engine/common/font/MetaFile.java similarity index 98% rename from src/main/java/com/github/hydos/ginger/engine/font/MetaFile.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/MetaFile.java index 8c95834..42646e4 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/MetaFile.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/MetaFile.java @@ -1,9 +1,9 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import java.io.*; import java.util.*; -import com.github.hydos.ginger.engine.io.Window; +import com.github.hydos.ginger.engine.common.io.Window; /** Provides functionality for getting the values from a font file. */ public class MetaFile diff --git a/src/main/java/com/github/hydos/ginger/engine/font/TextMaster.java b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMaster.java similarity index 69% rename from src/main/java/com/github/hydos/ginger/engine/font/TextMaster.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/TextMaster.java index dee98e5..0aad404 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/TextMaster.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMaster.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import java.util.*; -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; +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.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 textBatch = texts.get(font); if (textBatch == null) @@ -46,10 +46,10 @@ public class TextMaster public static void render(GUIText buildText) { Map> oldTexts = texts; - List oldFontText = texts.get(Ginger.getInstance().globalFont); + List 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; } } diff --git a/src/main/java/com/github/hydos/ginger/engine/font/TextMeshCreator.java b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshCreator.java similarity index 98% rename from src/main/java/com/github/hydos/ginger/engine/font/TextMeshCreator.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshCreator.java index 2d901b1..83e01df 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/TextMeshCreator.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshCreator.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import java.util.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/font/TextMeshData.java b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshData.java similarity index 91% rename from src/main/java/com/github/hydos/ginger/engine/font/TextMeshData.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshData.java index dc1d564..ae95597 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/TextMeshData.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/TextMeshData.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; /** Stores the vertex data for all the quads on which a text will be rendered. */ public class TextMeshData diff --git a/src/main/java/com/github/hydos/ginger/engine/font/Word.java b/src/main/java/com/github/hydos/ginger/engine/common/font/Word.java similarity index 94% rename from src/main/java/com/github/hydos/ginger/engine/font/Word.java rename to src/main/java/com/github/hydos/ginger/engine/common/font/Word.java index c1a58c9..fb55f06 100644 --- a/src/main/java/com/github/hydos/ginger/engine/font/Word.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/font/Word.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.font; +package com.github.hydos.ginger.engine.common.font; import java.util.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/io/Window.java b/src/main/java/com/github/hydos/ginger/engine/common/io/Window.java similarity index 96% rename from src/main/java/com/github/hydos/ginger/engine/io/Window.java rename to src/main/java/com/github/hydos/ginger/engine/common/io/Window.java index 18baced..c3827ec 100644 --- a/src/main/java/com/github/hydos/ginger/engine/io/Window.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/io/Window.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.io; +package com.github.hydos.ginger.engine.common.io; import java.nio.*; @@ -7,8 +7,8 @@ import org.lwjgl.BufferUtils; import org.lwjgl.glfw.*; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.api.Ginger; -import com.github.hydos.ginger.engine.render.texture.Image; +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(); } diff --git a/src/main/java/com/github/hydos/ginger/engine/math/Maths.java b/src/main/java/com/github/hydos/ginger/engine/common/math/Maths.java similarity index 95% rename from src/main/java/com/github/hydos/ginger/engine/math/Maths.java rename to src/main/java/com/github/hydos/ginger/engine/common/math/Maths.java index f4a2f50..fa8902d 100644 --- a/src/main/java/com/github/hydos/ginger/engine/math/Maths.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/math/Maths.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.math; +package com.github.hydos.ginger.engine.common.math; import java.lang.Math; import org.joml.*; -import com.github.hydos.ginger.engine.cameras.Camera; +import com.github.hydos.ginger.engine.common.cameras.Camera; public class Maths { diff --git a/src/main/java/com/github/hydos/ginger/engine/common/obj/Material.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/Material.java new file mode 100644 index 0000000..bd21501 --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/Material.java @@ -0,0 +1,5 @@ +package com.github.hydos.ginger.engine.common.obj; + +public class Material +{ +} diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/Mesh.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/Mesh.java similarity index 93% rename from src/main/java/com/github/hydos/ginger/engine/obj/Mesh.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/Mesh.java index d319a90..2c630b6 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/Mesh.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/Mesh.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.obj; +package com.github.hydos.ginger.engine.common.obj; public class Mesh { diff --git a/src/main/java/com/github/hydos/ginger/engine/common/obj/ModelLoader.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/ModelLoader.java new file mode 100644 index 0000000..d642bd2 --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/ModelLoader.java @@ -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)); + } +} diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/OBJFileLoader.java similarity index 98% rename from src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/OBJFileLoader.java index 93ad164..c70cbc0 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/OBJFileLoader.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.obj; +package com.github.hydos.ginger.engine.common.obj; import org.joml.*; import org.lwjgl.assimp.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/Vertex.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/Vertex.java similarity index 96% rename from src/main/java/com/github/hydos/ginger/engine/obj/Vertex.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/Vertex.java index c488f9a..e06901e 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/Vertex.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/Vertex.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.obj; +package com.github.hydos.ginger.engine.common.obj; import org.joml.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/normals/ModelDataNM.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/ModelDataNM.java similarity index 93% rename from src/main/java/com/github/hydos/ginger/engine/obj/normals/ModelDataNM.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/normals/ModelDataNM.java index 2e3c407..2dea790 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/normals/ModelDataNM.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/ModelDataNM.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.obj.normals; +package com.github.hydos.ginger.engine.common.obj.normals; public class ModelDataNM { diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/normals/NormalMappedObjLoader.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/NormalMappedObjLoader.java similarity index 95% rename from src/main/java/com/github/hydos/ginger/engine/obj/normals/NormalMappedObjLoader.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/normals/NormalMappedObjLoader.java index 3800f5c..5058170 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/normals/NormalMappedObjLoader.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/NormalMappedObjLoader.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.obj.normals; +package com.github.hydos.ginger.engine.common.obj.normals; import java.io.*; import java.util.*; import org.joml.*; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.utils.Loader; +import com.github.hydos.ginger.engine.opengl.render.models.RawModel; +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 vertices, diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/normals/VertexNM.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/VertexNM.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/obj/normals/VertexNM.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/normals/VertexNM.java index 3a12da0..701d2c7 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/normals/VertexNM.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/normals/VertexNM.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.obj.normals; +package com.github.hydos.ginger.engine.common.obj.normals; import java.util.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/ShapeMesh.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/ShapeMesh.java new file mode 100644 index 0000000..dce7dda --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/ShapeMesh.java @@ -0,0 +1 @@ +package com.github.hydos.ginger.engine.common.obj.shapes; diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/shapes/StaticCube.java b/src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/StaticCube.java similarity index 93% rename from src/main/java/com/github/hydos/ginger/engine/obj/shapes/StaticCube.java rename to src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/StaticCube.java index 618dd06..532e4fc 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/shapes/StaticCube.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/obj/shapes/StaticCube.java @@ -1,6 +1,6 @@ -package com.github.hydos.ginger.engine.obj.shapes; +package com.github.hydos.ginger.engine.common.obj.shapes; -import com.github.hydos.ginger.engine.obj.Mesh; +import com.github.hydos.ginger.engine.common.obj.Mesh; public class StaticCube { diff --git a/src/main/java/com/github/hydos/ginger/engine/screen/Screen.java b/src/main/java/com/github/hydos/ginger/engine/common/screen/Screen.java similarity index 65% rename from src/main/java/com/github/hydos/ginger/engine/screen/Screen.java rename to src/main/java/com/github/hydos/ginger/engine/common/screen/Screen.java index 931a24b..c60d227 100644 --- a/src/main/java/com/github/hydos/ginger/engine/screen/Screen.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/screen/Screen.java @@ -1,8 +1,8 @@ -package com.github.hydos.ginger.engine.screen; +package com.github.hydos.ginger.engine.common.screen; import java.util.List; -import com.github.hydos.ginger.engine.elements.GuiTexture; +import com.github.hydos.ginger.engine.common.elements.GuiTexture; public abstract class Screen { diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/Material.java b/src/main/java/com/github/hydos/ginger/engine/obj/Material.java deleted file mode 100644 index cc7f5f3..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/obj/Material.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.hydos.ginger.engine.obj; - -public class Material -{ -} diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java b/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java deleted file mode 100644 index 8481a00..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.github.hydos.ginger.engine.obj; - -import com.github.hydos.ginger.engine.obj.shapes.StaticCube; -import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.engine.render.texture.ModelTexture; -import com.github.hydos.ginger.engine.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)); - } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/shapes/ShapeMesh.java b/src/main/java/com/github/hydos/ginger/engine/obj/shapes/ShapeMesh.java deleted file mode 100644 index dad0279..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/obj/shapes/ShapeMesh.java +++ /dev/null @@ -1 +0,0 @@ -package com.github.hydos.ginger.engine.obj.shapes; diff --git a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java similarity index 79% rename from src/main/java/com/github/hydos/ginger/engine/api/Ginger.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java index 2d0bcba..1120861 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java @@ -1,10 +1,11 @@ -package com.github.hydos.ginger.engine.api; +package com.github.hydos.ginger.engine.opengl.api; 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; +<<<<<<< HEAD:src/main/java/com/github/hydos/ginger/engine/api/Ginger.java import com.github.hydos.ginger.engine.api.game.*; import com.github.hydos.ginger.engine.elements.buttons.TextureButton; import com.github.hydos.ginger.engine.elements.objects.Player; @@ -16,10 +17,24 @@ import com.github.hydos.ginger.engine.render.MasterRenderer; import com.github.hydos.ginger.engine.render.tools.MousePicker; import com.github.hydos.ginger.engine.screen.Screen; import com.github.hydos.ginger.engine.utils.Loader; +======= +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.font.*; +import com.github.hydos.ginger.engine.common.io.Window; +import com.github.hydos.ginger.engine.common.screen.Screen; +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.utils.GlLoader; +import com.github.hydos.multithreading.GingerThreading; +>>>>>>> liteCraft:src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java -public class Ginger +public class GingerGL { - private static Ginger INSTANCE; + private static GingerGL INSTANCE; private GingerRegister registry; public MousePicker picker; public FontType globalFont; @@ -40,10 +55,9 @@ public class Ginger { Window.stop(); PostProcessing.cleanUp(); - ParticleMaster.cleanUp(); registry.masterRenderer.cleanUp(); TextMaster.cleanUp(); - Loader.cleanUp(); + GlLoader.cleanUp(); } public void openScreen(Screen screen) @@ -89,7 +103,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); @@ -109,7 +122,6 @@ public class Ginger registry.masterRenderer = masterRenderer; picker = new MousePicker(game.data.camera, masterRenderer.getProjectionMatrix()); PostProcessing.init(); - ParticleMaster.init(masterRenderer.getProjectionMatrix()); } public void startGameLoop() @@ -129,11 +141,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; } } \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/api/GingerUtils.java b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerUtils.java similarity index 58% rename from src/main/java/com/github/hydos/ginger/engine/api/GingerUtils.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerUtils.java index 4ccd2de..23e00fe 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/GingerUtils.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerUtils.java @@ -1,11 +1,11 @@ -package com.github.hydos.ginger.engine.api; +package com.github.hydos.ginger.engine.opengl.api; -import com.github.hydos.ginger.engine.font.TextMaster; -import com.github.hydos.ginger.engine.obj.ModelLoader; -import com.github.hydos.ginger.engine.obj.normals.NormalMappedObjLoader; -import com.github.hydos.ginger.engine.render.MasterRenderer; -import com.github.hydos.ginger.engine.render.models.*; -import com.github.hydos.ginger.engine.render.texture.ModelTexture; +import com.github.hydos.ginger.engine.common.font.TextMaster; +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.render.MasterRenderer; +import com.github.hydos.ginger.engine.opengl.render.models.*; +import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture; public class GingerUtils { diff --git a/src/main/java/com/github/hydos/ginger/engine/api/ResourceManager.java b/src/main/java/com/github/hydos/ginger/engine/opengl/api/ResourceManager.java similarity index 80% rename from src/main/java/com/github/hydos/ginger/engine/api/ResourceManager.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/api/ResourceManager.java index 17095b4..46a611a 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/ResourceManager.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/api/ResourceManager.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.api; +package com.github.hydos.ginger.engine.opengl.api; /** * make your own resource manager if you want! diff --git a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastChanger.java b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastChanger.java similarity index 80% rename from src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastChanger.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastChanger.java index e836fb1..1e8b5bd 100644 --- a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastChanger.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastChanger.java @@ -1,8 +1,8 @@ -package com.github.hydos.ginger.engine.postprocessing; +package com.github.hydos.ginger.engine.opengl.postprocessing; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.fbo.FboCallbackHandler; +import com.github.hydos.ginger.engine.common.fbo.FboCallbackHandler; public class ContrastChanger extends FboCallbackHandler { diff --git a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastShader.java similarity index 74% rename from src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastShader.java index 8323cc8..d602c59 100644 --- a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ContrastShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ContrastShader.java @@ -1,6 +1,6 @@ -package com.github.hydos.ginger.engine.postprocessing; +package com.github.hydos.ginger.engine.opengl.postprocessing; -import com.github.hydos.ginger.engine.render.shaders.ShaderProgram; +import com.github.hydos.ginger.engine.opengl.render.shaders.ShaderProgram; public class ContrastShader extends ShaderProgram { diff --git a/src/main/java/com/github/hydos/ginger/engine/postprocessing/Fbo.java b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/Fbo.java similarity index 95% rename from src/main/java/com/github/hydos/ginger/engine/postprocessing/Fbo.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/Fbo.java index 73d53ec..38bd3de 100644 --- a/src/main/java/com/github/hydos/ginger/engine/postprocessing/Fbo.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/Fbo.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.postprocessing; +package com.github.hydos.ginger.engine.opengl.postprocessing; import static org.lwjgl.opengl.ARBFramebufferObject.*; import static org.lwjgl.opengl.GL11.*; @@ -8,8 +8,8 @@ import java.nio.ByteBuffer; import org.lwjgl.glfw.*; import org.lwjgl.system.Callback; -import com.github.hydos.ginger.engine.fbo.FboCallbackHandler; -import com.github.hydos.ginger.engine.io.Window; +import com.github.hydos.ginger.engine.common.fbo.FboCallbackHandler; +import com.github.hydos.ginger.engine.common.io.Window; public class Fbo { diff --git a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ImageRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ImageRenderer.java similarity index 89% rename from src/main/java/com/github/hydos/ginger/engine/postprocessing/ImageRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ImageRenderer.java index 7ec5876..d4cf3c0 100644 --- a/src/main/java/com/github/hydos/ginger/engine/postprocessing/ImageRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/ImageRenderer.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.postprocessing; +package com.github.hydos.ginger.engine.opengl.postprocessing; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/github/hydos/ginger/engine/postprocessing/PostProcessing.java b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/PostProcessing.java similarity index 76% rename from src/main/java/com/github/hydos/ginger/engine/postprocessing/PostProcessing.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/PostProcessing.java index b23993c..d4eaa23 100644 --- a/src/main/java/com/github/hydos/ginger/engine/postprocessing/PostProcessing.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/postprocessing/PostProcessing.java @@ -1,9 +1,9 @@ -package com.github.hydos.ginger.engine.postprocessing; +package com.github.hydos.ginger.engine.opengl.postprocessing; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.utils.Loader; +import com.github.hydos.ginger.engine.opengl.render.models.RawModel; +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(); } diff --git a/src/main/java/com/github/hydos/ginger/engine/render/MasterRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/MasterRenderer.java similarity index 89% rename from src/main/java/com/github/hydos/ginger/engine/render/MasterRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/MasterRenderer.java index ebeb2ec..ebd0801 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/MasterRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/MasterRenderer.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render; +package com.github.hydos.ginger.engine.opengl.render; import java.lang.Math; import java.util.*; @@ -8,14 +8,14 @@ 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.cameras.Camera; -import com.github.hydos.ginger.engine.elements.GuiTexture; -import com.github.hydos.ginger.engine.elements.objects.*; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.engine.render.renderers.*; -import com.github.hydos.ginger.engine.render.shaders.*; -import com.github.hydos.ginger.engine.shadow.ShadowMapMasterRenderer; +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.*; +import com.github.hydos.ginger.engine.opengl.shadow.ShadowMapMasterRenderer; public class MasterRenderer { diff --git a/src/main/java/com/github/hydos/ginger/engine/opengl/render/Renderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/Renderer.java new file mode 100644 index 0000000..963ccad --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/Renderer.java @@ -0,0 +1,5 @@ +package com.github.hydos.ginger.engine.opengl.render; + +public abstract class Renderer +{ +} \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/render/models/RawModel.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/models/RawModel.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/render/models/RawModel.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/models/RawModel.java index b4203be..4cba450 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/models/RawModel.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/models/RawModel.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.models; +package com.github.hydos.ginger.engine.opengl.render.models; public class RawModel { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/models/TexturedModel.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/models/TexturedModel.java similarity index 70% rename from src/main/java/com/github/hydos/ginger/engine/render/models/TexturedModel.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/models/TexturedModel.java index a1118f9..708acfd 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/models/TexturedModel.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/models/TexturedModel.java @@ -1,6 +1,6 @@ -package com.github.hydos.ginger.engine.render.models; +package com.github.hydos.ginger.engine.opengl.render.models; -import com.github.hydos.ginger.engine.render.texture.ModelTexture; +import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture; public class TexturedModel { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/FontRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/FontRenderer.java similarity index 83% rename from src/main/java/com/github/hydos/ginger/engine/render/renderers/FontRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/FontRenderer.java index 2cd5617..90c4629 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/FontRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/FontRenderer.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.render.renderers; +package com.github.hydos.ginger.engine.opengl.render.renderers; import java.util.*; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.font.*; -import com.github.hydos.ginger.engine.render.Renderer; -import com.github.hydos.ginger.engine.render.shaders.FontShader; +import com.github.hydos.ginger.engine.common.font.*; +import com.github.hydos.ginger.engine.opengl.render.Renderer; +import com.github.hydos.ginger.engine.opengl.render.shaders.FontShader; public class FontRenderer extends Renderer { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/GuiRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/GuiRenderer.java similarity index 70% rename from src/main/java/com/github/hydos/ginger/engine/render/renderers/GuiRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/GuiRenderer.java index 8da8d0d..4e76b79 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/GuiRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/GuiRenderer.java @@ -1,16 +1,16 @@ -package com.github.hydos.ginger.engine.render.renderers; +package com.github.hydos.ginger.engine.opengl.render.renderers; import java.util.List; import org.joml.Matrix4f; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.elements.GuiTexture; -import com.github.hydos.ginger.engine.math.Maths; -import com.github.hydos.ginger.engine.render.Renderer; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.render.shaders.GuiShader; -import com.github.hydos.ginger.engine.utils.Loader; +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.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() diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/NormalMappingRenderer.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/NormalMappingRenderer.java index f5d9033..01de0cd 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/NormalMappingRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/NormalMappingRenderer.java @@ -1,18 +1,18 @@ -package com.github.hydos.ginger.engine.render.renderers; +package com.github.hydos.ginger.engine.opengl.render.renderers; import java.util.*; import org.joml.*; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.elements.objects.*; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.math.Maths; -import com.github.hydos.ginger.engine.render.*; -import com.github.hydos.ginger.engine.render.models.*; -import com.github.hydos.ginger.engine.render.shaders.NormalMappingShader; -import com.github.hydos.ginger.engine.render.texture.ModelTexture; +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; +import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture; public class NormalMappingRenderer extends Renderer { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/ObjectRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/ObjectRenderer.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/render/renderers/ObjectRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/ObjectRenderer.java index 982856a..2a81add 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/ObjectRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/ObjectRenderer.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.renderers; +package com.github.hydos.ginger.engine.opengl.render.renderers; import java.util.*; @@ -6,14 +6,14 @@ import org.joml.Matrix4f; import org.lwjgl.opengl.*; import com.github.halotroop.litecraft.types.block.BlockInstance; -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.render.*; -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; +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; +import com.github.hydos.ginger.engine.opengl.render.texture.ModelTexture; public class ObjectRenderer extends Renderer { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/SkyboxRenderer.java similarity index 79% rename from src/main/java/com/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/SkyboxRenderer.java index cd43b77..e884f33 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/SkyboxRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/renderers/SkyboxRenderer.java @@ -1,13 +1,13 @@ -package com.github.hydos.ginger.engine.render.renderers; +package com.github.hydos.ginger.engine.opengl.render.renderers; import org.joml.Matrix4f; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.render.Renderer; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.render.shaders.SkyboxShader; -import com.github.hydos.ginger.engine.utils.Loader; +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.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); diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/FontShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/FontShader.java similarity index 92% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/FontShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/FontShader.java index 2d9de48..9e01c00 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/FontShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/FontShader.java @@ -1,8 +1,8 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import org.joml.*; -import com.github.hydos.ginger.engine.font.GUIText; +import com.github.hydos.ginger.engine.common.font.GUIText; public class FontShader extends ShaderProgram { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/GuiShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/GuiShader.java similarity index 91% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/GuiShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/GuiShader.java index c8cfeef..7f767db 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/GuiShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/GuiShader.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import org.joml.Matrix4f; diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/NormalMappingShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/NormalMappingShader.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/NormalMappingShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/NormalMappingShader.java index 7313cc6..053f523 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/NormalMappingShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/NormalMappingShader.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import java.util.List; import org.joml.*; -import com.github.hydos.ginger.engine.elements.objects.Light; +import com.github.hydos.ginger.engine.common.elements.objects.Light; public class NormalMappingShader extends ShaderProgram { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/ParticleShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ParticleShader.java similarity index 94% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/ParticleShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ParticleShader.java index 1b05724..fdb2156 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/ParticleShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ParticleShader.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import org.joml.Matrix4f; diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/ShaderProgram.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ShaderProgram.java similarity index 98% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/ShaderProgram.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ShaderProgram.java index c50d5eb..43c5f20 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/ShaderProgram.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/ShaderProgram.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import java.io.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/SkyboxShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/SkyboxShader.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/SkyboxShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/SkyboxShader.java index 6d455cc..c13519a 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/SkyboxShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/SkyboxShader.java @@ -1,9 +1,9 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import org.joml.Matrix4f; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.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 { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/StaticShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/StaticShader.java similarity index 92% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/StaticShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/StaticShader.java index 1434c01..2738b9e 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/StaticShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/StaticShader.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import java.util.List; import org.joml.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.elements.objects.Light; -import com.github.hydos.ginger.engine.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 { diff --git a/src/main/java/com/github/hydos/ginger/engine/render/shaders/TerrainShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/TerrainShader.java similarity index 94% rename from src/main/java/com/github/hydos/ginger/engine/render/shaders/TerrainShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/TerrainShader.java index 3a24193..5c7e370 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/shaders/TerrainShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/shaders/TerrainShader.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.render.shaders; +package com.github.hydos.ginger.engine.opengl.render.shaders; import java.util.List; import org.joml.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.elements.objects.Light; -import com.github.hydos.ginger.engine.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 { diff --git a/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ColorDepth.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ColorDepth.java new file mode 100644 index 0000000..987b40d --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ColorDepth.java @@ -0,0 +1,6 @@ +package com.github.hydos.ginger.engine.opengl.render.texture; + +public enum ColorDepth +{ + R, RG, RGB, RGBA +} diff --git a/src/main/java/com/github/hydos/ginger/engine/render/texture/Image.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/Image.java similarity index 77% rename from src/main/java/com/github/hydos/ginger/engine/render/texture/Image.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/Image.java index 136aeb3..5791e67 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/texture/Image.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/Image.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.texture; +package com.github.hydos.ginger.engine.opengl.render.texture; import static org.lwjgl.stb.STBImage.*; import static org.lwjgl.system.MemoryStack.stackPush; @@ -8,7 +8,7 @@ import java.nio.*; import org.lwjgl.system.MemoryStack; -import com.github.hydos.ginger.engine.render.tools.IOUtil; +import com.github.hydos.ginger.engine.opengl.render.tools.IOUtil; public class Image { @@ -34,20 +34,22 @@ public class Image img = stbi_load_from_memory(imageBuffer, w, h, comp, 0); if (img == null) { throw new RuntimeException("Failed to load image: " + stbi_failure_reason()); } - return new Image(w.get(0), h.get(0), img, comp); + return new Image(w.get(0), h.get(0), img, comp, imagePath); } } private ByteBuffer image; private int width, height; private IntBuffer comp; + private String location; - Image(int width, int heigh, ByteBuffer image, IntBuffer comp) + Image(int width, int heigh, ByteBuffer image, IntBuffer comp, String location) { this.image = image; this.height = heigh; this.width = width; this.comp = comp; + this.location = location; } public int getHeight() @@ -61,4 +63,8 @@ public class Image public IntBuffer getComp() { return comp; } + + public String getLocation() { + return location; + } } \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ModelTexture.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ModelTexture.java index 935c102..3146525 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/texture/ModelTexture.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.texture; +package com.github.hydos.ginger.engine.opengl.render.texture; import org.lwjgl.opengl.*; diff --git a/src/main/java/com/github/hydos/ginger/engine/render/tools/IOUtil.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/IOUtil.java similarity index 94% rename from src/main/java/com/github/hydos/ginger/engine/render/tools/IOUtil.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/IOUtil.java index 87c03d7..cd5a099 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/tools/IOUtil.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/IOUtil.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.render.tools; +package com.github.hydos.ginger.engine.opengl.render.tools; import static org.lwjgl.BufferUtils.createByteBuffer; diff --git a/src/main/java/com/github/hydos/ginger/engine/render/tools/MousePicker.java b/src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/MousePicker.java similarity index 92% rename from src/main/java/com/github/hydos/ginger/engine/render/tools/MousePicker.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/MousePicker.java index d35c06c..12407a9 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/tools/MousePicker.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/render/tools/MousePicker.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.render.tools; +package com.github.hydos.ginger.engine.opengl.render.tools; import org.joml.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.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 { diff --git a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowBox.java b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowBox.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/shadow/ShadowBox.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowBox.java index d5efd43..9108fce 100644 --- a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowBox.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowBox.java @@ -1,12 +1,12 @@ -package com.github.hydos.ginger.engine.shadow; +package com.github.hydos.ginger.engine.opengl.shadow; import java.lang.Math; import org.joml.*; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.render.MasterRenderer; +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 * shadows (basically represents the orthographic projection area for the shadow diff --git a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowFrameBuffer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowFrameBuffer.java similarity index 97% rename from src/main/java/com/github/hydos/ginger/engine/shadow/ShadowFrameBuffer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowFrameBuffer.java index 3db0722..14d1120 100644 --- a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowFrameBuffer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowFrameBuffer.java @@ -1,10 +1,10 @@ -package com.github.hydos.ginger.engine.shadow; +package com.github.hydos.ginger.engine.opengl.shadow; import java.nio.ByteBuffer; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.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 diff --git a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapEntityRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapEntityRenderer.java similarity index 89% rename from src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapEntityRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapEntityRenderer.java index 91cb946..70e021e 100644 --- a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapEntityRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapEntityRenderer.java @@ -1,14 +1,14 @@ -package com.github.hydos.ginger.engine.shadow; +package com.github.hydos.ginger.engine.opengl.shadow; import java.util.*; import org.joml.Matrix4f; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.elements.objects.RenderObject; -import com.github.hydos.ginger.engine.math.Maths; -import com.github.hydos.ginger.engine.render.MasterRenderer; -import com.github.hydos.ginger.engine.render.models.*; +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.*; public class ShadowMapEntityRenderer { diff --git a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapMasterRenderer.java similarity index 96% rename from src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapMasterRenderer.java index 06f0014..0e27772 100644 --- a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowMapMasterRenderer.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowMapMasterRenderer.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.shadow; +package com.github.hydos.ginger.engine.opengl.shadow; import java.lang.Math; import java.util.*; @@ -6,9 +6,9 @@ import java.util.*; import org.joml.*; import org.lwjgl.opengl.GL11; -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.elements.objects.*; -import com.github.hydos.ginger.engine.render.models.TexturedModel; +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 * carry out the shadow render pass, i.e. rendering the scene to the shadow map diff --git a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowShader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowShader.java similarity index 84% rename from src/main/java/com/github/hydos/ginger/engine/shadow/ShadowShader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowShader.java index 63cb6e3..99b0ace 100644 --- a/src/main/java/com/github/hydos/ginger/engine/shadow/ShadowShader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/shadow/ShadowShader.java @@ -1,8 +1,8 @@ -package com.github.hydos.ginger.engine.shadow; +package com.github.hydos.ginger.engine.opengl.shadow; import org.joml.Matrix4f; -import com.github.hydos.ginger.engine.render.shaders.ShaderProgram; +import com.github.hydos.ginger.engine.opengl.render.shaders.ShaderProgram; public class ShadowShader extends ShaderProgram { diff --git a/src/main/java/com/github/hydos/ginger/engine/utils/Loader.java b/src/main/java/com/github/hydos/ginger/engine/opengl/utils/GlLoader.java similarity index 82% rename from src/main/java/com/github/hydos/ginger/engine/utils/Loader.java rename to src/main/java/com/github/hydos/ginger/engine/opengl/utils/GlLoader.java index 4b46b09..ed35c8a 100644 --- a/src/main/java/com/github/hydos/ginger/engine/utils/Loader.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/utils/GlLoader.java @@ -1,4 +1,4 @@ -package com.github.hydos.ginger.engine.utils; +package com.github.hydos.ginger.engine.opengl.utils; import java.nio.*; import java.util.*; @@ -6,12 +6,12 @@ import java.util.*; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.*; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.render.texture.*; -import com.github.hydos.ginger.engine.terrain.TerrainTexture; +import com.github.halotroop.litecraft.types.block.*; +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.*; -public class Loader +public class GlLoader { private static List vaos = new ArrayList(); private static List vbos = new ArrayList(); @@ -99,12 +99,49 @@ 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); } + + public static int createBlockAtlas() + { + int width = 16; + int height = 16; + //Prepare the atlas texture and gen it + int atlasId = GL40.glGenTextures(); + //Bind it to openGL + GL40.glBindTexture(GL40.GL_TEXTURE_2D, atlasId); + //Apply the settings for the texture + GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MIN_FILTER, GL40.GL_NEAREST); + GL40.glTexParameteri(GL40.GL_TEXTURE_2D, GL40.GL_TEXTURE_MAG_FILTER, GL40.GL_NEAREST); + //Fill the image with blank image data + GL40.glTexImage2D(GL40.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width*2, height*2, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); + + long maxX = Math.round(Math.sqrt(Blocks.blocks.size())); + int currentX = 0; + int currentY = 0; + for(Block block: Blocks.blocks) { + //just in case + + if(!block.texture.equals("DONTLOAD")) { + System.out.println(block.texture); + block.updateBlockModelData(); + if(currentX > maxX) { + currentX = 0; + currentY--; + } + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, + currentX*width, currentY*height, + width, height, + GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, + block.model.getTexture().getTexture().getImage() + ); + currentX++; + } + } + return atlasId; + } + public static int loadTextureDirectly(String path) { int textureID = GL11.glGenTextures(); diff --git a/src/main/java/com/github/hydos/ginger/engine/particle/InsertionSort.java b/src/main/java/com/github/hydos/ginger/engine/particle/InsertionSort.java deleted file mode 100644 index 72efe16..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/particle/InsertionSort.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.github.hydos.ginger.engine.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 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 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); - } -} \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/particle/Particle.java b/src/main/java/com/github/hydos/ginger/engine/particle/Particle.java deleted file mode 100644 index bebed35..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/particle/Particle.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.github.hydos.ginger.engine.particle; - -import java.lang.Math; - -import org.joml.*; - -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.main.settings.Constants; - -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); - } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleMaster.java b/src/main/java/com/github/hydos/ginger/engine/particle/ParticleMaster.java deleted file mode 100644 index 0bd7a21..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleMaster.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.github.hydos.ginger.engine.particle; - -import java.util.*; -import java.util.Map.Entry; - -import org.joml.Matrix4f; - -import com.github.hydos.ginger.engine.cameras.Camera; -import com.github.hydos.ginger.engine.render.renderers.ParticleRenderer; - -public class ParticleMaster -{ - private static Map> particles = new HashMap>(); - private static ParticleRenderer particleRenderer; - - public static void addParticle(Particle particle) - { - List list = particles.get(particle.getTexture()); - if (list == null) - { - list = new ArrayList(); - 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>> mapIterator = particles.entrySet().iterator(); - while (mapIterator.hasNext()) - { - List list = mapIterator.next().getValue(); - Iterator 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); - } - } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleSystem.java b/src/main/java/com/github/hydos/ginger/engine/particle/ParticleSystem.java deleted file mode 100644 index 3d11401..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleSystem.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.github.hydos.ginger.engine.particle; - -import java.lang.Math; -import java.util.Random; - -import org.joml.*; - -import com.github.hydos.ginger.engine.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; } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleTexture.java b/src/main/java/com/github/hydos/ginger/engine/particle/ParticleTexture.java deleted file mode 100644 index 9776e89..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/particle/ParticleTexture.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.github.hydos.ginger.engine.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; } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/render/Renderer.java b/src/main/java/com/github/hydos/ginger/engine/render/Renderer.java deleted file mode 100644 index dedd6d9..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/render/Renderer.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.hydos.ginger.engine.render; - -public abstract class Renderer -{ -} \ No newline at end of file diff --git a/src/main/java/com/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java b/src/main/java/com/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java deleted file mode 100644 index 8a74fa6..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/render/renderers/ParticleRenderer.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.github.hydos.ginger.engine.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.cameras.Camera; -import com.github.hydos.ginger.engine.math.Maths; -import com.github.hydos.ginger.engine.particle.*; -import com.github.hydos.ginger.engine.render.Renderer; -import com.github.hydos.ginger.engine.render.models.RawModel; -import com.github.hydos.ginger.engine.render.shaders.ParticleShader; -import com.github.hydos.ginger.engine.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> particles, Camera camera) - { - Matrix4f viewMatrix = Maths.createViewMatrix(camera); - prepare(); - for (ParticleTexture texture : particles.keySet()) - { - bindTexture(texture); - List 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(); - } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/render/texture/ColorDepth.java b/src/main/java/com/github/hydos/ginger/engine/render/texture/ColorDepth.java deleted file mode 100644 index 8ae8065..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/render/texture/ColorDepth.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.hydos.ginger.engine.render.texture; - -public enum ColorDepth -{ - R, RG, RGB, RGBA -} diff --git a/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexture.java b/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexture.java deleted file mode 100644 index f5364f7..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexture.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.hydos.ginger.engine.terrain; - -public class TerrainTexture -{ - private int textureID; - - public TerrainTexture(int textureID) - { - super(); - this.textureID = textureID; - } - - public int getTextureID() - { return textureID; } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexturePack.java b/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexturePack.java deleted file mode 100644 index 85fd643..0000000 --- a/src/main/java/com/github/hydos/ginger/engine/terrain/TerrainTexturePack.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.github.hydos.ginger.engine.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; } -} diff --git a/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerV.java b/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerV.java new file mode 100644 index 0000000..b34d023 --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/vulkan/api/GingerV.java @@ -0,0 +1,5 @@ +package com.github.hydos.ginger.engine.vulkan.api; + +public class GingerV { + +} diff --git a/src/main/java/com/github/hydos/ginger/engine/vulkan/utils/VLoader.java b/src/main/java/com/github/hydos/ginger/engine/vulkan/utils/VLoader.java new file mode 100644 index 0000000..f3322ef --- /dev/null +++ b/src/main/java/com/github/hydos/ginger/engine/vulkan/utils/VLoader.java @@ -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 { + +} diff --git a/src/main/java/com/github/hydos/ginger/main/tools/GSceneBuilder.java b/src/main/java/com/github/hydos/ginger/main/tools/GSceneBuilder.java deleted file mode 100644 index 93288e7..0000000 --- a/src/main/java/com/github/hydos/ginger/main/tools/GSceneBuilder.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.hydos.ginger.main.tools; - -public class GSceneBuilder -{ - /** The class for turning GScene files into the engine parts in java */ -} diff --git a/src/main/java/com/github/hydos/ginger/voxelutils/BlockMesher.java b/src/main/java/com/github/hydos/ginger/voxelutils/BlockMesher.java deleted file mode 100644 index e5ec261..0000000 --- a/src/main/java/com/github/hydos/ginger/voxelutils/BlockMesher.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.hydos.ginger.voxelutils; - -public class BlockMesher -{ - //TODO: supercoder i ask you that you figure a way to cull inner faces and not just whole blocks :) -} diff --git a/src/main/java/com/github/hydos/multithreading/GingerThreading.java b/src/main/java/com/github/hydos/multithreading/GingerThreading.java index 3940b7c..b68054d 100644 --- a/src/main/java/com/github/hydos/multithreading/GingerThreading.java +++ b/src/main/java/com/github/hydos/multithreading/GingerThreading.java @@ -3,7 +3,7 @@ package com.github.hydos.multithreading; import java.util.*; import com.github.halotroop.litecraft.Litecraft; -import com.github.hydos.ginger.engine.io.Window; +import com.github.hydos.ginger.engine.common.io.Window; public class GingerThreading extends Thread {