Allow for custom GlAbstractTessellation implementations #15

Closed
venn0 wants to merge 1 commits from venn0/celeritas:ven-dev into stonecutter
pull from: venn0/celeritas:ven-dev
3 changed files with 8 additions and 1 deletions
Showing only changes of commit 10c3b78d7e - Show all commits

No files matched your search

@@ -9,6 +9,7 @@ import org.embeddedt.embeddium.impl.gl.tessellation.*;
import org.embeddedt.embeddium.impl.gl.util.EnumBitField;
import org.lwjgl.opengl.*;
import java.nio.ByteBuffer;
import java.util.function.BiFunction;
public class GLRenderDevice implements RenderDevice {
private final GlStateTracker stateTracker = new GlStateTracker();
@@ -24,6 +25,7 @@ public class GLRenderDevice implements RenderDevice {
public static Runnable VANILLA_STATE_RESETTER = () -> {
throw new IllegalStateException("The host mod should replace the VANILLA_STATE_RESETTER with an implementation specific to the platform.");
};
public static BiFunction<GlVertexArray, TessellationBinding[], GlAbstractTessellation> GL_TESSELLATION_PROVIDER = GlVertexArrayTessellation::new;
@Override
public CommandList createCommandList() {
@@ -257,7 +259,7 @@ public class GLRenderDevice implements RenderDevice {
@Override
public GlTessellation createTessellation(TessellationBinding[] bindings) {
GlVertexArrayTessellation tessellation = new GlVertexArrayTessellation(new GlVertexArray(), bindings);
GlAbstractTessellation tessellation = GL_TESSELLATION_PROVIDER.apply(new GlVertexArray(), bindings);
tessellation.init(this);
return tessellation;
@@ -12,6 +12,10 @@ public abstract class GlAbstractTessellation implements GlTessellation {
this.bindings = bindings;
}
public void init(CommandList commandList) {
}
protected void bindAttributes(CommandList commandList) {
for (TessellationBinding binding : this.bindings) {
commandList.bindBuffer(binding.target(), binding.buffer());
@@ -12,6 +12,7 @@ public class GlVertexArrayTessellation extends GlAbstractTessellation {
this.array = array;
}
@Override
public void init(CommandList commandList) {
this.bind(commandList);
this.bindAttributes(commandList);