Progress on more rewrites
This commit is contained in:
1 parent
340d8ff463
commit
396d4f2232
121 files changed
+899
-239
No files matched your search
+12
@@ -24,6 +24,18 @@
|
||||
<attribute name="gradle_used_by_scope" value="graphics"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/math" path="src/math/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="math"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,graphics,math"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/assets" path="src/assets/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="assets"/>
|
||||
<attribute name="gradle_used_by_scope" value="assets"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
|
||||
+21
-1
@@ -16,12 +16,31 @@ eclipse {
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
graphics {}
|
||||
math {
|
||||
java {}
|
||||
}
|
||||
assets {
|
||||
java {}
|
||||
}
|
||||
graphics {
|
||||
java {}
|
||||
}
|
||||
main {
|
||||
compileClasspath += sourceSets.math.output
|
||||
runtimeClasspath += sourceSets.math.output
|
||||
}
|
||||
graphics {
|
||||
compileClasspath += sourceSets.math.output
|
||||
runtimeClasspath += sourceSets.math.output
|
||||
java {}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
graphics.extendsFrom implementation
|
||||
graphics.extendsFrom runtime
|
||||
graphics.extendsFrom mathRuntime
|
||||
implementation.extendsFrom mathRuntime
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -64,6 +83,7 @@ dependencies {
|
||||
|
||||
//Primitive Collections
|
||||
implementation 'de.speiger:Primitive-Collections:1.0.0'
|
||||
mathImplementation 'de.speiger:Primitive-Collections:1.0.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface IAsset {
|
||||
public IAssetPackage owner();
|
||||
public ID location();
|
||||
|
||||
public String hash();
|
||||
public InputStream stream() throws IOException;
|
||||
|
||||
public <T> T parse(IAssetParser<T> parser) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
public interface IAssetPackage {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IAssetParser<T> {
|
||||
public T parse(Path path) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
public interface IAssetProvider {
|
||||
public IAsset get(ID id);
|
||||
public String hash(ID id);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record ID(String domain, String path) implements Comparable<ID> {
|
||||
|
||||
public ID {
|
||||
Objects.requireNonNull(domain);
|
||||
Objects.requireNonNull(path);
|
||||
if(!isValidDomain(domain)) throw new IllegalArgumentException("Non [a-zA-Z0-9_.-] Character found in domain of location ["+domain+":"+path+"]");
|
||||
if(!isValidPath(path)) throw new IllegalArgumentException("Non [a-zA-Z0-9/_.-] Character found in path of location ["+domain+":"+path+"]");
|
||||
}
|
||||
|
||||
public ID prefix(String prefix) { return of(domain, prefix+"/"+path); }
|
||||
public ID suffix(String suffix) { return of(domain, path+"/"+suffix); }
|
||||
public ID alternate(String alterversion) { return of(domain, path+"."+alterversion); }
|
||||
|
||||
public String fileLocation() { return "assets/"+domain+"/"+path; }
|
||||
public boolean isRoot() { return !path.contains("/"); }
|
||||
public boolean isRootFolder(String folder) { return path.indexOf('/', folder.length()+1) < 0; }
|
||||
public boolean endsWith(String suffix) { return path.endsWith(suffix); }
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return domain+":"+path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ID o) {
|
||||
int result = domain.compareToIgnoreCase(o.domain);
|
||||
return result != 0 ? result : path.compareToIgnoreCase(path);
|
||||
}
|
||||
|
||||
public boolean matches(ID id) {
|
||||
return id.domain.equals(domain) && id.path.equals(path);
|
||||
}
|
||||
|
||||
public static ID of(String domain, String path) {
|
||||
return new ID((domain == null || domain.isBlank() ? "base" : domain), path);
|
||||
}
|
||||
|
||||
public static ID of(String location) {
|
||||
Objects.requireNonNull(location);
|
||||
int index = location.indexOf(":");
|
||||
String domain = location.substring(0, index);
|
||||
String path = location.substring(index + 1);
|
||||
if(!isValidDomain(domain)) throw new IllegalArgumentException("Non [a-zA-Z0-9_.-] Character found in domain of location ["+domain+":"+path+"]");
|
||||
if(!isValidPath(path)) throw new IllegalArgumentException("Non [a-zA-Z0-9/_.-] Character found in path of location ["+domain+":"+path+"]");
|
||||
return new ID(domain, path);
|
||||
}
|
||||
|
||||
public static final ID tryOf(String location) {
|
||||
try { return of(location); }
|
||||
catch(Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isValidDomain(String s) {
|
||||
for(int i = 0,m=s.length();i<m;i++) {
|
||||
if(!isValidDomainChar(s.charAt(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isValidPath(String s) {
|
||||
for(int i = 0,m=s.length();i<m;i++) {
|
||||
if(!isValidPathChar(s.charAt(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isValidPathChar(char c) {
|
||||
return c == '/' || isValidDomainChar(c);
|
||||
}
|
||||
|
||||
private static boolean isValidDomainChar(char c) {
|
||||
return c == '_' || c == '-' || c == '.' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package speiger.src.coreengine.assets.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.objects.lists.ObjectList;
|
||||
|
||||
public record MultiAsset(ObjectList<IAsset> assets) implements ObjectIterable<IAsset> {
|
||||
|
||||
public MultiAsset(ObjectList<IAsset> assets) {
|
||||
this.assets = Objects.requireNonNull(assets).unmodifiable();
|
||||
}
|
||||
|
||||
public MultiAsset(IAsset... assets) {
|
||||
this(ObjectArrayList.wrap(assets));
|
||||
}
|
||||
|
||||
public int size() { return assets.size(); }
|
||||
public IAsset get(int index) { return assets.get(index); }
|
||||
@Override
|
||||
public ObjectIterator<IAsset> iterator() { return assets.iterator(); }
|
||||
|
||||
public <T> ObjectIterable<T> map(IAssetParser<T> mapper, Supplier<T> defaultValue) {
|
||||
return assets.map(E -> {
|
||||
try { return E.parse(mapper); }
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
return defaultValue.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super IAsset> action) {
|
||||
assets.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, ObjectObjectConsumer<E, IAsset> action) {
|
||||
assets.forEach(input, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachIndexed(IntObjectConsumer<IAsset> action) {
|
||||
assets.forEachIndexed(action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package speiger.src.coreengine.graphics.api.buffer.states;
|
||||
|
||||
public enum IndeciesType {
|
||||
BYTE,
|
||||
SHORT,
|
||||
INT;
|
||||
}
|
||||
+19
-2
@@ -1,5 +1,7 @@
|
||||
package speiger.src.coreengine.graphics.api.core;
|
||||
|
||||
import speiger.src.coreengine.graphics.api.shader.RenderPass;
|
||||
import speiger.src.coreengine.graphics.api.target.RenderTarget;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.api.utils.PushableResource;
|
||||
import speiger.src.coreengine.math.vector.floats.Vec4f;
|
||||
@@ -7,11 +9,26 @@ import speiger.src.coreengine.math.vector.floats.Vec4f;
|
||||
public interface GraphicsCommandQueue {
|
||||
public static final int CLEAR_COLOR = 1;
|
||||
public static final int CLEAR_DEPTH = 2;
|
||||
public PushableResource pushClearColor(Vec4f color);
|
||||
public PushableResource pushClearDepth(double value);
|
||||
public PushableResource putClearColor(Vec4f color);
|
||||
public PushableResource putClearDepth(double value);
|
||||
public PushableResource putRenderTarget(RenderTarget target);
|
||||
|
||||
public void clearTexture(int clearParam);
|
||||
public void clearTexture(int x, int y, int width, int height, int clearParam);
|
||||
public void clearTexture(Texture texture, int clearParam);
|
||||
public void clearTexture(Texture texture, int x, int y, int width, int height, int clearParam);
|
||||
|
||||
public void writeToTexture(Texture target, int x, int y, int width, int height, long source);
|
||||
public void readFromTexture(Texture source, int x, int y, int width, int height, long target);
|
||||
public RenderPass createRenderPass(RenderTarget target, DrawArea area);
|
||||
|
||||
public record DrawArea(int x, int y, int width, int height) {
|
||||
public boolean fits(int x, int y, int width, int height) {
|
||||
return x >= x() && y >= y() && x + width < width() && y + height < height();
|
||||
}
|
||||
|
||||
public boolean fills(int width, int height) {
|
||||
return x == 0 && y == 0 && width == width() && height == height();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,10 @@ import speiger.src.coreengine.graphics.api.sampler.Sampler;
|
||||
import speiger.src.coreengine.graphics.api.sampler.SamplerSettings;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.api.texture.TextureSettings;
|
||||
import speiger.src.coreengine.rendering.input.window.Window;
|
||||
|
||||
public interface GraphicsDevice {
|
||||
public Window getWindow();
|
||||
public GraphicsSurface createSurface();
|
||||
public GraphicsCommandQueue getQueue();
|
||||
public VertexBuffer createBuffer(BufferType type, BufferState state);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package speiger.src.coreengine.graphics.api.shader;
|
||||
|
||||
public interface CompiledPipeline {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package speiger.src.coreengine.graphics.api.shader;
|
||||
|
||||
import speiger.src.coreengine.graphics.api.buffer.VertexBuffer;
|
||||
import speiger.src.coreengine.graphics.api.buffer.states.IndeciesType;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsCommandQueue.DrawArea;
|
||||
import speiger.src.coreengine.graphics.api.sampler.Sampler;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.api.utils.ScissorsManager;
|
||||
|
||||
public abstract class RenderPass implements AutoCloseable {
|
||||
protected final DrawArea area;
|
||||
protected final boolean hasColor;
|
||||
protected final boolean hasDepth;
|
||||
protected final ScissorsManager scissors = new ScissorsManager(16);
|
||||
|
||||
public RenderPass(DrawArea area, boolean hasColor, boolean hasDepth) {
|
||||
this.area = area;
|
||||
this.hasColor = hasColor;
|
||||
this.hasDepth = hasDepth;
|
||||
}
|
||||
|
||||
public void pushScissors(int x, int y, int width, int height) {
|
||||
if(area != null && area.fits(x, y, width, height)) {
|
||||
//TODO implement logging
|
||||
return;
|
||||
}
|
||||
scissors.push(x, y, width, height);
|
||||
}
|
||||
|
||||
public void popScissors() {
|
||||
scissors.pop();
|
||||
}
|
||||
|
||||
public abstract void setShader(ShaderPipeline pipeline);
|
||||
public abstract void setTexture(String name, Texture texture, Sampler sampler);
|
||||
public abstract void clearTextures();
|
||||
public abstract void removeTexture(String name);
|
||||
public abstract void setUniform(String name, VertexBuffer buffer);
|
||||
public abstract void setIndecies(VertexBuffer buffer, IndeciesType type);
|
||||
public abstract void clearIndecies();
|
||||
public abstract void setVertexBuffer(int index, VertexBuffer buffer);
|
||||
|
||||
public DrawArea area() { return area; }
|
||||
public boolean hasDepth() { return hasDepth; }
|
||||
public boolean hasColor() { return hasColor; }
|
||||
|
||||
@Override
|
||||
public abstract void close();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package speiger.src.coreengine.graphics.api.target;
|
||||
|
||||
public sealed interface RenderTarget permits ScreenTarget, TextureTarget {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package speiger.src.coreengine.graphics.api.target;
|
||||
|
||||
public final class ScreenTarget implements RenderTarget {
|
||||
public static final ScreenTarget INSTANCE = new ScreenTarget();
|
||||
private ScreenTarget() {}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package speiger.src.coreengine.graphics.api.target;
|
||||
|
||||
import speiger.src.coreengine.assets.AssetLocation;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.api.texture.states.TextureType;
|
||||
|
||||
public record TextureTarget(AssetLocation id, Texture color, Texture depth) implements RenderTarget {
|
||||
public TextureTarget {
|
||||
if(color == null && depth == null) throw new IllegalArgumentException("At least either texture has to be nonNull");
|
||||
if(color != null && depth != null) {
|
||||
if(color.width() != depth.width()) throw new IllegalArgumentException("Width is not matching");
|
||||
if(color.height() != depth.height()) throw new IllegalArgumentException("Height is not matching");
|
||||
}
|
||||
if(color != null && color.settings().type() != TextureType.TEXTURE_2D) throw new IllegalArgumentException("Color Texture has to be 2D");
|
||||
if(depth != null && depth.settings().type() != TextureType.TEXTURE_2D) throw new IllegalArgumentException("Depth Texture has to be 2D");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package speiger.src.coreengine.graphics.api.utils;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.collections.utils.Stack;
|
||||
import speiger.src.coreengine.math.vector.ints.Vec4i;
|
||||
|
||||
public class ScissorsManager {
|
||||
Stack<Vec4i> stack = new ObjectArrayList<>();
|
||||
int limit;
|
||||
|
||||
public ScissorsManager(int limit) {
|
||||
if(limit <= 0) throw new IllegalStateException("Limit is negative");
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void push(int x, int y, int width, int height) {
|
||||
if(stack.size() >= limit) {
|
||||
//TODO implement logging
|
||||
return;
|
||||
}
|
||||
if(stack.isEmpty()) {
|
||||
stack.push(Vec4i.of(x, y, x + width, y + height));
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glScissor(x, y, width, height);
|
||||
return;
|
||||
}
|
||||
Vec4i top = stack.top();
|
||||
stack.push(Vec4i.of(Math.max(x, top.x()), Math.max(y, top.y()), Math.min(x + width, top.z()), Math.min(y + height, top.w())));
|
||||
}
|
||||
|
||||
public boolean contains(int x, int y, int width, int height) {
|
||||
return stack.isEmpty() || contains(stack.top(), x, y, width, height);
|
||||
}
|
||||
|
||||
protected boolean contains(Vec4i top, int x, int y, int width, int height) {
|
||||
return x >= top.x() && y >= top.y() && x + width < top.z() && y + height < top.w();
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
if(stack.isEmpty()) {
|
||||
//TODO implement logging
|
||||
return;
|
||||
}
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
stack.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package speiger.src.coreengine.graphics.opengl.core;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL45;
|
||||
|
||||
import speiger.src.coreengine.assets.AssetLocation;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsCommandQueue;
|
||||
import speiger.src.coreengine.graphics.api.shader.RenderPass;
|
||||
import speiger.src.coreengine.graphics.api.target.RenderTarget;
|
||||
import speiger.src.coreengine.graphics.api.target.ScreenTarget;
|
||||
import speiger.src.coreengine.graphics.api.target.TextureTarget;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.api.utils.PushableResource;
|
||||
import speiger.src.coreengine.graphics.opengl.shader.GLRenderPass;
|
||||
import speiger.src.coreengine.graphics.opengl.texture.FrameBufferCache;
|
||||
import speiger.src.coreengine.graphics.opengl.texture.GLTexture;
|
||||
import speiger.src.coreengine.math.vector.floats.Vec4f;
|
||||
import speiger.src.coreengine.rendering.input.window.Window;
|
||||
|
||||
public class GLCommandQueue implements GraphicsCommandQueue {
|
||||
private static final int HAS_COLOR = 1;
|
||||
private static final int HAS_DEPTH = 2;
|
||||
private static final int HAS_BOTH = 3;
|
||||
GLGraphicsDevice device;
|
||||
FrameBufferCache fboCache = new FrameBufferCache();
|
||||
GLRenderPass activePass;
|
||||
RenderTarget renderTarget = ScreenTarget.INSTANCE;
|
||||
Vec4f clearColor = Vec4f.mutable(0F, 0F, 0F, 1F);
|
||||
double clearDepth = 0D;
|
||||
|
||||
public GLCommandQueue(GLGraphicsDevice device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushableResource putClearColor(Vec4f color) {
|
||||
return new PushableObject<>(clearColor.copyAsImmutable(), setClearColor(color), () -> clearColor, this::setClearColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushableResource putClearDepth(double value) {
|
||||
return new PushableObject<>(clearDepth, setClearDepth(value), () -> clearDepth, this::setClearDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushableResource putRenderTarget(RenderTarget target) {
|
||||
return new PushableObject<>(renderTarget, setRenderTarget(target), () -> renderTarget, this::setRenderTarget);
|
||||
}
|
||||
|
||||
private Vec4f setClearColor(Vec4f value) {
|
||||
if(clearColor.equals(value)) return value;
|
||||
clearColor.set(value);
|
||||
GL11.glClearColor(value.x(), value.y(), value.y(), value.w());
|
||||
return value;
|
||||
}
|
||||
|
||||
private double setClearDepth(double value) {
|
||||
if(Double.compare(clearDepth, value) == 0) return value;
|
||||
clearDepth = value;
|
||||
GL11.glClearDepth(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private RenderTarget setRenderTarget(RenderTarget target) {
|
||||
if(this.renderTarget.equals(target)) return target;
|
||||
this.renderTarget = target;
|
||||
switch(target) {
|
||||
case ScreenTarget _ -> {
|
||||
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0);
|
||||
Window window = device.getWindow();
|
||||
GL11.glViewport(0, 0, window.width(), window.height());
|
||||
break;
|
||||
}
|
||||
case TextureTarget(AssetLocation id, Texture color, Texture depth) -> {
|
||||
int fbo = fboCache.getOrCreateFBO(id);
|
||||
if(color != null) GL45.glNamedFramebufferTexture(fbo, GL30.GL_COLOR_ATTACHMENT0, ((GLTexture)color).id(), 0);
|
||||
if(depth != null) GL45.glNamedFramebufferTexture(fbo, GL30.GL_DEPTH_ATTACHMENT, ((GLTexture)depth).id(), 0);
|
||||
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, fbo);
|
||||
if(color != null) GL11.glViewport(0, 0, color.width(), color.height());
|
||||
else if(depth != null) GL11.glViewport(0, 0, depth.width(), depth.height());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTexture(int clearParam) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTexture(int x, int y, int width, int height, int clearParam) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTexture(Texture texture, int clearParam) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTexture(Texture texture, int x, int y, int width, int height, int clearParam) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToTexture(Texture target, int x, int y, int width, int height, long source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromTexture(Texture source, int x, int y, int width, int height, long target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderPass createRenderPass(RenderTarget target, DrawArea area) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int hasState = 0;
|
||||
int frameBuffer = switch(target) {
|
||||
case ScreenTarget _ -> {
|
||||
Window window = device.getWindow();
|
||||
width = window.width();
|
||||
height = window.height();
|
||||
hasState = HAS_BOTH;
|
||||
yield 0;
|
||||
}
|
||||
case TextureTarget(AssetLocation id, Texture color, Texture depth) -> {
|
||||
int fbo = fboCache.getOrCreateFBO(id);
|
||||
if(color != null) {
|
||||
hasState |= HAS_COLOR;
|
||||
GL45.glNamedFramebufferTexture(fbo, GL30.GL_COLOR_ATTACHMENT0, ((GLTexture)color).id(), 0);
|
||||
}
|
||||
if(depth != null) {
|
||||
hasState |= HAS_DEPTH;
|
||||
GL45.glNamedFramebufferTexture(fbo, GL30.GL_DEPTH_ATTACHMENT, ((GLTexture)depth).id(), 0);
|
||||
}
|
||||
if(color != null) {
|
||||
width = color.width();
|
||||
height = color.height();
|
||||
}
|
||||
else if(depth != null) {
|
||||
width = depth.width();
|
||||
height = depth.height();
|
||||
}
|
||||
yield fbo;
|
||||
}
|
||||
};
|
||||
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, frameBuffer);
|
||||
GL11.glViewport(0, 0, width, height);
|
||||
boolean scissors = area != null && !area.fills(width, height);
|
||||
if(scissors) {
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glScissor(area.x(), area.y(), area.width(), area.height());
|
||||
}
|
||||
return (activePass = new GLRenderPass(this, area, scissors, (hasState & HAS_COLOR) != 0, (hasState & HAS_DEPTH) != 0, frameBuffer));
|
||||
}
|
||||
|
||||
private record PushableObject<T>(T original, T applying, Supplier<T> current, Consumer<T> apply) implements PushableResource {
|
||||
@Override
|
||||
public void close() {
|
||||
if(current.get().equals(applying)) {
|
||||
apply.accept(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -9,36 +9,44 @@ import org.lwjgl.opengl.GL33;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
import org.lwjgl.opengl.GL45;
|
||||
|
||||
import speiger.src.coreengine.assets.base.IAssetProvider;
|
||||
import speiger.src.coreengine.graphics.api.buffer.states.BufferState;
|
||||
import speiger.src.coreengine.graphics.api.buffer.states.BufferType;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsCommandQueue;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsDevice;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsSurface;
|
||||
import speiger.src.coreengine.graphics.api.sampler.SamplerSettings;
|
||||
import speiger.src.coreengine.graphics.api.shader.ShaderPipeline;
|
||||
import speiger.src.coreengine.graphics.api.texture.TextureSettings;
|
||||
import speiger.src.coreengine.graphics.api.texture.states.SwizzleMask;
|
||||
import speiger.src.coreengine.graphics.opengl.buffer.GLVertexBuffer;
|
||||
import speiger.src.coreengine.graphics.opengl.sampler.GLSampler;
|
||||
import speiger.src.coreengine.graphics.opengl.shader.ShaderInstance;
|
||||
import speiger.src.coreengine.graphics.opengl.texture.GLTexture;
|
||||
import speiger.src.coreengine.graphics.opengl.utils.GLFunctions;
|
||||
import speiger.src.coreengine.graphics.opengl.utils.GLUtils;
|
||||
import speiger.src.coreengine.rendering.input.window.Window;
|
||||
|
||||
public class GLGraphicsDevice implements GraphicsDevice {
|
||||
GLCommandQueue queue;
|
||||
Window owner;
|
||||
|
||||
public GLGraphicsDevice(Window owner) {
|
||||
this.owner = owner;
|
||||
this.queue = new GLCommandQueue(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicsSurface createSurface() {
|
||||
public Window getWindow() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GLSurface createSurface() {
|
||||
return new GLSurface(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicsCommandQueue getQueue() {
|
||||
return null;
|
||||
public GLCommandQueue getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,4 +84,10 @@ public class GLGraphicsDevice implements GraphicsDevice {
|
||||
public GLSampler createSampler(SamplerSettings settings) {
|
||||
return new GLSampler(Objects.requireNonNull(settings));
|
||||
}
|
||||
|
||||
public ShaderInstance createShader(ShaderPipeline line, IAssetProvider provider) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package speiger.src.coreengine.graphics.opengl.shader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL45;
|
||||
|
||||
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
|
||||
import speiger.src.collections.objects.misc.pairs.ObjectObjectPair;
|
||||
import speiger.src.coreengine.graphics.api.buffer.VertexBuffer;
|
||||
import speiger.src.coreengine.graphics.api.buffer.states.IndeciesType;
|
||||
import speiger.src.coreengine.graphics.api.core.GraphicsCommandQueue.DrawArea;
|
||||
import speiger.src.coreengine.graphics.api.sampler.Sampler;
|
||||
import speiger.src.coreengine.graphics.api.shader.CompiledPipeline;
|
||||
import speiger.src.coreengine.graphics.api.shader.RenderPass;
|
||||
import speiger.src.coreengine.graphics.api.shader.ShaderPipeline;
|
||||
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||
import speiger.src.coreengine.graphics.opengl.core.GLCommandQueue;
|
||||
|
||||
public class GLRenderPass extends RenderPass {
|
||||
boolean scissors;
|
||||
GLCommandQueue queue;
|
||||
int fbo;
|
||||
VertexBuffer[] buffers = new VertexBuffer[4];
|
||||
Map<String, ObjectObjectPair<Texture, Sampler>> textures = Object2ObjectMap.builder().linkedMap();
|
||||
Map<String, VertexBuffer> uniforms = Object2ObjectMap.builder().linkedMap();
|
||||
VertexBuffer indecies;
|
||||
IndeciesType indeciesType;
|
||||
ShaderPipeline pipeline;
|
||||
CompiledPipeline compiled;
|
||||
|
||||
public GLRenderPass(GLCommandQueue queue, DrawArea area, boolean scissors, boolean hasColor, boolean hasDepth, int fbo) {
|
||||
super(area, hasColor, hasDepth);
|
||||
this.scissors = scissors;
|
||||
this.queue = queue;
|
||||
this.fbo = fbo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShader(ShaderPipeline pipeline) {
|
||||
this.pipeline = Objects.requireNonNull(pipeline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexture(String name, Texture texture, Sampler sampler) {
|
||||
Objects.requireNonNull(name, "Sampler Name is needed");
|
||||
Objects.requireNonNull(texture, "Texture is required");
|
||||
Objects.requireNonNull(sampler, "Sampler is required");
|
||||
textures.put(name, ObjectObjectPair.of(texture, sampler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTextures() {
|
||||
textures.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTexture(String name) {
|
||||
Objects.requireNonNull(name, "Sampler Name is needed");
|
||||
textures.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUniform(String name, VertexBuffer buffer) {
|
||||
Objects.requireNonNull(name, "Uniform name is needed");
|
||||
Objects.requireNonNull(buffer, "Vertex Buffer is required");
|
||||
uniforms.put(name, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndecies(VertexBuffer buffer, IndeciesType type) {
|
||||
indecies = Objects.requireNonNull(buffer, "Buffer is required");
|
||||
indeciesType = Objects.requireNonNull(type, "Type is required");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearIndecies() {
|
||||
indecies = null;
|
||||
indeciesType = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVertexBuffer(int index, VertexBuffer buffer) {
|
||||
if(index < 0 || index >= 4) throw new ArrayIndexOutOfBoundsException(index);
|
||||
buffers[index] = buffer;
|
||||
}
|
||||
|
||||
public void applyState() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if(fbo == -1) return;
|
||||
if(scissors) GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
if(fbo != 0) GL45.glBindFramebuffer(GL45.GL_DRAW_FRAMEBUFFER, 0);
|
||||
fbo = -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package speiger.src.coreengine.graphics.opengl.shader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.internal.Streams;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import speiger.src.collections.objects.maps.impl.hash.Object2ObjectOpenHashMap;
|
||||
import speiger.src.coreengine.assets.AssetLocation;
|
||||
|
||||
public class ShaderCache {
|
||||
public static final ShaderCache INSTANCE = new ShaderCache();
|
||||
Map<AssetLocation, String> hashCache;
|
||||
Path cache;
|
||||
|
||||
public void init(Path cache) {
|
||||
this.cache = cache;
|
||||
if(Files.notExists(cache)) {
|
||||
try { Files.createDirectories(cache); }
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
this.cache = null;
|
||||
}
|
||||
}
|
||||
try(BufferedReader reader = Files.newBufferedReader(cache.resolve("cache.json"))) {
|
||||
Map<AssetLocation, String> knownCache = new Object2ObjectOpenHashMap<>();
|
||||
for(JsonElement element : JsonParser.parseReader(reader).getAsJsonObject().getAsJsonArray("shaders")) {
|
||||
JsonObject shader = element.getAsJsonObject();
|
||||
knownCache.put(AssetLocation.of(shader.get("id").getAsString()), shader.get("hash").getAsString());
|
||||
}
|
||||
hashCache = knownCache;
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
hashCache = new Object2ObjectOpenHashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
JsonArray array = new JsonArray();
|
||||
hashCache.forEach((K, V) -> {
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.addProperty("id", K.toString());
|
||||
obj.addProperty("hash", V);
|
||||
array.add(obj);
|
||||
});
|
||||
try(JsonWriter writer = new JsonWriter(Files.newBufferedWriter(cache.resolve("cache.json")))) {
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.add("shaders", array);
|
||||
writer.setIndent("\t");
|
||||
Streams.write(obj, writer);
|
||||
}
|
||||
catch(Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
public byte[] get(AssetLocation shaderLocation, String fileHash) {
|
||||
String known = hashCache.get(shaderLocation);
|
||||
if(!Objects.equals(known, fileHash)) return null;
|
||||
Path path = toFile(shaderLocation);
|
||||
if(Files.notExists(path)) return null;
|
||||
try { return Files.readAllBytes(path); }
|
||||
catch(Exception e) { e.printStackTrace(); }
|
||||
return null;
|
||||
}
|
||||
|
||||
public void store(AssetLocation shaderLocation, String fileHash, byte[] shader) {
|
||||
Objects.requireNonNull(shaderLocation);
|
||||
Objects.requireNonNull(fileHash);
|
||||
Objects.requireNonNull(shader);
|
||||
hashCache.put(shaderLocation, fileHash);
|
||||
try {
|
||||
Path file = toFile(shaderLocation);
|
||||
if(Files.notExists(file.getParent())) Files.createDirectories(file.getParent());
|
||||
Files.write(file, shader);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public void delete(AssetLocation shaderLocation) {
|
||||
if(hashCache.remove(shaderLocation) == null) return;
|
||||
try { Files.deleteIfExists(toFile(shaderLocation)); }
|
||||
catch(Exception e) { e.printStackTrace(); }
|
||||
save();
|
||||
}
|
||||
|
||||
private Path toFile(AssetLocation id) {
|
||||
return cache.resolve(id.domain()).resolve(id.location()+".bin");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package speiger.src.coreengine.graphics.opengl.shader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public record ShaderInstance(int programId, Map<String, UniformObject> uniforms, Map<String, SamplerObject> samplers) {
|
||||
|
||||
public record UniformObject(int slot) {}
|
||||
public record SamplerObject(int unit) {}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package speiger.src.coreengine.graphics.opengl.texture;
|
||||
|
||||
import org.lwjgl.opengl.GL45;
|
||||
|
||||
import speiger.src.collections.objects.maps.impl.hash.Object2IntOpenHashMap;
|
||||
import speiger.src.collections.objects.maps.interfaces.Object2IntMap;
|
||||
import speiger.src.coreengine.assets.AssetLocation;
|
||||
|
||||
public class FrameBufferCache {
|
||||
Object2IntMap<AssetLocation> fboCache = new Object2IntOpenHashMap<>();
|
||||
|
||||
public int getOrCreateFBO(AssetLocation id) {
|
||||
return fboCache.supplyIntIfAbsent(id, GL45::glCreateFramebuffers);
|
||||
}
|
||||
|
||||
public void deleteFBO(AssetLocation id) {
|
||||
int fbo = fboCache.rem(id);
|
||||
if(fbo == -1) return;
|
||||
GL45.glDeleteFramebuffers(fbo);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
GL45.glDeleteFramebuffers(fboCache.values().toIntArray());
|
||||
fboCache.clear();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,10 @@ public class GLTexture extends Texture {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return id == 0;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.lwjgl.opengl.GL43;
|
||||
import org.lwjgl.system.Configuration;
|
||||
import org.lwjgl.util.freetype.FreeType;
|
||||
|
||||
|
||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.coreengine.assets.AssetLocation;
|
||||
import speiger.src.coreengine.assets.AssetManager;
|
||||
@@ -19,7 +18,6 @@ import speiger.src.coreengine.assets.base.IAssetProvider;
|
||||
import speiger.src.coreengine.math.vector.matrix.Matrix4f;
|
||||
import speiger.src.coreengine.rendering.gui.font.Font;
|
||||
import speiger.src.coreengine.rendering.gui.font.FontManager;
|
||||
import speiger.src.coreengine.rendering.gui.font.TextStyle;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.Glyth;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.IGlythSheetInfo;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.MissingGlyth;
|
||||
@@ -157,11 +155,11 @@ public class NewInputTest {
|
||||
// });
|
||||
|
||||
// String s = "The Quick brown fox Jumps over the Lazy dog";
|
||||
float x = 50;
|
||||
float y = 50;
|
||||
float scale = 1F;
|
||||
y /= scale;
|
||||
TextStyle style = TextStyle.DEFAULT.size(12).bold(false);
|
||||
// float x = 50;
|
||||
// float y = 50;
|
||||
// float scale = 1F;
|
||||
// y /= scale;
|
||||
// TextStyle style = TextStyle.DEFAULT.size(12).bold(false);
|
||||
// font.drawText(style, "Testing My Theory", x, y, -1, buffer, scale, true);
|
||||
// float offset = font.drawText(style, "The Quick ", 50, y, -1, buffer, scale, false);
|
||||
// offset += font.drawText(style, "Brown ", 50+offset, y, -1, buffer, scale, false);
|
||||
@@ -169,7 +167,7 @@ public class NewInputTest {
|
||||
// offset += font.drawText(style, "Jumps ", 50+offset, y, -1, buffer, scale, false);
|
||||
// offset += font.drawText(style, "over the Lazy dog", 50+offset, y, -1, buffer, scale, true);
|
||||
// font.drawText(s, 50, 50, -1, buffer, true);
|
||||
GLStateTracker tracker = GLStateTracker.instance();
|
||||
// GLStateTracker tracker = GLStateTracker.instance();
|
||||
GL11.glClearColor(0.2F, 0.55F, 0.66F, 1F);
|
||||
while(!window.shouldClose()) {
|
||||
GLFW.glfwPollEvents();
|
||||
@@ -215,7 +213,7 @@ public class NewInputTest {
|
||||
GL11.glClearColor(0.4F, 0.55F, 0.36F, 1F);
|
||||
int size = 512;
|
||||
int half = size >> 1;
|
||||
int base = size >> 3;
|
||||
// int base = size >> 3;
|
||||
|
||||
DynamicTexture texture = new DynamicTexture(size, size, DynamicTexture.DEFAULT_PARAMETERS);
|
||||
texture.fill(0, 0, size, size, -1);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class LanguageManager implements IReloadableResource {
|
||||
String key = subArray.get(0).getAsString();
|
||||
String value = subArray.get(1).getAsString();
|
||||
if(key.length() != 2 || value.length() > 16) continue;
|
||||
languages.computeIfAbsent(key, T -> new Language(key, value));
|
||||
languages.computeIfAbsent(key, _ -> new Language(key, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package speiger.src.coreengine.math.vector;
|
||||
|
||||
import speiger.src.coreengine.math.vector.floats.Vec2f;
|
||||
import speiger.src.coreengine.math.vector.floats.Vec3f;
|
||||
|
||||
public class VectorUtil
|
||||
{
|
||||
public static float barryCentric(Vec3f p1, Vec3f p2, Vec3f p3, Vec2f pos)
|
||||
{
|
||||
float det = (p2.z() - p3.z()) * (p1.x() - p3.x()) + (p3.x() - p2.x()) * (p1.z() - p3.z());
|
||||
float l1 = ((p2.z() - p3.z()) * (pos.x() - p3.x()) + (p3.x() - p2.x()) * (pos.y() - p3.z())) / det;
|
||||
float l2 = ((p3.z() - p1.z()) * (pos.x() - p3.x()) + (p1.x() - p3.x()) * (pos.y() - p3.z())) / det;
|
||||
float l3 = 1.0f - l1 - l2;
|
||||
return l1 * p1.y() + l2 * p2.y() + l3 * p3.y();
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Vec2bImmutable implements Vec2b {
|
||||
final byte x;
|
||||
final byte y;
|
||||
|
||||
public Vec2bImmutable() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
public Vec2bImmutable(byte value) {
|
||||
x = value;
|
||||
y = value;
|
||||
}
|
||||
|
||||
public Vec2bImmutable(byte x, byte y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public byte x() { return x; }
|
||||
@Override
|
||||
public byte y() { return y; }
|
||||
@Override
|
||||
public Vec2b x(byte x) { return this.x == x ? this : Vec2b.of(x, y); }
|
||||
@Override
|
||||
public Vec2b y(byte y) { return this.y == y ? this : Vec2b.of(x, y); }
|
||||
@Override
|
||||
public Vec2b copy() { return Vec2b.of(this); }
|
||||
@Override
|
||||
public Vec2b set(byte x, byte y) { return this.x == x && this.y == y ? this : Vec2b.of(x, y); }
|
||||
@Override
|
||||
public int hashCode() { return Objects.hash(x, y); }
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Vec2b) {
|
||||
Vec2b vec = (Vec2b)obj;
|
||||
return vec.x() == x && vec.y() == y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return "Vec2b[x="+x+", y="+y+"]"; }
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Vec3bImmutable implements Vec3b {
|
||||
final byte x;
|
||||
final byte y;
|
||||
final byte z;
|
||||
|
||||
public Vec3bImmutable() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
public Vec3bImmutable(byte value) {
|
||||
x = value;
|
||||
y = value;
|
||||
z = value;
|
||||
}
|
||||
|
||||
public Vec3bImmutable(byte x, byte y, byte z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public byte x() { return x; }
|
||||
@Override
|
||||
public byte y() { return y; }
|
||||
@Override
|
||||
public byte z() { return z; }
|
||||
@Override
|
||||
public Vec3b x(byte x) { return this.x == x ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b y(byte y) { return this.y == y ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b z(byte z) { return this.z == z ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b copy() { return Vec3b.of(this); }
|
||||
@Override
|
||||
public Vec3b set(byte x, byte y, byte z) { return this.x == x && this.y == y && this.z == z ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public int hashCode() { return Objects.hash(x, y, z); }
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Vec3b) {
|
||||
Vec3b vec = (Vec3b)obj;
|
||||
return vec.x() == x && vec.y() == y && vec.z() == z;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return "Vec3b[x="+x+", y="+y+", z="+z+"]"; }
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Vec4bImmutable implements Vec4b {
|
||||
final byte x;
|
||||
final byte y;
|
||||
final byte z;
|
||||
final byte w;
|
||||
|
||||
public Vec4bImmutable() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
w = 0;
|
||||
}
|
||||
|
||||
public Vec4bImmutable(byte value) {
|
||||
x = value;
|
||||
y = value;
|
||||
z = value;
|
||||
w = value;
|
||||
}
|
||||
|
||||
public Vec4bImmutable(byte x, byte y, byte z, byte w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public byte x() { return x; }
|
||||
@Override
|
||||
public byte y() { return y; }
|
||||
@Override
|
||||
public byte z() { return z; }
|
||||
@Override
|
||||
public byte w() { return w; }
|
||||
@Override
|
||||
public Vec4b x(byte x) { return this.x == x ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b y(byte y) { return this.y == y ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b z(byte z) { return this.z == z ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b w(byte w) { return this.w == w ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b copy() { return Vec4b.of(this); }
|
||||
@Override
|
||||
public Vec4b set(byte x, byte y, byte z, byte w) { return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public int hashCode() { return Objects.hash(x, y, z, w); }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Vec4b) {
|
||||
Vec4b vec = (Vec4b)obj;
|
||||
return vec.x() == x && vec.y() == y && vec.z() == z && vec.w() == w;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return "Vec4b[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
|
||||
}
|
||||
+1
-1
@@ -18,9 +18,9 @@ import speiger.src.coreengine.assets.base.IAssetProvider;
|
||||
import speiger.src.coreengine.assets.parsers.NativeMemoryParser;
|
||||
import speiger.src.coreengine.rendering.gui.font.FontTexture;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.Glyth;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.IGlythSheetInfo;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.UnbakedGlyth;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.UnbakedGlyth.EmptyGlythData;
|
||||
import speiger.src.coreengine.rendering.gui.font.glyth.IGlythSheetInfo;
|
||||
import speiger.src.coreengine.rendering.textures.custom.Drawable;
|
||||
import speiger.src.coreengine.utils.helpers.JsonUtil;
|
||||
|
||||
|
||||
@@ -690,7 +690,7 @@ public abstract class GuiComponent extends FlagHolder
|
||||
|
||||
public final GuiComponent addListener(Runnable runnable, int index)
|
||||
{
|
||||
listeners[index].add(T -> runnable.run());
|
||||
listeners[index].add(_ -> runnable.run());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import speiger.src.coreengine.rendering.guiOld.renderer.FontRenderer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.GuiShader;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.UIRenderer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.provider.FontManager;
|
||||
import speiger.src.coreengine.rendering.inputOld.events.MouseEvent;
|
||||
import speiger.src.coreengine.rendering.inputOld.events.KeyEvent.CharTypeEvent;
|
||||
import speiger.src.coreengine.rendering.inputOld.events.KeyEvent.KeyPressEvent;
|
||||
import speiger.src.coreengine.rendering.inputOld.events.MouseEvent;
|
||||
import speiger.src.coreengine.rendering.inputOld.window.IWindowListener;
|
||||
import speiger.src.coreengine.rendering.inputOld.window.ScaledResolution;
|
||||
import speiger.src.coreengine.rendering.inputOld.window.Window;
|
||||
|
||||
+1
-1
@@ -13,8 +13,8 @@ import speiger.src.coreengine.rendering.guiOld.base.IButtonComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.list.SelectionEntry;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.Align;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.box.IGuiBox;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.UIRenderer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.buffer.RenderBuffer;
|
||||
import speiger.src.coreengine.rendering.tesselationOld.Tesselator;
|
||||
|
||||
+1
-1
@@ -9,9 +9,9 @@ import speiger.src.coreengine.math.misc.Facing;
|
||||
import speiger.src.coreengine.rendering.guiOld.GuiComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.base.IButtonComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.Align;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.DynamicConstrain;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
|
||||
public class SingleTabPanelComponent extends PanelComponent
|
||||
{
|
||||
|
||||
+1
-1
@@ -9,9 +9,9 @@ import speiger.src.coreengine.math.misc.Facing;
|
||||
import speiger.src.coreengine.rendering.guiOld.GuiComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.base.IButtonComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.Align;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.DynamicConstrain;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
|
||||
public class TabbedPanelComponent extends PanelComponent
|
||||
{
|
||||
|
||||
+1
-1
@@ -11,8 +11,8 @@ import speiger.src.coreengine.rendering.guiOld.base.IKeyComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.Align;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.box.IGuiBox;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.box.ParentBox;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.UIRenderer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.TextMetadata;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.Word;
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@ public class ColorPickerWindowComponent extends WindowComponent
|
||||
addBox(selectedBox);
|
||||
addChild(brightness.onChange(minimizedListener).onAction(T -> setColor(hsv[0], hsv[1], T.cast(SliderComponent.class).getValue() * 0.01F)));
|
||||
addChild(saturation.onChange(minimizedListener).onAction(T -> setColor(hsv[0], T.cast(SliderComponent.class).getValue() * 0.01F, hsv[2])));
|
||||
addChild(code.setScale(0.5F).onChange(minimizedListener).onAction(T -> onTyped()));
|
||||
addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Select", ColorUtils.GREEN).setScale(0.4F).onAction(T -> apply()), new Constrains(null, new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null));
|
||||
addChild(code.setScale(0.5F).onChange(minimizedListener).onAction(_ -> onTyped()));
|
||||
addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Select", ColorUtils.GREEN).setScale(0.4F).onAction(_ -> apply()), new Constrains(null, new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null));
|
||||
addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Cancel", ColorUtils.RED).setScale(0.4F).onAction(T -> T.getGui().removeComponent(this)), new Constrains(new RelativeConstrain(0.5F), new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null));
|
||||
setColor(hsv[0], hsv[1], hsv[2]);
|
||||
}
|
||||
|
||||
+3
-3
@@ -15,17 +15,17 @@ import speiger.src.coreengine.math.misc.Facing;
|
||||
import speiger.src.coreengine.math.vector.floats.Vec2f;
|
||||
import speiger.src.coreengine.rendering.guiOld.base.IKeyComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.PieComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.PieComponent.IPieIndex;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.PieComponent.PieIndex;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.SingleTabPanelComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.TextComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.WindowComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.PieComponent.IPieIndex;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.PieComponent.PieIndex;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.Align;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.DynamicConstrain;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.PixelConstrain;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.inputOld.Keyboard;
|
||||
import speiger.src.coreengine.utils.profiler.IProfiler;
|
||||
import speiger.src.coreengine.utils.profiler.IProfiler.IProfilerEntry;
|
||||
|
||||
+2
-2
@@ -14,15 +14,15 @@ import speiger.src.coreengine.rendering.guiOld.components.SingleTabPanelComponen
|
||||
import speiger.src.coreengine.rendering.guiOld.components.TreeComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.WindowComponent;
|
||||
import speiger.src.coreengine.rendering.guiOld.components.tree.ProfilerTreeEntry;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrain.Target;
|
||||
import speiger.src.coreengine.rendering.guiOld.helper.constrains.Constrains;
|
||||
import speiger.src.coreengine.utils.profiler.IProfiler;
|
||||
import speiger.src.coreengine.utils.profiler.IProfiler.IProfilerEntry;
|
||||
|
||||
public class TreeProfilerWindow extends WindowComponent
|
||||
{
|
||||
IntPriorityQueue todoList = new IntArrayFIFOQueue().synchronizeQueue();
|
||||
ObjIntConsumer<IProfiler> listener = (T, V) -> todoList.enqueue(V);
|
||||
ObjIntConsumer<IProfiler> listener = (_, V) -> todoList.enqueue(V);
|
||||
SingleTabPanelComponent panel = new SingleTabPanelComponent(Facing.SOUTH).onAction(this::onProfilerChanged).cast();
|
||||
TreeComponent<ProfilerTreeEntry> tree = panel.addChild(new TreeComponent<>(ColorUtils.GRAY, 9F).disableBackground(true).setSelectionMode(TreeComponent.SELECTION_MODE_INTERACT).cast(), Constrains.parent(Target.WIDTH).parent(4, Target.HEIGHT).build());
|
||||
List<ProfilerTab> tabs = new ObjectArrayList<>();
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ public class ChoiceComponent extends WindowComponent
|
||||
super.init();
|
||||
yesButton.getText().setTextScale(0.5F);
|
||||
noButton.getText().setTextScale(0.5F);
|
||||
addChild(yesButton.onChange(minimizedListener).onAction(closeListener).onAction(T -> listener.accept(true)), new Constrains(new RelativeConstrain(0F), new ParentConstrain(10F).invert(), new RelativeConstrain(0.5F), new PixelConstrain(10F)));
|
||||
addChild(noButton.onChange(minimizedListener).onAction(closeListener).onAction(T -> listener.accept(false)), new Constrains(new RelativeConstrain(0.5F), new ParentConstrain(10F).invert(), new RelativeConstrain(0.5F), new PixelConstrain(10F)));
|
||||
addChild(yesButton.onChange(minimizedListener).onAction(closeListener).onAction(_ -> listener.accept(true)), new Constrains(new RelativeConstrain(0F), new ParentConstrain(10F).invert(), new RelativeConstrain(0.5F), new PixelConstrain(10F)));
|
||||
addChild(noButton.onChange(minimizedListener).onAction(closeListener).onAction(_ -> listener.accept(false)), new Constrains(new RelativeConstrain(0.5F), new ParentConstrain(10F).invert(), new RelativeConstrain(0.5F), new PixelConstrain(10F)));
|
||||
addChild(message, new Constrains(new PixelConstrain(10F), new PixelConstrain(11F), new ParentConstrain(10F), TextConstrain.height(message)));
|
||||
getBox().setHeight(25F + message.getMetadata().getMaxHeight());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import speiger.src.coreengine.rendering.guiOld.renderer.buffer.RenderBuffer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.buffer.TranslatedVertexBuilder;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.Line;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.TextContext;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.TextLexer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.TextContext.WordContext;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.lexer.TextLexer;
|
||||
import speiger.src.coreengine.rendering.guiOld.renderer.provider.IFontProvider;
|
||||
import speiger.src.coreengine.rendering.models.DrawCall;
|
||||
import speiger.src.coreengine.rendering.tesselationOld.IVertexBuilder;
|
||||
|
||||
@@ -66,10 +66,10 @@ public class Window
|
||||
|
||||
protected void initWindowListeners() {
|
||||
addCallback(T -> GLFW.glfwSetFramebufferSizeCallback(T, this::onResize));
|
||||
addCallback(T -> GLFW.glfwSetWindowMaximizeCallback(T, (K, V) -> flags.setFlag(FLAG_WINDOW_CHANGE)));
|
||||
addCallback(T -> GLFW.glfwSetWindowPosCallback(T, (W, X, Y) -> setPosition(X, Y)));
|
||||
addCallback(T -> GLFW.glfwSetWindowFocusCallback(T, (K, V) -> flags.setFlag(FLAG_FOCUS, V)));
|
||||
addCallback(T -> GLFW.glfwSetErrorCallback(this::error));
|
||||
addCallback(T -> GLFW.glfwSetWindowMaximizeCallback(T, (_, _) -> flags.setFlag(FLAG_WINDOW_CHANGE)));
|
||||
addCallback(T -> GLFW.glfwSetWindowPosCallback(T, (_, X, Y) -> setPosition(X, Y)));
|
||||
addCallback(T -> GLFW.glfwSetWindowFocusCallback(T, (_, V) -> flags.setFlag(FLAG_FOCUS, V)));
|
||||
addCallback(_ -> GLFW.glfwSetErrorCallback(this::error));
|
||||
}
|
||||
|
||||
private void error(int error, long text) {
|
||||
|
||||
@@ -6,8 +6,8 @@ import speiger.src.coreengine.math.vector.floats.Vec2f;
|
||||
import speiger.src.coreengine.math.vector.floats.Vec3f;
|
||||
import speiger.src.coreengine.rendering.models.DrawCall;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexElement;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexElement.Usage;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
||||
import speiger.src.coreengine.rendering.utils.values.GLMode;
|
||||
|
||||
public class Tesselator implements IVertexBuilder
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package speiger.src.coreengine.rendering.tesselationOld;
|
||||
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexElement;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexElement.Usage;
|
||||
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
||||
|
||||
public class VertexType
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ import java.util.function.Predicate;
|
||||
|
||||
public class Functions
|
||||
{
|
||||
static final Predicate<Object> ALWAYS_TRUE = (T) -> true;
|
||||
static final Consumer<Object> EMPTY_CONSUMER = (T) -> {};
|
||||
static final Predicate<Object> ALWAYS_TRUE = _ -> true;
|
||||
static final Consumer<Object> EMPTY_CONSUMER = _ -> {};
|
||||
public static final Predicate<String> NUMBERS_ONLY = T -> {
|
||||
if(T.isEmpty() || T.equals("#") || T.equals("0x")) return true;
|
||||
try { return Long.decode(T) != null; }
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package speiger.src.coreengine.utils.io.dataTag.compression;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface DataTagLimiter {
|
||||
public static final DataTagLimiter INFINTE = T -> {};
|
||||
public static final DataTagLimiter INFINTE = _ -> {};
|
||||
|
||||
public static DataTagLimiter limit(int byteLimit) {
|
||||
return new Instance(byteLimit);
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,23 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
public record Vec2bImmutable(byte x, byte y) implements Vec2b {
|
||||
|
||||
public Vec2bImmutable() {
|
||||
this((byte)0, (byte)0);
|
||||
}
|
||||
|
||||
public Vec2bImmutable(byte value) {
|
||||
this(value, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public Vec2b x(byte x) { return this.x == x ? this : Vec2b.of(x, y); }
|
||||
@Override
|
||||
public Vec2b y(byte y) { return this.y == y ? this : Vec2b.of(x, y); }
|
||||
@Override
|
||||
public Vec2b copy() { return Vec2b.of(this); }
|
||||
@Override
|
||||
public Vec2b set(byte x, byte y) { return this.x == x && this.y == y ? this : Vec2b.of(x, y); }
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,25 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
public record Vec3bImmutable(byte x, byte y, byte z) implements Vec3b {
|
||||
|
||||
public Vec3bImmutable() {
|
||||
this((byte)0, (byte)0, (byte)0);
|
||||
}
|
||||
|
||||
public Vec3bImmutable(byte value) {
|
||||
this(value, value, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public Vec3b x(byte x) { return this.x == x ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b y(byte y) { return this.y == y ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b z(byte z) { return this.z == z ? this : Vec3b.of(x, y, z); }
|
||||
@Override
|
||||
public Vec3b copy() { return Vec3b.of(this); }
|
||||
@Override
|
||||
public Vec3b set(byte x, byte y, byte z) { return this.x == x && this.y == y && this.z == z ? this : Vec3b.of(x, y, z); }
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,27 @@
|
||||
package speiger.src.coreengine.math.vector.bytes;
|
||||
|
||||
public record Vec4bImmutable(byte x, byte y, byte z, byte w) implements Vec4b {
|
||||
|
||||
public Vec4bImmutable() {
|
||||
this((byte)0, (byte)0, (byte)0, (byte)0);
|
||||
}
|
||||
|
||||
public Vec4bImmutable(byte value) {
|
||||
this(value, value, value, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() { return false; }
|
||||
@Override
|
||||
public Vec4b x(byte x) { return this.x == x ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b y(byte y) { return this.y == y ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b z(byte z) { return this.z == z ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b w(byte w) { return this.w == w ? this : Vec4b.of(x, y, z, w); }
|
||||
@Override
|
||||
public Vec4b copy() { return Vec4b.of(this); }
|
||||
@Override
|
||||
public Vec4b set(byte x, byte y, byte z, byte w) { return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4b.of(x, y, z, w); }
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user