mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-01 01:46:39 +01:00
Remove compat layer wrapper functions
This commit is contained in:
parent
83dc241cd2
commit
128a2c2e06
8 changed files with 132 additions and 127 deletions
|
@ -126,6 +126,7 @@ public class SphereFilterProgram extends GlProgram {
|
|||
public Vector3d center;
|
||||
public float radius;
|
||||
public float feather;
|
||||
public float fade;
|
||||
public float strength = 1;
|
||||
public boolean hsv;
|
||||
|
||||
|
@ -146,6 +147,11 @@ public class SphereFilterProgram extends GlProgram {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterSphere setFade(float fade) {
|
||||
this.fade = fade;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterSphere setStrength(float strength) {
|
||||
this.strength = strength;
|
||||
return this;
|
||||
|
@ -168,9 +174,9 @@ public class SphereFilterProgram extends GlProgram {
|
|||
(float) center.z,
|
||||
radius,
|
||||
feather,
|
||||
fade,
|
||||
strength,
|
||||
hsv ? 1f : 0f,
|
||||
0 // padding, we could add more parameters here
|
||||
});
|
||||
|
||||
buf.put(RenderUtil.writeMatrix(filter));
|
||||
|
|
|
@ -48,15 +48,15 @@ public class GlBuffer extends GlObject {
|
|||
}
|
||||
|
||||
public void map(int length, Consumer<ByteBuffer> upload) {
|
||||
Backend.compat.mapBuffer(bufferType, 0, length, upload);
|
||||
Backend.compat.mapBuffer.mapBuffer(bufferType, 0, length, upload);
|
||||
}
|
||||
|
||||
public void map(int offset, int length, Consumer<ByteBuffer> upload) {
|
||||
Backend.compat.mapBuffer(bufferType, offset, length, upload);
|
||||
Backend.compat.mapBuffer.mapBuffer(bufferType, offset, length, upload);
|
||||
}
|
||||
|
||||
public void map(int type, int offset, int length, Consumer<ByteBuffer> upload) {
|
||||
Backend.compat.mapBuffer(type, offset, length, upload);
|
||||
Backend.compat.mapBuffer.mapBuffer(type, offset, length, upload);
|
||||
}
|
||||
|
||||
protected void deleteInternal(int handle) {
|
||||
|
|
|
@ -6,15 +6,15 @@ import com.simibubi.create.foundation.render.backend.Backend;
|
|||
|
||||
public class GlVertexArray extends GlObject {
|
||||
public GlVertexArray() {
|
||||
setHandle(Backend.compat.genVertexArrays());
|
||||
setHandle(Backend.compat.vao.genVertexArrays());
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
Backend.compat.bindVertexArray(handle());
|
||||
Backend.compat.vao.bindVertexArray(handle());
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
Backend.compat.bindVertexArray(0);
|
||||
Backend.compat.vao.bindVertexArray(0);
|
||||
}
|
||||
|
||||
public void with(Consumer<GlVertexArray> action) {
|
||||
|
@ -24,6 +24,6 @@ public class GlVertexArray extends GlObject {
|
|||
}
|
||||
|
||||
protected void deleteInternal(int handle) {
|
||||
Backend.compat.deleteVertexArrays(handle);
|
||||
Backend.compat.vao.deleteVertexArrays(handle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.foundation.render.backend.gl.versioned;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
|
@ -10,58 +9,44 @@ import org.lwjgl.opengl.GLCapabilities;
|
|||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Blit;
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Framebuffer;
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.DrawInstanced;
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.InstancedArrays;
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.VertexArrayObject;
|
||||
|
||||
/**
|
||||
* An instance of this class stores information
|
||||
* about what OpenGL features are available.
|
||||
*
|
||||
* <p>
|
||||
* Each field stores an enum variant that provides access to the
|
||||
* most appropriate version of a feature for the current system.
|
||||
*/
|
||||
public class GlCompat {
|
||||
public final MapBuffer mapBuffer;
|
||||
|
||||
public final VertexArrayObject vertexArrayObject;
|
||||
public final VertexArrayObject vao;
|
||||
public final InstancedArrays instancedArrays;
|
||||
public final DrawInstanced drawInstanced;
|
||||
public final Blit blit;
|
||||
public final Framebuffer fbo;
|
||||
|
||||
public final RGPixelFormat pixelFormat;
|
||||
|
||||
public GlCompat(GLCapabilities caps) {
|
||||
mapBuffer = getLatest(MapBuffer.class, caps);
|
||||
|
||||
vertexArrayObject = getLatest(VertexArrayObject.class, caps);
|
||||
vao = getLatest(VertexArrayObject.class, caps);
|
||||
instancedArrays = getLatest(InstancedArrays.class, caps);
|
||||
drawInstanced = getLatest(DrawInstanced.class, caps);
|
||||
blit = getLatest(Blit.class, caps);
|
||||
fbo = getLatest(Framebuffer.class, caps);
|
||||
|
||||
pixelFormat = getLatest(RGPixelFormat.class, caps);
|
||||
}
|
||||
|
||||
public void mapBuffer(int target, int offset, int length, Consumer<ByteBuffer> upload) {
|
||||
mapBuffer.mapBuffer(target, offset, length, upload);
|
||||
}
|
||||
|
||||
public void vertexAttribDivisor(int index, int divisor) {
|
||||
instancedArrays.vertexAttribDivisor(index, divisor);
|
||||
}
|
||||
|
||||
public void drawArraysInstanced(int mode, int first, int count, int primcount) {
|
||||
drawInstanced.drawArraysInstanced(mode, first, count, primcount);
|
||||
}
|
||||
|
||||
public int genVertexArrays() {
|
||||
return vertexArrayObject.genVertexArrays();
|
||||
}
|
||||
|
||||
public void deleteVertexArrays(int array) {
|
||||
vertexArrayObject.deleteVertexArrays(array);
|
||||
}
|
||||
|
||||
public void bindVertexArray(int array) {
|
||||
vertexArrayObject.bindVertexArray(array);
|
||||
}
|
||||
|
||||
public boolean vertexArrayObjectsSupported() {
|
||||
return vertexArrayObject != VertexArrayObject.UNSUPPORTED;
|
||||
return vao != VertexArrayObject.UNSUPPORTED;
|
||||
}
|
||||
|
||||
public boolean instancedArraysSupported() {
|
||||
|
@ -72,6 +57,14 @@ public class GlCompat {
|
|||
return drawInstanced != DrawInstanced.UNSUPPORTED;
|
||||
}
|
||||
|
||||
public boolean fbosSupported() {
|
||||
return fbo != Framebuffer.UNSUPPORTED;
|
||||
}
|
||||
|
||||
public boolean blitSupported() {
|
||||
return blit != Blit.UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most compatible version of a specific OpenGL feature by iterating over enum constants in order.
|
||||
*
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.simibubi.create.foundation.render.backend.gl.versioned;
|
||||
package com.simibubi.create.foundation.render.backend.gl.versioned.instancing;
|
||||
|
||||
import org.lwjgl.opengl.ARBDrawInstanced;
|
||||
import org.lwjgl.opengl.EXTDrawInstanced;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned;
|
||||
|
||||
public enum DrawInstanced implements GlVersioned {
|
||||
GL31_DRAW_INSTANCED {
|
||||
@Override
|
|
@ -1,9 +1,11 @@
|
|||
package com.simibubi.create.foundation.render.backend.gl.versioned;
|
||||
package com.simibubi.create.foundation.render.backend.gl.versioned.instancing;
|
||||
|
||||
import org.lwjgl.opengl.ARBInstancedArrays;
|
||||
import org.lwjgl.opengl.GL33;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned;
|
||||
|
||||
public enum InstancedArrays implements GlVersioned {
|
||||
GL33_INSTANCED_ARRAYS {
|
||||
@Override
|
|
@ -1,9 +1,11 @@
|
|||
package com.simibubi.create.foundation.render.backend.gl.versioned;
|
||||
package com.simibubi.create.foundation.render.backend.gl.versioned.instancing;
|
||||
|
||||
import org.lwjgl.opengl.ARBVertexArrayObject;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned;
|
||||
|
||||
public enum VertexArrayObject implements GlVersioned {
|
||||
GL30_VAO {
|
||||
@Override
|
|
@ -83,7 +83,7 @@ public abstract class InstancedModel<D extends InstanceData> extends BufferedMod
|
|||
renderSetup();
|
||||
|
||||
if (glInstanceCount > 0)
|
||||
Backend.compat.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount);
|
||||
Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ public abstract class InstancedModel<D extends InstanceData> extends BufferedMod
|
|||
getInstanceFormat().vertexAttribPointers(staticAttributes);
|
||||
|
||||
for (int i = 0; i < getInstanceFormat().getShaderAttributeCount(); i++) {
|
||||
Backend.compat.vertexAttribDivisor(i + staticAttributes, 1);
|
||||
Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue