Search in sources :

Example 16 with GLRenderableUpdateTask

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);
    };
}
Also used : Arrays(java.util.Arrays) 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) IOException(java.io.IOException) GL2ES3(com.jogamp.opengl.GL2ES3) 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) 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) GLTools(au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools) IntBuffer(java.nio.IntBuffer)

Example 17 with GLRenderableUpdateTask

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);
    };
}
Also used : Arrays(java.util.Arrays) 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) IOException(java.io.IOException) GL2ES3(com.jogamp.opengl.GL2ES3) 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) 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) GLTools(au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools) FloatBuffer(java.nio.FloatBuffer)

Example 18 with GLRenderableUpdateTask

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);
        }
    };
}
Also used : IconManager(au.gov.asd.tac.constellation.utilities.icon.IconManager) 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) IOException(java.io.IOException) GL2ES3(com.jogamp.opengl.GL2ES3) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) 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) 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) GLTools(au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools) IntBuffer(java.nio.IntBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 19 with GLRenderableUpdateTask

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);
        }
    };
}
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) IOException(java.io.IOException) VisualChange(au.gov.asd.tac.constellation.utilities.visual.VisualChange) GLRenderableUpdateTask(au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask) Buffers(com.jogamp.common.nio.Buffers) 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) GLTools(au.gov.asd.tac.constellation.visual.opengl.utilities.GLTools) SortedMap(java.util.SortedMap) IntBuffer(java.nio.IntBuffer) FloatBuffer(java.nio.FloatBuffer)

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