Search in sources :

Example 6 with GLRenderableUpdateTask

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);
        }
    };
}
Also used : GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LabelUtilities(au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) ArrayList(java.util.ArrayList) ConnectionDirection(au.gov.asd.tac.constellation.utilities.visual.VisualAccess.ConnectionDirection) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) List(java.util.List) TreeMap(java.util.TreeMap) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) SortedMap(java.util.SortedMap) IntBuffer(java.nio.IntBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 7 with GLRenderableUpdateTask

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);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream) GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LabelUtilities(au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities) IOException(java.io.IOException) ArrayList(java.util.ArrayList) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) NodeGlyphStreamContext(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStreamContext) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) Collections(java.util.Collections)

Example 8 with GLRenderableUpdateTask

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);
    };
}
Also used : GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) Arrays(java.util.Arrays) GL3(com.jogamp.opengl.GL3) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) FloatBuffer(java.nio.FloatBuffer) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) ByteBuffer(java.nio.ByteBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 9 with GLRenderableUpdateTask

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);
    };
}
Also used : NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream) GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LabelUtilities(au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities) IOException(java.io.IOException) ArrayList(java.util.ArrayList) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) NodeGlyphStreamContext(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStreamContext) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) Collections(java.util.Collections) NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream)

Example 10 with GLRenderableUpdateTask

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);
    };
}
Also used : NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream) GL3(com.jogamp.opengl.GL3) TextureUnits(au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) FloatBuffer(java.nio.FloatBuffer) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LabelUtilities(au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities) IOException(java.io.IOException) ArrayList(java.util.ArrayList) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) IntBuffer(java.nio.IntBuffer) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) NodeGlyphStreamContext(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStreamContext) Matrix44f(au.gov.asd.tac.constellation.utilities.graphics.Matrix44f) GL(com.jogamp.opengl.GL) Collections(java.util.Collections) NodeGlyphStream(au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream)

Aggregations

VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)19 GLRenderableUpdateTask (au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask)19 FloatBuffer (java.nio.FloatBuffer)18 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)17 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)17 GL3 (com.jogamp.opengl.GL3)17 IOException (java.io.IOException)17 IntBuffer (java.nio.IntBuffer)17 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)14 TextureUnits (au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits)14 SharedDrawable (au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable)14 GL (com.jogamp.opengl.GL)14 Buffers (com.jogamp.common.nio.Buffers)11 LabelUtilities (au.gov.asd.tac.constellation.visual.opengl.utilities.LabelUtilities)9 ArrayList (java.util.ArrayList)9 VisualChange (au.gov.asd.tac.constellation.utilities.visual.VisualChange)8 Arrays (java.util.Arrays)6 GLTools (au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools)5 NodeGlyphStream (au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStream)5 NodeGlyphStreamContext (au.gov.asd.tac.constellation.visual.opengl.utilities.glyphs.NodeGlyphStreamContext)5