Skip to content

Commit

Permalink
Rename NIOBufferUtil to BufferUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldexun committed Jun 19, 2023
1 parent a9d64a1 commit bffae42
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/main/java/meldexun/renderlib/util/BoundingBoxHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import meldexun.matrixutil.Matrix4f;
import meldexun.renderlib.RenderLib;
import meldexun.renderlib.api.IBoundingBoxCache;
import meldexun.renderlib.util.memory.NIOBufferUtil;
import meldexun.renderlib.util.memory.BufferUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
Expand All @@ -30,7 +30,7 @@ public class BoundingBoxHelper {
public BoundingBoxHelper() {
cubeVertexBuffer = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, cubeVertexBuffer);
NIOBufferUtil.tempByteBuffer(new byte[] {
BufferUtil.tempByteBuffer(new byte[] {
0, 0, 0,
0, 0, 1,
0, 1, 0,
Expand All @@ -44,7 +44,7 @@ public BoundingBoxHelper() {

quadsCubeIndexBuffer = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, quadsCubeIndexBuffer);
NIOBufferUtil.tempByteBuffer(new byte[] {
BufferUtil.tempByteBuffer(new byte[] {
0, 4, 5, 1,
3, 7, 6, 2,
4, 0, 2, 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.function.LongFunction;
import java.util.function.ObjLongConsumer;

public class NIOBufferUtil {
public class BufferUtil {

private static final ByteOrder NATIVE_ORDER = ByteOrder.nativeOrder();

Expand Down Expand Up @@ -135,31 +135,31 @@ private static <T extends Buffer> T asBuffer(Class<T> clazz, long address, long
}

public static void tempByteBuffer(long capacity, Consumer<ByteBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateByte, consumer);
tempBuffer(capacity, BufferUtil::allocateByte, consumer);
}

public static void tempShortBuffer(long capacity, Consumer<ShortBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateShort, consumer);
tempBuffer(capacity, BufferUtil::allocateShort, consumer);
}

public static void tempIntBuffer(long capacity, Consumer<IntBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateInt, consumer);
tempBuffer(capacity, BufferUtil::allocateInt, consumer);
}

public static void tempLongBuffer(long capacity, Consumer<LongBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateLong, consumer);
tempBuffer(capacity, BufferUtil::allocateLong, consumer);
}

public static void tempFloatBuffer(long capacity, Consumer<FloatBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateFloat, consumer);
tempBuffer(capacity, BufferUtil::allocateFloat, consumer);
}

public static void tempDoubleBuffer(long capacity, Consumer<DoubleBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateDouble, consumer);
tempBuffer(capacity, BufferUtil::allocateDouble, consumer);
}

public static void tempCharBuffer(long capacity, Consumer<CharBuffer> consumer) {
tempBuffer(capacity, NIOBufferUtil::allocateChar, consumer);
tempBuffer(capacity, BufferUtil::allocateChar, consumer);
}

private static <T extends Buffer> void tempBuffer(long capacity, LongFunction<T> bufferFactory, Consumer<T> consumer) {
Expand All @@ -173,31 +173,31 @@ private static <T extends Buffer> void tempBuffer(long capacity, LongFunction<T>
}

public static void tempByteBuffer(byte[] data, Consumer<ByteBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateByte, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateByte, MemoryUtil::copyMemory, consumer);
}

public static void tempShortBuffer(short[] data, Consumer<ShortBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateShort, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateShort, MemoryUtil::copyMemory, consumer);
}

public static void tempIntBuffer(int[] data, Consumer<IntBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateInt, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateInt, MemoryUtil::copyMemory, consumer);
}

public static void tempLongBuffer(long[] data, Consumer<LongBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateLong, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateLong, MemoryUtil::copyMemory, consumer);
}

public static void tempFloatBuffer(float[] data, Consumer<FloatBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateFloat, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateFloat, MemoryUtil::copyMemory, consumer);
}

public static void tempDoubleBuffer(double[] data, Consumer<DoubleBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateDouble, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateDouble, MemoryUtil::copyMemory, consumer);
}

public static void tempCharBuffer(char[] data, Consumer<CharBuffer> consumer) {
tempBuffer(data, NIOBufferUtil::allocateChar, MemoryUtil::copyMemory, consumer);
tempBuffer(data, BufferUtil::allocateChar, MemoryUtil::copyMemory, consumer);
}

private static <A, T extends Buffer> void tempBuffer(A data, LongFunction<T> bufferFactory, ObjLongConsumer<A> copyFunction, Consumer<T> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public UnsafeByteBuffer(long address, long capacity) {

@Override
protected ByteBuffer createBuffer() {
return NIOBufferUtil.asByteBuffer(getAddress(), getCapacity());
return BufferUtil.asByteBuffer(getAddress(), getCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getCharCapacity() {

@Override
protected CharBuffer createBuffer() {
return NIOBufferUtil.asCharBuffer(getAddress(), getCharCapacity());
return BufferUtil.asCharBuffer(getAddress(), getCharCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getDoubleCapacity() {

@Override
protected DoubleBuffer createBuffer() {
return NIOBufferUtil.asDoubleBuffer(getAddress(), getDoubleCapacity());
return BufferUtil.asDoubleBuffer(getAddress(), getDoubleCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getFloatCapacity() {

@Override
protected FloatBuffer createBuffer() {
return NIOBufferUtil.asFloatBuffer(getAddress(), getFloatCapacity());
return BufferUtil.asFloatBuffer(getAddress(), getFloatCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getIntCapacity() {

@Override
protected IntBuffer createBuffer() {
return NIOBufferUtil.asIntBuffer(getAddress(), getIntCapacity());
return BufferUtil.asIntBuffer(getAddress(), getIntCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getLongCapacity() {

@Override
protected LongBuffer createBuffer() {
return NIOBufferUtil.asLongBuffer(getAddress(), getLongCapacity());
return BufferUtil.asLongBuffer(getAddress(), getLongCapacity());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public long getShortCapacity() {

@Override
protected ShortBuffer createBuffer() {
return NIOBufferUtil.asShortBuffer(getAddress(), getShortCapacity());
return BufferUtil.asShortBuffer(getAddress(), getShortCapacity());
}

}

0 comments on commit bffae42

Please sign in to comment.