mirror of
https://github.com/GTNewHorizons/lwjgl3ify.git
synced 2026-11-27 23:45:50 +00:00
Add *Buffer transformations
This commit is contained in:
1 parent
882d7a8c48
commit
33fc6611b3
171 files changed
+7677
-2577
No files matched your search
@@ -0,0 +1,72 @@
|
||||
package me.eigenraven.lwjgl3ify;
|
||||
|
||||
import java.nio.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class BufferCasts {
|
||||
public static ByteBuffer toByteBuffer(CharBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asCharBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
public static ByteBuffer toByteBuffer(ShortBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asShortBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
public static ByteBuffer toByteBuffer(IntBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asIntBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
public static ByteBuffer toByteBuffer(LongBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asLongBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
public static ByteBuffer toByteBuffer(FloatBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asFloatBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
public static ByteBuffer toByteBuffer(DoubleBuffer buffer) {
|
||||
ByteBuffer newBuffer = ByteBuffer.allocateDirect(buffer.capacity() * 4);
|
||||
newBuffer.asDoubleBuffer().put(buffer);
|
||||
return newBuffer;
|
||||
}
|
||||
|
||||
public static void updateBuffer(CharBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asCharBuffer());
|
||||
}
|
||||
public static void updateBuffer(ShortBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asShortBuffer());
|
||||
}
|
||||
public static void updateBuffer(IntBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asIntBuffer());
|
||||
}
|
||||
public static void updateBuffer(LongBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asLongBuffer());
|
||||
}
|
||||
public static void updateBuffer(FloatBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asFloatBuffer());
|
||||
}
|
||||
public static void updateBuffer(DoubleBuffer destination, ByteBuffer source) {
|
||||
destination.clear();
|
||||
destination.put(source.asDoubleBuffer());
|
||||
}
|
||||
|
||||
public static CharSequence bufferToCharSeq(ByteBuffer buffer) {
|
||||
if (buffer.hasArray()) {
|
||||
return new String(buffer.array(), StandardCharsets.UTF_8);
|
||||
} else {
|
||||
byte[] tmp = new byte[buffer.remaining()];
|
||||
buffer.get(tmp);
|
||||
return new String(tmp, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ import java.util.HashMap;
|
||||
public final class ALCdevice {
|
||||
|
||||
/** Address of actual device */
|
||||
final long device;
|
||||
public final long device;
|
||||
|
||||
/** Whether this device is valid */
|
||||
private boolean valid;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.lwjglx.opengl;
|
||||
|
||||
public class ARBBufferObject {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.lwjglx.opengl;
|
||||
|
||||
public class ARBProgram {
|
||||
}
|
||||
Reference in new issue
Block a user