lower opengl requirement to 2.1 when higher versions are unsupported #21

Closed
rdh wants to merge 10 commits from rdh/celeritas:stonecutter into stonecutter
pull from: rdh/celeritas:stonecutter
Showing only changes of commit a6719412d4 - Show all commits
@@ -2,8 +2,11 @@ package org.embeddedt.embeddium.impl.gl.tessellation;
import org.embeddedt.embeddium.impl.gl.attribute.GlVertexAttributeBinding; import org.embeddedt.embeddium.impl.gl.attribute.GlVertexAttributeBinding;
import org.embeddedt.embeddium.impl.gl.device.CommandList; import org.embeddedt.embeddium.impl.gl.device.CommandList;
import org.lwjgl.opengl.EXTGPUShader4;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL20C; import org.lwjgl.opengl.GL20C;
import org.lwjgl.opengl.GL30C; import org.lwjgl.opengl.GL30C;
import org.lwjgl.opengl.GLCapabilities;
public abstract class GlAbstractTessellation implements GlTessellation { public abstract class GlAbstractTessellation implements GlTessellation {
protected final TessellationBinding[] bindings; protected final TessellationBinding[] bindings;
@@ -17,14 +20,26 @@ public abstract class GlAbstractTessellation implements GlTessellation {
commandList.bindBuffer(binding.target(), binding.buffer()); commandList.bindBuffer(binding.target(), binding.buffer());
for (GlVertexAttributeBinding attrib : binding.attributeBindings()) { for (GlVertexAttributeBinding attrib : binding.attributeBindings()) {
int index = attrib.getIndex();
int size = attrib.getCount();
int type = attrib.getFormat().typeId();
int stride = attrib.getStride();
long pointer = attrib.getPointer();
if (attrib.isIntType()) { if (attrib.isIntType()) {
GL30C.glVertexAttribIPointer(attrib.getIndex(), attrib.getCount(), attrib.getFormat().typeId(), GLCapabilities caps = GL.getCapabilities();
attrib.getStride(), attrib.getPointer());
if (caps.OpenGL30) {
GL30C.glVertexAttribIPointer(index, size, type, stride, pointer);
} else if (caps.GL_EXT_gpu_shader4) {
EXTGPUShader4.glVertexAttribIPointerEXT(index, size, type, stride, pointer);
} else { } else {
GL20C.glVertexAttribPointer(attrib.getIndex(), attrib.getCount(), attrib.getFormat().typeId(), attrib.isNormalized(), GL20C.glVertexAttribPointer(index, size, type, false, stride, pointer);
attrib.getStride(), attrib.getPointer());
} }
GL20C.glEnableVertexAttribArray(attrib.getIndex()); } else {
GL20C.glVertexAttribPointer(index, size, type, attrib.isNormalized(), stride, pointer);
}
GL20C.glEnableVertexAttribArray(index);
} }
} }
} }