Search in sources :

Example 11 with GLRenderableUpdateTask

use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.

the class NodeLabelBatcher method createBatch.

@Override
public GLRenderableUpdateTask createBatch(final VisualAccess access) throws InterruptedException {
    final NodeGlyphStream topGlyphStream = new NodeGlyphStream();
    final NodeGlyphStream bottomGlyphStream = new NodeGlyphStream();
    fillTopLabels(access, topGlyphStream);
    fillBottomLabels(access, bottomGlyphStream);
    return gl -> {
        topBatch.initialise(topGlyphStream.getCurrentFloats().size() / FLOAT_BUFFERS_WIDTH);
        topBatch.buffer(gl, labelFloatsTarget, FloatBuffer.wrap(topGlyphStream.getCurrentFloats().rawArray()));
        topBatch.buffer(gl, labelIntsTarget, IntBuffer.wrap(topGlyphStream.getCurrentInts().rawArray()));
        topBatch.finalise(gl);
        bottomBatch.initialise(bottomGlyphStream.getCurrentFloats().size() / FLOAT_BUFFERS_WIDTH);
        bottomBatch.buffer(gl, labelFloatsTarget, FloatBuffer.wrap(bottomGlyphStream.getCurrentFloats().rawArray()));
        bottomBatch.buffer(gl, labelIntsTarget, IntBuffer.wrap(bottomGlyphStream.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 12 with GLRenderableUpdateTask

use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.

the class NodeLabelBatcher method setTopLabelColors.

public GLRenderableUpdateTask setTopLabelColors(final VisualAccess access) {
    final int numTopLabels = Math.min(LabelUtilities.MAX_LABELS_TO_DRAW, access.getTopLabelCount());
    for (int i = 0; i < numTopLabels; i++) {
        final ConstellationColor labelColor = access.getTopLabelColor(i);
        labelTopInfoReference.setRow(labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue(), labelTopInfoReference.get(i, 3), i);
    }
    return gl -> labelTopInfo.set(labelTopInfoReference);
}
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 13 with GLRenderableUpdateTask

use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.

the class SceneBatcher method updateIntBufferTask.

public static GLRenderableUpdateTask updateIntBufferTask(final VisualChange change, final VisualAccess access, final IntBufferOperation operation, final IntBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
    final int width = updateMask.length;
    final int numChanges = change.getSize();
    final IntBuffer updateBuffer = Buffers.newDirectIntBuffer(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 IntBuffer 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) IntBuffer(java.nio.IntBuffer)

Example 14 with GLRenderableUpdateTask

use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.

the class SceneBatcher method updateFloatBufferTask.

public static GLRenderableUpdateTask updateFloatBufferTask(final VisualChange change, final VisualAccess access, final FloatBufferOperation operation, final FloatBufferConnection connector, final BufferDisconnection disconnector, final boolean[] updateMask) {
    final int width = updateMask.length;
    final int numChanges = change.getSize();
    final FloatBuffer updateBuffer = Buffers.newDirectFloatBuffer(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 FloatBuffer 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) FloatBuffer(java.nio.FloatBuffer)

Example 15 with GLRenderableUpdateTask

use of au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask in project constellation by constellation-app.

the class XyzTexturiser method createTexture.

public GLRenderableUpdateTask createTexture(final VisualAccess access) {
    final FloatBuffer xyzBuffer = Buffers.newDirectFloatBuffer(XYZ_BUFFER_WIDTH * access.getVertexCount());
    for (int i = 0; i < access.getVertexCount(); i++) {
        bufferXyzInfo(i, xyzBuffer, access);
    }
    xyzBuffer.flip();
    return gl -> xyzTexture = new FloatTextureBuffer(gl, xyzBuffer);
}
Also used : FloatTextureBuffer(au.gov.asd.tac.constellation.visual.opengl.utilities.FloatTextureBuffer) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) VisualAccess(au.gov.asd.tac.constellation.utilities.visual.VisualAccess) FloatBuffer(java.nio.FloatBuffer) SceneBatcher(au.gov.asd.tac.constellation.visual.opengl.renderer.batcher.SceneBatcher) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) FloatBuffer(java.nio.FloatBuffer) FloatTextureBuffer(au.gov.asd.tac.constellation.visual.opengl.utilities.FloatTextureBuffer)

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