Protect against java versioning

- Cast ByteBuffers to Buffer before calling #rewind or #flip
This commit is contained in:
Jozufozu 2021-07-12 16:45:36 -07:00
parent 5d47cc6136
commit 07a2cfd7db
4 changed files with 8 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
@ -182,7 +183,7 @@ public class ShaderSources implements ISelectiveResourceReloadListener {
try {
bytebuffer = readToBuffer(is);
int i = bytebuffer.position();
bytebuffer.rewind();
((Buffer) bytebuffer).rewind();
return MemoryUtil.memASCII(bytebuffer, i);
} catch (IOException e) {

View File

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.backend.gl.buffer;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -29,7 +30,7 @@ public class VecBuffer {
}
public VecBuffer rewind() {
internal.rewind();
((Buffer) internal).rewind();
return this;
}

View File

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.backend.instancing;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
@ -137,7 +138,7 @@ public class InstanceMaterial<D extends InstanceData> {
vertices.putFloat(reader.getV(i));
}
vertices.rewind();
((Buffer) vertices).rewind();
// return new BufferedModel(GlPrimitive.QUADS, format, vertices, vertexCount);

View File

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.core;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.EnumMap;
@ -136,7 +137,7 @@ public class QuadConverter {
type.castAndBuffer(indices, i + 2);
type.castAndBuffer(indices, i + 3);
}
indices.flip();
((Buffer) indices).flip();
}
private GlBuffer getBuffer(GlNumericType type) {