mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-29 08:26:37 +01:00
Add RecordingVertexConsumer
- Very basic and untested
This commit is contained in:
parent
7b3bab6647
commit
da55941e4f
3 changed files with 88 additions and 3 deletions
|
@ -42,9 +42,9 @@ public enum GlError {
|
||||||
|
|
||||||
public static void pollAndThrow(Supplier<String> context) {
|
public static void pollAndThrow(Supplier<String> context) {
|
||||||
// TODO: build flag? to enable or disable this function
|
// TODO: build flag? to enable or disable this function
|
||||||
GlError poll = GlError.poll();
|
GlError err = GlError.poll();
|
||||||
if (poll != null) {
|
if (err != null) {
|
||||||
Flywheel.log.error("{}: {}", poll.name(), context.get());
|
Flywheel.log.error("{}: {}", err.name(), context.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.jozufozu.flywheel.core.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
|
||||||
|
public class RecordingVertexConsumer implements VertexConsumer {
|
||||||
|
|
||||||
|
List<Consumer<VertexConsumer>> replay = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer vertex(double x, double y, double z) {
|
||||||
|
replay.add(v -> v.vertex(x, y, z));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer color(int r, int g, int b, int a) {
|
||||||
|
replay.add(v -> v.color(r, g, b, a));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer uv(float u, float v) {
|
||||||
|
replay.add(vc -> vc.uv(u, v));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer overlayCoords(int u, int v) {
|
||||||
|
replay.add(vc -> vc.overlayCoords(u, v));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer uv2(int u, int v) {
|
||||||
|
replay.add(vc -> vc.uv2(u, v));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VertexConsumer normal(float x, float y, float z) {
|
||||||
|
replay.add(v -> v.normal(x, y, z));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endVertex() {
|
||||||
|
replay.add(VertexConsumer::endVertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void defaultColor(int r, int g, int b, int a) {
|
||||||
|
replay.add(vc -> vc.defaultColor(r, g, b, a));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unsetDefaultColor() {
|
||||||
|
replay.add(VertexConsumer::unsetDefaultColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VertexRecording saveRecording() {
|
||||||
|
VertexRecording out = new VertexRecording(ImmutableList.copyOf(replay));
|
||||||
|
replay.clear();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.jozufozu.flywheel.core.model;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
|
||||||
|
public record VertexRecording(ImmutableList<Consumer<VertexConsumer>> recording) {
|
||||||
|
|
||||||
|
public void replay(VertexConsumer vc) {
|
||||||
|
for (Consumer<VertexConsumer> consumer : recording) {
|
||||||
|
consumer.accept(vc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue