Start of engine rewrite
This commit is contained in:
parent
51afb9d82e
commit
e1d827223d
|
@ -22,7 +22,7 @@ import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
import speiger.src.coreengine.rendering.input.window.WindowProvider;
|
import speiger.src.coreengine.rendering.input.window.WindowProvider;
|
||||||
import speiger.src.coreengine.rendering.shaderOld.ProjectionBuffer;
|
import speiger.src.coreengine.rendering.shaderOld.ProjectionBuffer;
|
||||||
import speiger.src.coreengine.rendering.shaderOld.ShaderTracker;
|
import speiger.src.coreengine.rendering.shaderOld.ShaderTracker;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
import speiger.src.coreengine.rendering.utils.Cursor;
|
import speiger.src.coreengine.rendering.utils.Cursor;
|
||||||
import speiger.src.coreengine.utils.counters.timers.FPSTimer;
|
import speiger.src.coreengine.utils.counters.timers.FPSTimer;
|
||||||
import speiger.src.coreengine.utils.eventbus.EventBus;
|
import speiger.src.coreengine.utils.eventbus.EventBus;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package speiger.src.coreengine.rendering.gui;
|
package speiger.src.coreengine.rendering.gui;
|
||||||
|
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
|
|
||||||
public class UITextures
|
public class UITextures
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package speiger.src.coreengine.rendering.gui.components;
|
package speiger.src.coreengine.rendering.gui.components;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.gui.GuiComponent;
|
import speiger.src.coreengine.rendering.gui.GuiComponent;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
|
|
||||||
public class IconComponent extends GuiComponent
|
public class IconComponent extends GuiComponent
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ package speiger.src.coreengine.rendering.gui.components.icon;
|
||||||
|
|
||||||
import speiger.src.coreengine.math.misc.ColorUtils;
|
import speiger.src.coreengine.math.misc.ColorUtils;
|
||||||
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
|
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
|
|
||||||
public class TexturedIcon implements IIcon
|
public class TexturedIcon implements IIcon
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,11 +36,11 @@ import speiger.src.collections.objects.misc.pairs.ObjectObjectPair;
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.math.vector.ints.Vec2i;
|
import speiger.src.coreengine.math.vector.ints.Vec2i;
|
||||||
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
||||||
import speiger.src.coreengine.rendering.textures.atlas.AtlasStitcher;
|
import speiger.src.coreengine.rendering.texturesOld.atlas.AtlasStitcher;
|
||||||
import speiger.src.coreengine.rendering.textures.atlas.AtlasStitcher.Entry;
|
import speiger.src.coreengine.rendering.texturesOld.atlas.AtlasStitcher.Entry;
|
||||||
import speiger.src.coreengine.rendering.textures.custom.TextureAtlas;
|
import speiger.src.coreengine.rendering.texturesOld.custom.TextureAtlas;
|
||||||
import speiger.src.coreengine.rendering.textures.custom.TextureAtlas.AtlasEntry;
|
import speiger.src.coreengine.rendering.texturesOld.custom.TextureAtlas.AtlasEntry;
|
||||||
import speiger.src.coreengine.rendering.textures.custom.TextureAtlas.Builder;
|
import speiger.src.coreengine.rendering.texturesOld.custom.TextureAtlas.Builder;
|
||||||
|
|
||||||
public class FontBuilder {
|
public class FontBuilder {
|
||||||
public static final int LITERAL = 1;
|
public static final int LITERAL = 1;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import speiger.src.coreengine.rendering.models.DrawCall;
|
||||||
import speiger.src.coreengine.rendering.tesselationOld.IVertexBuilder;
|
import speiger.src.coreengine.rendering.tesselationOld.IVertexBuilder;
|
||||||
import speiger.src.coreengine.rendering.tesselationOld.Tesselator;
|
import speiger.src.coreengine.rendering.tesselationOld.Tesselator;
|
||||||
import speiger.src.coreengine.rendering.tesselationOld.VertexType;
|
import speiger.src.coreengine.rendering.tesselationOld.VertexType;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
import speiger.src.coreengine.utils.helpers.TextUtil;
|
import speiger.src.coreengine.utils.helpers.TextUtil;
|
||||||
|
|
||||||
public class FontRenderer implements IFontRenderer
|
public class FontRenderer implements IFontRenderer
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package speiger.src.coreengine.rendering.gui.renderer;
|
package speiger.src.coreengine.rendering.gui.renderer;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.gui.components.TextComponent;
|
import speiger.src.coreengine.rendering.gui.components.TextComponent;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
|
|
||||||
public interface IFontRenderer
|
public interface IFontRenderer
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,8 +27,8 @@ import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformVec2f;
|
||||||
import speiger.src.coreengine.rendering.tesselation.GLCall;
|
import speiger.src.coreengine.rendering.tesselation.GLCall;
|
||||||
import speiger.src.coreengine.rendering.tesselationOld.Tesselator;
|
import speiger.src.coreengine.rendering.tesselationOld.Tesselator;
|
||||||
import speiger.src.coreengine.rendering.tesselationOld.VertexType;
|
import speiger.src.coreengine.rendering.tesselationOld.VertexType;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||||
import speiger.src.coreengine.utils.collections.pools.SimplePool;
|
import speiger.src.coreengine.utils.collections.pools.SimplePool;
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ import speiger.src.coreengine.math.vector.ints.Vec2i;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.FontBuilder;
|
import speiger.src.coreengine.rendering.gui.helper.FontBuilder;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.FontBuilder.WrittenChar;
|
import speiger.src.coreengine.rendering.gui.helper.FontBuilder.WrittenChar;
|
||||||
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
import speiger.src.coreengine.utils.helpers.JsonUtil;
|
import speiger.src.coreengine.utils.helpers.JsonUtil;
|
||||||
|
|
||||||
public class BitmapFontProvider implements IFontProvider
|
public class BitmapFontProvider implements IFontProvider
|
||||||
|
|
|
@ -3,7 +3,7 @@ package speiger.src.coreengine.rendering.gui.renderer.provider;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer.CharInstance;
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
import speiger.src.coreengine.utils.helpers.JsonUtil;
|
import speiger.src.coreengine.utils.helpers.JsonUtil;
|
||||||
|
|
||||||
public interface IFontProvider
|
public interface IFontProvider
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.lwjgl.opengl.GL13;
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class TextureAttachment implements IFrameAttachment
|
public class TextureAttachment implements IFrameAttachment
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,12 +55,13 @@ public non-sealed class GuiComponent extends FlagObject implements ICastable, IL
|
||||||
|
|
||||||
protected void renderChildren(IUIRenderer renderer, int mouseX, int mouseY, float particalTicks) {
|
protected void renderChildren(IUIRenderer renderer, int mouseX, int mouseY, float particalTicks) {
|
||||||
for(GuiComponent child : children) {
|
for(GuiComponent child : children) {
|
||||||
|
if(child.isManualManaged()) continue;
|
||||||
renderComponent(child, renderer, mouseX, mouseY, particalTicks);
|
renderComponent(child, renderer, mouseX, mouseY, particalTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean renderComponent(GuiComponent comp, IUIRenderer renderer, int mouseX, int mouseY, float particalTicks) {
|
public static boolean renderComponent(GuiComponent comp, IUIRenderer renderer, int mouseX, int mouseY, float particalTicks) {
|
||||||
if(!comp.isVisible() || comp.isManualManaged() || (comp.isScissored() && !renderer.isInScissors(comp.getBox()))) return false;
|
if(!comp.isVisible() || (comp.isScissored() && !renderer.isInScissors(comp.getBox()))) return false;
|
||||||
if(comp.isScissored()) {
|
if(comp.isScissored()) {
|
||||||
renderer.pushScissors(comp.getBox());
|
renderer.pushScissors(comp.getBox());
|
||||||
if(comp.renderer != null) {
|
if(comp.renderer != null) {
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
package speiger.src.coreengine.rendering.newGui.renderer;
|
package speiger.src.coreengine.rendering.newGui.renderer;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.math.vector.quaternion.Quaternion;
|
||||||
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
|
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
|
||||||
|
|
||||||
public interface IUIRenderer {
|
public interface IUIRenderer {
|
||||||
public boolean isInScissors(IGuiBox box);
|
public boolean isInScissors(IGuiBox box);
|
||||||
public void pushScissors(IGuiBox box);
|
public void pushScissors(IGuiBox box);
|
||||||
public void popScissors();
|
public void popScissors();
|
||||||
|
|
||||||
|
public void flush();
|
||||||
|
|
||||||
|
public void pushTransform();
|
||||||
|
public void popTransform();
|
||||||
|
|
||||||
|
public void translate(float z);
|
||||||
|
public void translate(float x, float y);
|
||||||
|
public void translate(float x, float y, float z);
|
||||||
|
|
||||||
|
public void scale(float scale);
|
||||||
|
public void scale(float x, float y);
|
||||||
|
|
||||||
|
public void rotate(Quaternion rotation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package speiger.src.coreengine.rendering.shaderOld.uniforms;
|
package speiger.src.coreengine.rendering.shaderOld.uniforms;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class UniformTexture extends UniformInt {
|
public class UniformTexture extends UniformInt {
|
||||||
int bank;
|
int bank;
|
||||||
|
|
|
@ -11,6 +11,8 @@ public interface IVertexBuilder extends IVertexBuffer {
|
||||||
public IVertexBuilder putInt(int offset, int value);
|
public IVertexBuilder putInt(int offset, int value);
|
||||||
public IVertexBuilder putFloat(int offset, float value);
|
public IVertexBuilder putFloat(int offset, float value);
|
||||||
|
|
||||||
|
public int size();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IVertexBuffer pos(float x, float y) {
|
default IVertexBuffer pos(float x, float y) {
|
||||||
validate(this, Usage.POS, 2);
|
validate(this, Usage.POS, 2);
|
||||||
|
|
|
@ -56,6 +56,9 @@ public class VertexBuilder implements IVertexBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() { return vertecies; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IVertexBuilder put(int offset, byte value) {
|
public IVertexBuilder put(int offset, byte value) {
|
||||||
buffer.put(totalStoredBytes + offset, value);
|
buffer.put(totalStoredBytes + offset, value);
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package speiger.src.coreengine.rendering.textures.base;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public abstract class BaseTexture implements ITexture {
|
||||||
|
protected int id;
|
||||||
|
|
||||||
|
protected BaseTexture() {
|
||||||
|
this(GL11.glGenTextures());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BaseTexture(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int id() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bind() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int width() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int height() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float minU() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float minV() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float maxU() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float maxV() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,56 +1,16 @@
|
||||||
package speiger.src.coreengine.rendering.textures.base;
|
package speiger.src.coreengine.rendering.textures.base;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
public interface ITexture {
|
||||||
import java.nio.ByteBuffer;
|
public int id();
|
||||||
|
public void bind();
|
||||||
|
public void reload();
|
||||||
|
public void delete();
|
||||||
|
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
public int width();
|
||||||
import speiger.src.coreengine.assets.reloader.IReloadableResource;
|
public int height();
|
||||||
import speiger.src.coreengine.rendering.textures.normal.DirectTexture;
|
|
||||||
import speiger.src.coreengine.rendering.textures.normal.SimpleTexture;
|
|
||||||
import speiger.src.coreengine.rendering.textures.stb.STBDirectTexture;
|
|
||||||
import speiger.src.coreengine.rendering.textures.stb.STBTexture;
|
|
||||||
|
|
||||||
public interface ITexture extends IReloadableResource
|
public float minU();
|
||||||
{
|
public float minV();
|
||||||
public int getTextureId();
|
public float maxU();
|
||||||
|
public float maxV();
|
||||||
public void bindTexture();
|
|
||||||
public void deleteTexture();
|
|
||||||
|
|
||||||
public int getWidth();
|
|
||||||
public int getHeight();
|
|
||||||
|
|
||||||
public float getUMin();
|
|
||||||
public float getVMin();
|
|
||||||
public float getUMax();
|
|
||||||
public float getVMax();
|
|
||||||
|
|
||||||
public ITexture makeReloadable();
|
|
||||||
|
|
||||||
public default float getInterpolatedU(float u){return getUMin() + ((getUMax() - getUMin()) * u);}
|
|
||||||
public default float getInterpolatedV(float v){return getUMin() + ((getUMax() - getUMin()) * v);}
|
|
||||||
|
|
||||||
public static ITexture simple(AssetLocation location) {
|
|
||||||
return new STBTexture(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ITexture direct(ByteBuffer stbImageData, int width, int height) {
|
|
||||||
return new STBDirectTexture(stbImageData, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ITexture direct(long stbImageData, int width, int height) {
|
|
||||||
return new STBDirectTexture(stbImageData, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ITexture direct(BufferedImage imageData) {
|
|
||||||
return new STBDirectTexture(imageData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ITexture awtSimple(AssetLocation location) {
|
|
||||||
return new SimpleTexture(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ITexture awtDirect(BufferedImage imageData) {
|
|
||||||
return new DirectTexture(imageData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package speiger.src.coreengine.rendering.textures.base;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
|
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
|
||||||
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
|
import speiger.src.coreengine.assets.base.IAssetProvider;
|
||||||
|
import speiger.src.coreengine.assets.base.IManagedAsset;
|
||||||
|
import speiger.src.coreengine.assets.base.IReloadableAsset.ISimpleRealodableAsset;
|
||||||
|
|
||||||
|
public class TextureTracker implements ISimpleRealodableAsset, IManagedAsset {
|
||||||
|
IAssetProvider provider;
|
||||||
|
ObjectList<ITexture> textures = new ObjectArrayList<>();
|
||||||
|
ObjectSet<ITexture> reloadable = new ObjectLinkedOpenHashSet<>();
|
||||||
|
|
||||||
|
public void registerTexture(ITexture texture) {
|
||||||
|
register(texture, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerReloadable(ITexture texture) {
|
||||||
|
register(texture, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(ITexture texture, boolean reloadable) {
|
||||||
|
textures.add(texture);
|
||||||
|
if(reloadable) this.reloadable.add(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteTexture(ITexture texture) {
|
||||||
|
textures.remove(texture);
|
||||||
|
reloadable.remove(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAssetsReloaded(IAssetProvider provider) {
|
||||||
|
textures.filter(((Predicate<ITexture>)reloadable::contains).negate()).forEach(ITexture::delete);
|
||||||
|
textures.clear();
|
||||||
|
reloadable.peek(ITexture::reload).forEach(textures::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
textures.forEach(ITexture::delete);
|
||||||
|
textures.clear();
|
||||||
|
reloadable.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "Texture Tracker"; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProvider(IAssetProvider provider) { this.provider = provider; }
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.atlas;
|
package speiger.src.coreengine.rendering.texturesOld.atlas;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
import speiger.src.collections.objects.utils.ObjectIterables;
|
import speiger.src.collections.objects.utils.ObjectIterables;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.rendering.textures.atlas.AtlasStitcher.Entry;
|
import speiger.src.coreengine.rendering.texturesOld.atlas.AtlasStitcher.Entry;
|
||||||
|
|
||||||
|
|
||||||
public class AtlasStitcher<T extends Entry> {
|
public class AtlasStitcher<T extends Entry> {
|
||||||
|
@ -20,6 +20,10 @@ public class AtlasStitcher<T extends Entry> {
|
||||||
List<Record<T>> toStitch = new ObjectArrayList<>();
|
List<Record<T>> toStitch = new ObjectArrayList<>();
|
||||||
Slot<T> slot = null;
|
Slot<T> slot = null;
|
||||||
|
|
||||||
|
public AtlasStitcher(int bounds) {
|
||||||
|
this(bounds, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
public AtlasStitcher(int maxWidth, int maxHeight) {
|
public AtlasStitcher(int maxWidth, int maxHeight) {
|
||||||
this.maxWidth = maxWidth;
|
this.maxWidth = maxWidth;
|
||||||
this.maxHeight = maxHeight;
|
this.maxHeight = maxHeight;
|
||||||
|
@ -30,9 +34,7 @@ public class AtlasStitcher<T extends Entry> {
|
||||||
public int height() { return height; }
|
public int height() { return height; }
|
||||||
public boolean isValid() { return valid; }
|
public boolean isValid() { return valid; }
|
||||||
|
|
||||||
public void add(T entry) {
|
public void add(T entry) { add(new Record<T>(entry)); }
|
||||||
add(new Record<T>(entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAll(Iterable<? extends T> iterables) {
|
public void addAll(Iterable<? extends T> iterables) {
|
||||||
ObjectIterables.map(iterables, Record<T>::new).forEach(this::add);
|
ObjectIterables.map(iterables, Record<T>::new).forEach(this::add);
|
||||||
|
@ -96,9 +98,7 @@ public class AtlasStitcher<T extends Entry> {
|
||||||
this(entry, entry.width(), entry.height());
|
this(entry, entry.width(), entry.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int pixels() {
|
public int pixels() { return width() * height(); }
|
||||||
return width() * height();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Record<T> o) {
|
public int compareTo(Record<T> o) {
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.base;
|
package speiger.src.coreengine.rendering.texturesOld.base;
|
||||||
|
|
||||||
public abstract class AbstractTexture implements ITexture {
|
public abstract class AbstractTexture implements ITexture {
|
||||||
protected int textureID;
|
protected int textureID;
|
|
@ -0,0 +1,56 @@
|
||||||
|
package speiger.src.coreengine.rendering.texturesOld.base;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
|
import speiger.src.coreengine.assets.reloader.IReloadableResource;
|
||||||
|
import speiger.src.coreengine.rendering.texturesOld.normal.DirectTexture;
|
||||||
|
import speiger.src.coreengine.rendering.texturesOld.normal.SimpleTexture;
|
||||||
|
import speiger.src.coreengine.rendering.texturesOld.stb.STBDirectTexture;
|
||||||
|
import speiger.src.coreengine.rendering.texturesOld.stb.STBTexture;
|
||||||
|
|
||||||
|
public interface ITexture extends IReloadableResource
|
||||||
|
{
|
||||||
|
public int getTextureId();
|
||||||
|
|
||||||
|
public void bindTexture();
|
||||||
|
public void deleteTexture();
|
||||||
|
|
||||||
|
public int getWidth();
|
||||||
|
public int getHeight();
|
||||||
|
|
||||||
|
public float getUMin();
|
||||||
|
public float getVMin();
|
||||||
|
public float getUMax();
|
||||||
|
public float getVMax();
|
||||||
|
|
||||||
|
public ITexture makeReloadable();
|
||||||
|
|
||||||
|
public default float getInterpolatedU(float u){return getUMin() + ((getUMax() - getUMin()) * u);}
|
||||||
|
public default float getInterpolatedV(float v){return getUMin() + ((getUMax() - getUMin()) * v);}
|
||||||
|
|
||||||
|
public static ITexture simple(AssetLocation location) {
|
||||||
|
return new STBTexture(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITexture direct(ByteBuffer stbImageData, int width, int height) {
|
||||||
|
return new STBDirectTexture(stbImageData, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITexture direct(long stbImageData, int width, int height) {
|
||||||
|
return new STBDirectTexture(stbImageData, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITexture direct(BufferedImage imageData) {
|
||||||
|
return new STBDirectTexture(imageData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITexture awtSimple(AssetLocation location) {
|
||||||
|
return new SimpleTexture(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITexture awtDirect(BufferedImage imageData) {
|
||||||
|
return new DirectTexture(imageData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.base;
|
package speiger.src.coreengine.rendering.texturesOld.base;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.base;
|
package speiger.src.coreengine.rendering.texturesOld.base;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.base;
|
package speiger.src.coreengine.rendering.texturesOld.base;
|
||||||
|
|
||||||
public class WrappedTexture implements ITexture
|
public class WrappedTexture implements ITexture
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
package speiger.src.coreengine.rendering.textures.custom;
|
package speiger.src.coreengine.rendering.texturesOld.custom;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.textures.base.ITexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.ITexture;
|
||||||
|
|
||||||
public interface IDynamicTexture extends ITexture
|
public interface IDynamicTexture extends ITexture
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.custom;
|
package speiger.src.coreengine.rendering.texturesOld.custom;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.normal;
|
package speiger.src.coreengine.rendering.texturesOld.normal;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -8,8 +8,8 @@ import org.lwjgl.opengl.GL13;
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.textures.base.AbstractTexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.AbstractTexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class DirectTexture extends AbstractTexture
|
public class DirectTexture extends AbstractTexture
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.normal;
|
package speiger.src.coreengine.rendering.texturesOld.normal;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -20,9 +20,9 @@ import speiger.src.collections.ints.sets.IntSet;
|
||||||
import speiger.src.collections.ints.utils.maps.Int2ObjectMaps;
|
import speiger.src.collections.ints.utils.maps.Int2ObjectMaps;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
import speiger.src.coreengine.math.BitUtil;
|
import speiger.src.coreengine.math.BitUtil;
|
||||||
import speiger.src.coreengine.rendering.textures.base.AbstractTexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.AbstractTexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
import speiger.src.coreengine.rendering.textures.custom.IDynamicTexture;
|
import speiger.src.coreengine.rendering.texturesOld.custom.IDynamicTexture;
|
||||||
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
||||||
|
|
||||||
public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
public class DynamicTexture extends AbstractTexture implements IDynamicTexture
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.normal;
|
package speiger.src.coreengine.rendering.texturesOld.normal;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -10,8 +10,8 @@ import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.assets.base.IAsset;
|
import speiger.src.coreengine.assets.base.IAsset;
|
||||||
import speiger.src.coreengine.rendering.textures.base.AbstractTexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.AbstractTexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class SimpleTexture extends AbstractTexture
|
public class SimpleTexture extends AbstractTexture
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.stb;
|
package speiger.src.coreengine.rendering.texturesOld.stb;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -13,8 +13,8 @@ import org.lwjgl.opengl.GL30;
|
||||||
import org.lwjgl.stb.STBImage;
|
import org.lwjgl.stb.STBImage;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.textures.base.AbstractTexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.AbstractTexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class STBDirectTexture extends AbstractTexture
|
public class STBDirectTexture extends AbstractTexture
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
package speiger.src.coreengine.rendering.textures.stb;
|
package speiger.src.coreengine.rendering.texturesOld.stb;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -11,9 +11,9 @@ import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.assets.base.IAsset;
|
import speiger.src.coreengine.assets.base.IAsset;
|
||||||
import speiger.src.coreengine.rendering.textures.base.AbstractTexture;
|
import speiger.src.coreengine.rendering.texturesOld.base.AbstractTexture;
|
||||||
import speiger.src.coreengine.rendering.textures.base.NativeMemoryParser;
|
import speiger.src.coreengine.rendering.texturesOld.base.NativeMemoryParser;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public class STBTexture extends AbstractTexture
|
public class STBTexture extends AbstractTexture
|
||||||
{
|
{
|
|
@ -13,7 +13,7 @@ import speiger.src.collections.objects.utils.maps.Object2ObjectMaps;
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.assets.reloader.IReloadableResource;
|
import speiger.src.coreengine.assets.reloader.IReloadableResource;
|
||||||
import speiger.src.coreengine.rendering.input.window.Window;
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
import speiger.src.coreengine.rendering.textures.base.TextureManager;
|
import speiger.src.coreengine.rendering.texturesOld.base.TextureManager;
|
||||||
|
|
||||||
public final class Cursor implements IReloadableResource {
|
public final class Cursor implements IReloadableResource {
|
||||||
public static final Cursor INSTANCE = new Cursor();
|
public static final Cursor INSTANCE = new Cursor();
|
||||||
|
|
|
@ -9,15 +9,13 @@ import org.lwjgl.opengl.GL33;
|
||||||
import speiger.src.collections.ints.collections.IntStack;
|
import speiger.src.collections.ints.collections.IntStack;
|
||||||
import speiger.src.collections.ints.lists.IntArrayList;
|
import speiger.src.collections.ints.lists.IntArrayList;
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
import speiger.src.collections.objects.maps.impl.hash.Object2ObjectOpenHashMap;
|
|
||||||
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
|
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
|
||||||
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap.Entry;
|
|
||||||
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
|
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
|
||||||
import speiger.src.collections.utils.Stack;
|
import speiger.src.collections.utils.Stack;
|
||||||
|
|
||||||
public class GLStamper {
|
public class GLStamper {
|
||||||
public static GLStamper INSTANCE = new GLStamper();
|
public static GLStamper INSTANCE = new GLStamper();
|
||||||
Object2ObjectMap<String, Set<GLStamp>> stamps = new Object2ObjectOpenHashMap<>();
|
Object2ObjectMap<String, Set<GLStamp>> stamps = Object2ObjectMap.builder().linkedMap();
|
||||||
Stack<GLStamp> unusedStamps = new ObjectArrayList<>();
|
Stack<GLStamp> unusedStamps = new ObjectArrayList<>();
|
||||||
IntStack queryIDs = new IntArrayList();
|
IntStack queryIDs = new IntArrayList();
|
||||||
|
|
||||||
|
@ -31,18 +29,14 @@ public class GLStamper {
|
||||||
|
|
||||||
public void removeOwner(String ownerID) {
|
public void removeOwner(String ownerID) {
|
||||||
Set<GLStamp> set = stamps.remove(ownerID);
|
Set<GLStamp> set = stamps.remove(ownerID);
|
||||||
if(set != null) {
|
if(set == null) return;
|
||||||
for(GLStamp stamp : set) {
|
set.forEach(GLStamp::release);
|
||||||
stamp.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if(!stamps.isEmpty()) {
|
if(!stamps.isEmpty()) {
|
||||||
for(Iterator<Entry<String, Set<GLStamp>>> iter = stamps.object2ObjectEntrySet().iterator();iter.hasNext();) {
|
for(Iterator<Set<GLStamp>> iter = stamps.values().iterator();iter.hasNext();iter.remove()) {
|
||||||
iter.next().getValue().forEach(GLStamp::release);
|
iter.next().forEach(GLStamp::release);
|
||||||
iter.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(queryIDs.isEmpty()) return;
|
if(queryIDs.isEmpty()) return;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
import speiger.src.collections.objects.lists.ObjectList;
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
import speiger.src.coreengine.rendering.shader.ShaderTracker;
|
import speiger.src.coreengine.rendering.shader.ShaderTracker;
|
||||||
import speiger.src.coreengine.rendering.shader.uniform.GlobalUniforms;
|
import speiger.src.coreengine.rendering.shader.uniform.GlobalUniforms;
|
||||||
|
import speiger.src.coreengine.rendering.textures.base.TextureTracker;
|
||||||
import speiger.src.coreengine.rendering.utils.states.BlendState;
|
import speiger.src.coreengine.rendering.utils.states.BlendState;
|
||||||
import speiger.src.coreengine.rendering.utils.states.CullState;
|
import speiger.src.coreengine.rendering.utils.states.CullState;
|
||||||
import speiger.src.coreengine.rendering.utils.states.FloatState;
|
import speiger.src.coreengine.rendering.utils.states.FloatState;
|
||||||
|
@ -24,6 +25,7 @@ import speiger.src.coreengine.utils.counters.averager.Counter;
|
||||||
|
|
||||||
public class GLStateTracker {
|
public class GLStateTracker {
|
||||||
static final ObjectList<IGLState> ALL_STATES = new ObjectArrayList<>();
|
static final ObjectList<IGLState> ALL_STATES = new ObjectArrayList<>();
|
||||||
|
//GPU States
|
||||||
public static final GLState MULTI_SAMPLING = addState(new GLState(GL13.GL_MULTISAMPLE));
|
public static final GLState MULTI_SAMPLING = addState(new GLState(GL13.GL_MULTISAMPLE));
|
||||||
public static final GLWireFrame WIRE_FRAME = addState(new GLWireFrame(GLCullType.BOTH));
|
public static final GLWireFrame WIRE_FRAME = addState(new GLWireFrame(GLCullType.BOTH));
|
||||||
public static final GLState PROVOKING_VERTEX = addState(new GLProvoking());
|
public static final GLState PROVOKING_VERTEX = addState(new GLProvoking());
|
||||||
|
@ -35,10 +37,13 @@ public class GLStateTracker {
|
||||||
public static final FloatState LINE_SIZE = addState(new FloatState(1F, GL11::glLineWidth));
|
public static final FloatState LINE_SIZE = addState(new FloatState(1F, GL11::glLineWidth));
|
||||||
public static final ScissorsManager TESTER = new ScissorsManager(100);
|
public static final ScissorsManager TESTER = new ScissorsManager(100);
|
||||||
public static final Counter[] COUNTERS = Counter.createCounters(4);
|
public static final Counter[] COUNTERS = Counter.createCounters(4);
|
||||||
public static final ViewPortStack VIEW_PORT = new ViewPortStack();
|
|
||||||
public static final ShaderTracker SHADERS = new ShaderTracker();
|
|
||||||
public static final GlobalUniforms UNIFORMS = new GlobalUniforms();
|
|
||||||
public static final TextureState TEXTURES = addState(new TextureState());
|
public static final TextureState TEXTURES = addState(new TextureState());
|
||||||
|
public static final ViewPortStack VIEW_PORT = new ViewPortStack();
|
||||||
|
|
||||||
|
//Trackers
|
||||||
|
public static final ShaderTracker SHADERS = new ShaderTracker();
|
||||||
|
public static final TextureTracker TEXTURE_TRACKER = new TextureTracker();
|
||||||
|
public static final GlobalUniforms UNIFORMS = new GlobalUniforms();
|
||||||
|
|
||||||
public static <T extends IGLState> T addState(T state) {
|
public static <T extends IGLState> T addState(T state) {
|
||||||
ALL_STATES.add(state);
|
ALL_STATES.add(state);
|
||||||
|
|
Loading…
Reference in New Issue