Search in sources :

Example 1 with RecyclableByteBuffer

use of io.xol.chunkstories.api.rendering.vertex.RecyclableByteBuffer in project chunkstories by Hugobros3.

the class VertexBufferGL method uploadData.

/* (non-Javadoc)
	 * @see io.xol.engine.graphics.geometry.VertexBuffer#uploadData(io.xol.chunkstories.renderer.buffers.ByteBufferPool.RecyclableByteBuffer)
	 */
@Override
public Fence uploadData(RecyclableByteBuffer dataToUpload) {
    if (glID == -2)
        throw new RuntimeException("Illegal operation : Attempted to upload data to a destroyed VerticesObject !");
    // Queue for immediate upload
    if (Client.getInstance().getGameWindow().isMainGLWindow()) {
        Object replacing = waitingToUploadMainThread;
        waitingToUploadMainThread = dataToUpload;
        if (replacing != null && replacing != dataToUpload && replacing instanceof RecyclableByteBuffer) {
            // System.out.println("Watch out, uploading two RecyclableByteBuffer in a row, the first one is getting recycled early to prevent locks");
            RecyclableByteBuffer rcb = (RecyclableByteBuffer) replacing;
            rcb.recycle();
        }
        dataSize = dataToUpload.accessByteBuffer().limit();
        return new TrivialFence();
    }
    // This is a deffered call
    return setAsyncDataPendingUpload(dataToUpload);
// pendingAsyncUpload = dataToUpload;
// return false;
}
Also used : TrivialFence(io.xol.chunkstories.util.concurrency.TrivialFence) RecyclableByteBuffer(io.xol.chunkstories.api.rendering.vertex.RecyclableByteBuffer)

Aggregations

RecyclableByteBuffer (io.xol.chunkstories.api.rendering.vertex.RecyclableByteBuffer)1 TrivialFence (io.xol.chunkstories.util.concurrency.TrivialFence)1