Java Code Examples for com.jogamp.opengl.GL3#glDepthMask()
The following examples show how to use
com.jogamp.opengl.GL3#glDepthMask() .
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: AxesRenderable.java From constellation with Apache License 2.0 | 5 votes |
@Override public void display(final GLAutoDrawable drawable, final Matrix44f projectionMatrix) { final GL3 gl = drawable.getGL().getGL3(); // Extract the rotation matrix from the mvp matrix. final Matrix44f rotationMatrix = new Matrix44f(); parent.getDisplayModelViewProjectionMatrix().getRotationMatrix(rotationMatrix); // Scale down to size. final Matrix44f scalingMatrix = new Matrix44f(); scalingMatrix.makeScalingMatrix(pScale, pScale, 0); final Matrix44f srMatrix = new Matrix44f(); srMatrix.multiply(scalingMatrix, rotationMatrix); // Translate to the top right corner. final Matrix44f translationMatrix = new Matrix44f(); translationMatrix.makeTranslationMatrix(topRightCorner.getX(), topRightCorner.getY(), topRightCorner.getZ()); final Matrix44f axesMatrix = new Matrix44f(); axesMatrix.multiply(translationMatrix, srMatrix); // Disable depth so the axes are drawn over everything else. gl.glDisable(GL3.GL_DEPTH_TEST); gl.glDepthMask(false); // Draw. gl.glLineWidth(1); gl.glUseProgram(axesShader); gl.glUniformMatrix4fv(axesShaderLocMVP, 1, false, axesMatrix.a, 0); axesBatch.draw(gl); // Reenable depth. gl.glEnable(GL3.GL_DEPTH_TEST); gl.glDepthMask(true); }
Example 2
Source File: FPSRenderable.java From constellation with Apache License 2.0 | 4 votes |
@Override public void display(final GLAutoDrawable drawable, final Matrix44f pMatrix) { if (start == 0) { start = System.currentTimeMillis(); } if ((System.currentTimeMillis() - start) >= 500) { fps = count_fps << 1; start = 0; count_fps = 0; } count_fps++; if (enabled) { final GL3 gl = drawable.getGL().getGL3(); // extract and scale the rotation matrix from the mvp matrix // final Matrix44f rotationMatrix = new Matrix44f(); // parent.getDisplayModelViewProjectionMatrix().getRotationMatrix(rotationMatrix); final Matrix44f scalingMatrix = new Matrix44f(); scalingMatrix.makeScalingMatrix(pxScale, pyScale, 0); final Matrix44f srMatrix = new Matrix44f(); srMatrix.multiply(scalingMatrix, IDENTITY_44F); // srMatrix.multiply(scalingMatrix, rotationMatrix); // build the fps matrix by translating the sr matrix final Matrix44f translationMatrix = new Matrix44f(); translationMatrix.makeTranslationMatrix(bottomRightCorner.getX(), bottomRightCorner.getY(), bottomRightCorner.getZ()); final Matrix44f fpsMatrix = new Matrix44f(); fpsMatrix.multiply(translationMatrix, srMatrix); // disable depth so the fps counter is drawn on top gl.glDisable(GL3.GL_DEPTH_TEST); gl.glDepthMask(false); // draw the fps counter int[] fpsDigits = Long.toString(fps).chars().map(c -> c -= '0').toArray(); if (fpsDigits.length < 2) { fpsDigits = new int[]{0, fpsDigits[0]}; } fpsBatcher.setPixelDensity(pixelDensity); fpsBatcher.setProjectionScale(pyScale); fpsBatcher.updateColors(ConstellationColor.YELLOW).run(gl); fpsBatcher.updateIcons(fpsDigits).run(gl); fpsBatcher.drawBatch(gl, CAMERA, fpsMatrix, pMatrix); // re-enable depth gl.glEnable(GL3.GL_DEPTH_TEST); gl.glDepthMask(true); } }
Example 3
Source File: NewLineRenderable.java From constellation with Apache License 2.0 | 4 votes |
/** * Draws the new line on the display. * <p> * @param drawable The OpenGL rendering target. * @param pMatrix The model view projection matrix. */ @Override public void display(final GLAutoDrawable drawable, final Matrix44f pMatrix) { final Matrix44f mvpMatrix = parent.getDisplayModelViewProjectionMatrix(); // If no endpoints are set, don't draw anything if (model != null && !model.isClear()) { final Vector3f startPosition = model.getStartLocation(); final Vector3f endPosition = model.getEndLocation(); final GL3 gl = drawable.getGL().getGL3(); gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, batch.getBufferName(vertexTarget)); ByteBuffer bbuf = gl.glMapBuffer(GL3.GL_ARRAY_BUFFER, GL3.GL_WRITE_ONLY); FloatBuffer fbuf = bbuf.asFloatBuffer(); // Update the line endpoints in the vertex buffer. float[] vertices = new float[]{ startPosition.getX(), startPosition.getY(), startPosition.getZ(), endPosition.getX(), endPosition.getY(), endPosition.getZ()}; fbuf.put(vertices); gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER); // Disable depth so the line is drawn over everything else. gl.glDisable(GL3.GL_DEPTH_TEST); gl.glDepthMask(false); // Draw the line. gl.glLineWidth(NEW_LINE_WIDTH); gl.glUseProgram(shader); gl.glUniformMatrix4fv(shaderMVP, 1, false, mvpMatrix.a, 0); batch.draw(gl); gl.glLineWidth(1); // Reenable depth. gl.glEnable(GL3.GL_DEPTH_TEST); gl.glDepthMask(true); // Rebind default array buffer gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); } }