use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class LineBatcher method createBatch.
@Override
public GLRenderableUpdateTask createBatch(final VisualAccess access) {
int lineCounter = 0;
for (int link = 0; link < access.getLinkCount(); link++) {
if (access.getLinkSource(link) != access.getLinkDestination(link)) {
connections.add(NEW_LINK);
for (int pos = 0; pos < access.getLinkConnectionCount(link); pos++) {
final int connection = access.getLinkConnection(link, pos);
connectionPosToBufferPos.put(connection, lineCounter++);
connections.add(connection);
}
}
}
final int numLines = lineCounter;
FloatBuffer colorBuffer = Buffers.newDirectFloatBuffer(numLines * 2 * COLOR_BUFFER_WIDTH);
IntBuffer dataBuffer = Buffers.newDirectIntBuffer(numLines * 2 * CONNECTION_INFO_BUFFER_WIDTH);
connections.forEach(pos -> {
if (pos == NEW_LINK) {
leftOffset = 0;
} else {
bufferColorInfo(pos, colorBuffer, access);
bufferConnectionInfo(pos, dataBuffer, access);
}
});
colorBuffer.flip();
dataBuffer.flip();
return gl -> {
if (numLines > 0) {
batch.initialise(numLines * 2);
batch.buffer(gl, colorTarget, colorBuffer);
batch.buffer(gl, connectionInfoTarget, dataBuffer);
batch.finalise(gl);
}
};
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class NodeLabelBatcher method setBottomLabelColors.
public GLRenderableUpdateTask setBottomLabelColors(final VisualAccess access) {
final int numBottomLabels = Math.min(LabelUtilities.MAX_LABELS_TO_DRAW, access.getBottomLabelCount());
for (int i = 0; i < numBottomLabels; i++) {
final ConstellationColor labelColor = access.getBottomLabelColor(i);
labelBottomInfoReference.setRow(labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue(), labelBottomInfoReference.get(i, 3), i);
}
return gl -> labelBottomInfo.set(labelBottomInfoReference);
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class SceneBatcher method updateByteBufferTask.
public static GLRenderableUpdateTask updateByteBufferTask(final VisualChange change, final VisualAccess access, final ByteBufferOperation operation, final ByteBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
final int width = updateMask.length;
final int numChanges = change.getSize();
final ByteBuffer updateBuffer = Buffers.newDirectByteBuffer(width * numChanges);
final int[] bufferUpdatePositions = new int[numChanges];
int updatePos = 0;
for (int i = 0; i < numChanges; i++) {
int pos = change.getElement(i);
final int updatedPosition = operation.buffer(pos, updateBuffer, access);
if (updatedPosition >= 0) {
bufferUpdatePositions[updatePos++] = updatedPosition;
}
}
final int numUpdates = updatePos;
updateBuffer.flip();
return gl -> {
final ByteBuffer buffer = connector.connect(gl);
for (int i = 0; i < numUpdates; i++) {
buffer.position(bufferUpdatePositions[i] * width);
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 NodeLabelBatcher method updateBottomLabels.
public GLRenderableUpdateTask updateBottomLabels(final VisualAccess access) throws InterruptedException {
// We build the whole batch again - can't update labels in place at this stage.
final NodeGlyphStream glyphStream = new NodeGlyphStream();
fillBottomLabels(access, glyphStream);
return gl -> {
bottomBatch.dispose(gl);
bottomBatch.initialise(glyphStream.getCurrentFloats().size() / FLOAT_BUFFERS_WIDTH);
bottomBatch.buffer(gl, labelFloatsTarget, FloatBuffer.wrap(glyphStream.getCurrentFloats().rawArray()));
bottomBatch.buffer(gl, labelIntsTarget, IntBuffer.wrap(glyphStream.getCurrentInts().rawArray()));
bottomBatch.finalise(gl);
};
}
use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.
the class NodeLabelBatcher method updateTopLabels.
public GLRenderableUpdateTask updateTopLabels(final VisualAccess access) throws InterruptedException {
// We build the whole batch again - can't update labels in place at this stage.
final NodeGlyphStream glyphStream = new NodeGlyphStream();
fillTopLabels(access, glyphStream);
return gl -> {
topBatch.dispose(gl);
topBatch.initialise(glyphStream.getCurrentFloats().size() / FLOAT_BUFFERS_WIDTH);
topBatch.buffer(gl, labelFloatsTarget, FloatBuffer.wrap(glyphStream.getCurrentFloats().rawArray()));
topBatch.buffer(gl, labelIntsTarget, IntBuffer.wrap(glyphStream.getCurrentInts().rawArray()));
topBatch.finalise(gl);
};
}
Aggregations