use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class FpsBatcher method updateIcons.
public GLRenderableUpdateTask updateIcons(final int[] digits) {
final IconOperation operation = this::bufferIconInfo;
final IntBufferConnection connector = gl -> batch.connectIntBuffer(gl, iconTarget);
final BufferDisconnection disconnector = gl -> batch.disconnectBuffer(gl, iconTarget);
final int width = ICON_BUFFER_WIDTH;
final boolean[] updateMask = new boolean[width];
Arrays.fill(updateMask, true);
final int maskSize = updateMask.length;
final int numChanges = digits.length;
final IntBuffer updateBuffer = Buffers.newDirectIntBuffer(maskSize * numChanges);
final int[] bufferUpdatePositions = new int[numChanges];
int updatePosition = 0;
for (int i = 0; i < numChanges; i++) {
final int updatedPosition = operation.buffer(i, updateBuffer, digits[i], i * DIGIT_ICON_OFFSET);
if (updatedPosition >= 0) {
bufferUpdatePositions[updatePosition++] = updatedPosition;
}
}
final int numUpdates = updatePosition;
updateBuffer.flip();
return gl -> {
final IntBuffer buffer = connector.connect(gl);
for (int i = 0; i < numUpdates; i++) {
buffer.position(bufferUpdatePositions[i] * maskSize);
for (boolean update : updateMask) {
if (update) {
buffer.put(updateBuffer.get());
} else {
buffer.get();
}
}
}
disconnector.disconnect(gl);
};
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class FpsBatcher method updateColors.
public GLRenderableUpdateTask updateColors(final ConstellationColor color) {
final ColorOperation operation = this::bufferColorInfo;
final FloatBufferConnection connector = gl -> batch.connectFloatBuffer(gl, colorTarget);
final BufferDisconnection disconnector = gl -> batch.disconnectBuffer(gl, colorTarget);
final int width = COLOR_BUFFER_WIDTH;
final boolean[] updateMask = new boolean[width];
Arrays.fill(updateMask, true);
final int maskSize = updateMask.length;
final int numChanges = 2;
final FloatBuffer updateBuffer = Buffers.newDirectFloatBuffer(maskSize * numChanges);
final int[] bufferUpdatePositions = new int[numChanges];
int updatePos = 0;
for (int i = 0; i < numChanges; i++) {
final int updatedPosition = operation.buffer(i, updateBuffer, color);
if (updatedPosition >= 0) {
bufferUpdatePositions[updatePos++] = updatedPosition;
}
}
final int numUpdates = updatePos;
updateBuffer.flip();
return gl -> {
final FloatBuffer buffer = connector.connect(gl);
for (int i = 0; i < numUpdates; i++) {
buffer.position(bufferUpdatePositions[i] * maskSize);
for (boolean update : updateMask) {
if (update) {
buffer.put(updateBuffer.get());
} else {
buffer.get();
}
}
}
disconnector.disconnect(gl);
};
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class IconBatcher method createBatch.
@Override
public GLRenderableUpdateTask createBatch(final VisualAccess access) {
final int numVertices = access.getVertexCount();
final FloatBuffer colorBuffer = Buffers.newDirectFloatBuffer(COLOR_BUFFER_WIDTH * numVertices);
final IntBuffer iconBuffer = Buffers.newDirectIntBuffer(ICON_BUFFER_WIDTH * numVertices);
for (int pos = 0; pos < numVertices; pos++) {
bufferColorInfo(pos, colorBuffer, access);
bufferIconInfo(pos, iconBuffer, access);
}
colorBuffer.flip();
iconBuffer.flip();
return gl -> {
if (numVertices > 0) {
batch.initialise(numVertices);
batch.buffer(gl, colorTarget, colorBuffer);
batch.buffer(gl, iconTarget, iconBuffer);
batch.finalise(gl);
}
};
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class LoopBatcher method createBatch.
@Override
public GLRenderableUpdateTask createBatch(final VisualAccess access) {
int loopCounter = 0;
for (int i = 0; i < access.getConnectionCount(); i++) {
if (access.getConnectionLowVertex(i) == access.getConnectionHighVertex(i)) {
loopPosToBufferPos.put(i, loopCounter++);
}
}
final int numLoops = loopCounter;
FloatBuffer colorBuffer = Buffers.newDirectFloatBuffer(numLoops * COLOR_BUFFER_WIDTH);
IntBuffer dataBuffer = Buffers.newDirectIntBuffer(numLoops * LOOP_INFO_BUFFER_WIDTH);
loopPosToBufferPos.keySet().forEach(pos -> {
bufferColorInfo(pos, colorBuffer, access);
bufferLoopInfo(pos, dataBuffer, access);
});
colorBuffer.flip();
dataBuffer.flip();
return gl -> {
if (numLoops > 0) {
batch.initialise(numLoops);
batch.buffer(gl, colorTarget, colorBuffer);
batch.buffer(gl, loopInfoTarget, dataBuffer);
batch.finalise(gl);
}
};
}
Aggregations