lower opengl requirement to 2.1 when higher versions are unsupported #21
@@ -10,6 +10,8 @@ import org.embeddedt.embeddium.impl.gl.util.EnumBitField;
|
||||
import org.embeddedt.embeddium.impl.gl.util.VAOUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.*;
|
||||
import org.lwjgl.system.libc.LibCString;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class GLRenderDevice implements RenderDevice {
|
||||
@@ -109,27 +111,26 @@ public class GLRenderDevice implements RenderDevice {
|
||||
|
||||
@Override
|
||||
public void copyBufferSubData(GlBuffer src, GlBuffer dst, long readOffset, long writeOffset, long bytes) {
|
||||
if (GL.getCapabilities().OpenGL31 || GL.getCapabilities().GL_ARB_copy_buffer) {
|
||||
if(GL.getCapabilities().OpenGL31 || GL.getCapabilities().GL_ARB_copy_buffer) {
|
||||
this.bindBuffer(GlBufferTarget.COPY_READ_BUFFER, src);
|
||||
this.bindBuffer(GlBufferTarget.COPY_WRITE_BUFFER, dst);
|
||||
GL31C.glCopyBufferSubData(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_WRITE_BUFFER, readOffset, writeOffset, bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, src);
|
||||
ByteBuffer srcData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_READ_ONLY, bytes, null);
|
||||
srcData.position((int) readOffset);
|
||||
this.bindBuffer(GlBufferTarget.PIXEL_PACK_BUFFER, src);
|
||||
this.bindBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER, dst);
|
||||
|
||||
GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER);
|
||||
ByteBuffer a = GL15.glMapBuffer(GlBufferTarget.PIXEL_PACK_BUFFER.getTargetParameter(), GL15.GL_READ_ONLY);
|
||||
ByteBuffer b = GL15.glMapBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER.getTargetParameter(), GL15.GL_WRITE_ONLY);
|
||||
|
||||
this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, dst);
|
||||
ByteBuffer dstData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_WRITE_ONLY, null);
|
||||
dstData.position((int) writeOffset);
|
||||
LibCString.memcpy(
|
||||
b.position(Math.toIntExact(writeOffset)).limit(Math.toIntExact(writeOffset + bytes)),
|
||||
a.position(Math.toIntExact(readOffset)).limit(Math.toIntExact(readOffset + bytes))
|
||||
);
|
||||
|
||||
ByteBuffer srcSlice = srcData.slice(0, (int) bytes);
|
||||
dstData.put(srcSlice);
|
||||
|
||||
GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER);
|
||||
GL15.glUnmapBuffer(GlBufferTarget.PIXEL_PACK_BUFFER.getTargetParameter());
|
||||
GL15.glUnmapBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER.getTargetParameter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user