Java Code Examples for com.jogamp.opengl.GL3#glUniform1f()
The following examples show how to use
com.jogamp.opengl.GL3#glUniform1f() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeBatcher.java From constellation with Apache License 2.0 | 6 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (batch.isDrawable()) { gl.glUseProgram(shader); gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(shaderMorphMix, camera.getMix()); gl.glUniform1i(shaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1i(shaderImagesTexture, TextureUnits.ICONS); gl.glUniform1f(shaderScale, blazeSize); gl.glUniform1f(shaderOpacity, blazeOpacity); gl.glDisable(GL3.GL_DEPTH_TEST); batch.draw(gl); gl.glEnable(GL3.GL_DEPTH_TEST); } }
Example 2
Source File: LoopBatcher.java From constellation with Apache License 2.0 | 6 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (batch.isDrawable()) { gl.glUseProgram(shader); // Uniform variables if (drawForHitTest) { gl.glUniform1i(shaderLocDrawHitTest, GL3.GL_TRUE); drawForHitTest = false; } else { gl.glUniform1i(shaderLocDrawHitTest, GL3.GL_FALSE); } gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(shaderMorphMix, camera.getMix()); gl.glUniform1i(shaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1i(shaderImagesTexture, TextureUnits.ICONS); batch.draw(gl); } }
Example 3
Source File: IconBatcher.java From constellation with Apache License 2.0 | 6 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (batch.isDrawable()) { gl.glUseProgram(shader); // Uniform variables if (drawForHitTest) { gl.glUniform1i(shaderLocDrawHitTest, GL3.GL_TRUE); } else { gl.glUniform1i(shaderLocDrawHitTest, GL3.GL_FALSE); } gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(shaderPixelDensity, pixelDensity); gl.glUniform1f(shaderMorphMix, camera.getMix()); gl.glUniform1i(shaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1i(shaderImagesTexture, TextureUnits.ICONS); gl.glUniform1i(shaderFlagsTexture, TextureUnits.VERTEX_FLAGS); gl.glUniformMatrix4fv(shaderHighlightColor, 1, false, highlightColorMatrix, 0); batch.draw(gl); } drawForHitTest = false; }
Example 4
Source File: FpsBatcher.java From constellation with Apache License 2.0 | 6 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (batch.isDrawable()) { gl.glUseProgram(shader); // Uniform variables gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1i(shaderImagesTexture, TextureUnits.ICONS); gl.glUniform1f(shaderPixelDensity, pixelDensity); gl.glUniform1f(shaderPScale, projectionScale); batch.draw(gl); } }
Example 5
Source File: NodeLabelBatcher.java From constellation with Apache License 2.0 | 5 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (topBatch.isDrawable() || bottomBatch.isDrawable()) { gl.glUseProgram(shader); // Let the glyph controller bind the glyph info and glyph image textures SharedDrawable.updateGlyphTextureController(gl); SharedDrawable.getGlyphTextureController().bind(gl, shaderGlyphInfoTexture, TextureUnits.GLYPH_INFO, shaderGlyphImageTexture, TextureUnits.GLYPHS); // Uniform variables gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniformMatrix4fv(shaderLabelBottomInfo, 1, false, labelBottomInfo.a, 0); gl.glUniformMatrix4fv(shaderLabelTopInfo, 1, false, labelTopInfo.a, 0); gl.glUniform1f(shaderLocWidth, SharedDrawable.getGlyphManager().getWidthScalingFactor()); gl.glUniform1f(shaderLocHeight, SharedDrawable.getGlyphManager().getHeightScalingFactor()); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(shaderMorphMix, camera.getMix()); gl.glUniform1i(shaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1i(shaderBackgroundGlyphIndex, SharedDrawable.getLabelBackgroundGlyphPosition()); gl.glUniform4fv(shaderBackgroundColor, 1, backgroundColor, 0); gl.glUniform4fv(shaderHighlightColor, 1, highlightColor, 0); if (topBatch.isDrawable()) { topBatch.draw(gl); } if (bottomBatch.isDrawable()) { bottomBatch.draw(gl); } } }
Example 6
Source File: LineBatcher.java From constellation with Apache License 2.0 | 4 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (batch.isDrawable()) { // Uniform variables gl.glUseProgram(lineShader); if (drawForHitTest) { gl.glUniform1i(lineShaderLocDrawHitTest, GL3.GL_TRUE); gl.glUniform1f(lineShaderDirectionMotion, -1); } else { gl.glUniform1i(lineShaderLocDrawHitTest, GL3.GL_FALSE); gl.glUniform1f(lineShaderDirectionMotion, motion); } gl.glUniformMatrix4fv(lineShaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(lineShaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(lineShaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(lineShaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(lineShaderMorphMix, camera.getMix()); gl.glUniform1i(lineShaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1f(lineShaderAlpha, opacity); gl.glUniform4fv(lineShaderHighlightColor, 1, highlightColor, 0); batch.draw(gl); gl.glUseProgram(lineLineShader); if (drawForHitTest) { gl.glUniform1i(lineLineShaderLocDrawHitTest, GL3.GL_TRUE); gl.glUniform1f(lineLineShaderDirectionMotion, -1); } else { gl.glUniform1i(lineLineShaderLocDrawHitTest, GL3.GL_FALSE); gl.glUniform1f(lineLineShaderDirectionMotion, motion); } gl.glUniformMatrix4fv(lineLineShaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(lineLineShaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(lineLineShaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(lineLineShaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(lineLineShaderMorphMix, camera.getMix()); gl.glUniform1i(lineLineShaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1f(lineLineShaderAlpha, opacity); gl.glUniform4fv(lineLineShaderHighlightColor, 1, highlightColor, 0); batch.draw(gl); } drawForHitTest = false; }
Example 7
Source File: ConnectionLabelBatcher.java From constellation with Apache License 2.0 | 4 votes |
@Override public void drawBatch(final GL3 gl, final Camera camera, final Matrix44f mvMatrix, final Matrix44f pMatrix) { if (attributeLabelBatch.isDrawable() || summaryLabelBatch.isDrawable()) { gl.glUseProgram(shader); // Let the glyph controller bind the glyph info and glyph image textures SharedDrawable.updateGlyphTextureController(gl); SharedDrawable.getGlyphTextureController().bind(gl, shaderGlyphInfoTexture, TextureUnits.GLYPH_INFO, shaderGlyphImageTexture, TextureUnits.GLYPHS); // This is kind of weird - fix this to actually mean something? final int further_f = 0; final int further_u = 1; gl.glPolygonOffset(further_f, further_u); gl.glDepthFunc(GL.GL_LEQUAL); // Uniform variables gl.glUniformMatrix4fv(shaderMVMatrix, 1, false, mvMatrix.a, 0); gl.glUniformMatrix4fv(shaderPMatrix, 1, false, pMatrix.a, 0); gl.glUniform1f(shaderLocWidth, SharedDrawable.getGlyphManager().getWidthScalingFactor()); gl.glUniform1f(shaderLocHeight, SharedDrawable.getGlyphManager().getHeightScalingFactor()); gl.glUniform1f(shaderVisibilityLow, camera.getVisibilityLow()); gl.glUniform1f(shaderVisibilityHigh, camera.getVisibilityHigh()); gl.glUniform1f(shaderMorphMix, camera.getMix()); gl.glUniform1i(shaderXyzTexture, TextureUnits.VERTICES); gl.glUniform1i(shaderBackgroundGlyphIndex, SharedDrawable.getLabelBackgroundGlyphPosition()); gl.glUniform4fv(shaderBackgroundColor, 1, backgroundColor, 0); gl.glUniform4fv(shaderHighlightColor, 1, highlightColor, 0); if (attributeLabelBatch.isDrawable()) { gl.glUniformMatrix4fv(shaderLabelInfo, 1, false, attributeLabelInfo.a, 0); attributeLabelBatch.draw(gl); } if (summaryLabelBatch.isDrawable()) { gl.glUniformMatrix4fv(shaderLabelInfo, 1, false, summaryLabelInfo.a, 0); summaryLabelBatch.draw(gl); } } }
Example 8
Source File: NBodyVisualizer.java From gpu-nbody with MIT License | 4 votes |
/** * Implementation of GLEventListener: Called when the given GLAutoDrawable is to be displayed. */ @Override public void display(final GLAutoDrawable drawable) { if (!initialized) { return; } final GL3 gl = (GL3) drawable.getGL(); // run computation // Map OpenGL buffer object for writing from OpenCL gl.glFinish(); simulation.step(); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Activate the shader program gl.glUseProgram(shaderProgramID); // Set the current projection matrix final int projectionMatrixLocation = gl.glGetUniformLocation(shaderProgramID, "projectionMatrix"); gl.glUniformMatrix4fv(projectionMatrixLocation, 1, false, projectionMatrix, 0); // Set the current modelview matrix final int modelviewMatrixLocation = gl.glGetUniformLocation(shaderProgramID, "modelviewMatrix"); gl.glUniformMatrix4fv(modelviewMatrixLocation, 1, false, modelviewMatrix, 0); final int screenSizeLocation = gl.glGetUniformLocation(shaderProgramID, "screenSize"); gl.glUniform2f(screenSizeLocation, glComponent.getWidth(), glComponent.getHeight()); final int spriteSizeLocation = gl.glGetUniformLocation(shaderProgramID, "spriteSize"); gl.glUniform1f(spriteSizeLocation, 0.1f); bodyTexture.enable(gl); bodyTexture.bind(gl); final int textureLocation = gl.glGetUniformLocation(shaderProgramID, "tex"); gl.glUniform1i(textureLocation, bodyTexture.getTarget()); // Render the VBO gl.glEnable(GL_TEXTURE_2D); gl.glEnable(GL_BLEND); gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE); final int velLocation = gl.glGetAttribLocation(shaderProgramID, "inVelocity"); gl.glBindBuffer(GL_ARRAY_BUFFER, velocityVBO); gl.glEnableVertexAttribArray(velLocation); gl.glVertexAttribPointer(velLocation, 4, GL3.GL_FLOAT, false, 0, 0); final int inVertexLocation = gl.glGetAttribLocation(shaderProgramID, "inVertex"); gl.glBindBuffer(GL_ARRAY_BUFFER, positionVBO); gl.glEnableVertexAttribArray(inVertexLocation); gl.glVertexAttribPointer(inVertexLocation, 4, GL3.GL_FLOAT, false, 0, 0); gl.glDrawArrays(GL_POINTS, 0, simulation.getNumberOfBodies()); }