Java Code Examples for com.jogamp.opengl.GL2GL3#glLineWidth()
The following examples show how to use
com.jogamp.opengl.GL2GL3#glLineWidth() .
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: Polygon.java From jaamsim with Apache License 2.0 | 6 votes |
private void renderOutline(GL2GL3 gl) { // The vertex list is just the closed loop of points if (lineWidth == 0) { return; } gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _vertBuffer); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, fb.limit() * 4, fb, GL2GL3.GL_STATIC_DRAW); gl.glVertexAttribPointer(_posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); if (!gl.isGLcore()) gl.glLineWidth((float)lineWidth); else gl.glLineWidth(1.0f); gl.glDrawArrays(GL2GL3.GL_LINE_LOOP, 0, _points.size()); gl.glLineWidth(1.0f); }
Example 2
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 4 votes |
private void renderStaticLines(int contextID, Renderer renderer, Mat4d modelViewMat, Camera cam) { if (_lineBatches.size() == 0) { return; } GL2GL3 gl = renderer.getGL(); GL4 gl4 = renderer.getGL4(); if (!_lineVAOs.containsKey(contextID)) { setupVAOForStaticLines(contextID, renderer); } int vao = _lineVAOs.get(contextID); gl.glBindVertexArray(vao); Shader s = renderer.getShader(ShaderHandle.DEBUG_BATCH); int progHandle = s.getProgramHandle(); gl.glUseProgram(progHandle); Mat4d projMat = cam.getProjMat4d(); int modelViewMatVar = gl.glGetUniformLocation(progHandle, "modelViewMat"); int projMatVar = gl.glGetUniformLocation(progHandle, "projMat"); int cVar = gl.glGetUniformLocation(progHandle, "C"); int fcVar = gl.glGetUniformLocation(progHandle, "FC"); gl.glUniformMatrix4fv(modelViewMatVar, 1, false, RenderUtils.MarshalMat4d(modelViewMat), 0); gl.glUniformMatrix4fv(projMatVar, 1, false, RenderUtils.MarshalMat4d(projMat), 0); gl.glUniform1f(cVar, Camera.C); gl.glUniform1f(fcVar, Camera.FC); gl.glLineWidth(1); // Actually draw it gl4.glBindBuffer(GL4.GL_DRAW_INDIRECT_BUFFER, lineIndirectBuffer); gl4.glMultiDrawArraysIndirect(GL2GL3.GL_LINES, 0, _lineBatches.size(), 0); //gl.glDrawArrays(GL2GL3.GL_LINES, 0, sub._numVerts); gl.glBindVertexArray(0); }
Example 3
Source File: DebugUtils.java From jaamsim with Apache License 2.0 | 4 votes |
public static void renderArmature(int contextID, Renderer renderer, Mat4d modelViewMat, Armature arm, ArrayList<Mat4d> pose, Color4d color, Camera cam) { GL2GL3 gl = renderer.getGL(); if (!_debugVAOMap.containsKey(contextID)) { setupDebugVAO(contextID, renderer); } int vao = _debugVAOMap.get(contextID); gl.glBindVertexArray(vao); gl.glUseProgram(_debugProgHandle); // Setup uniforms for this object Mat4d projMat = cam.getProjMat4d(); gl.glUniformMatrix4fv(_modelViewMatVar, 1, false, RenderUtils.MarshalMat4d(modelViewMat), 0); gl.glUniformMatrix4fv(_projMatVar, 1, false, RenderUtils.MarshalMat4d(projMat), 0); gl.glUniform4fv(_colorVar, 1, color.toFloats(), 0); gl.glUniform1f(_cVar, Camera.C); gl.glUniform1f(_fcVar, Camera.FC); ArrayList<Armature.Bone> bones = arm.getAllBones(); //Build up the list of bone vertices Vec4d[] vects = new Vec4d[bones.size() * 2]; for (int i = 0; i < bones.size(); ++i) { Armature.Bone b = bones.get(i); Vec4d boneStart = new Vec4d(0, 0, 0, 1); boneStart.mult4(b.getMatrix(), boneStart); Vec4d boneEnd = new Vec4d(0, b.getLength(), 0, 1); boneEnd.mult4(b.getMatrix(), boneEnd); if (pose != null) { // Adjust the bone by the current pose Mat4d poseMat = pose.get(i); boneStart.mult4(poseMat, boneStart); boneEnd.mult4(poseMat, boneEnd); } vects[2*i + 0] = boneStart; vects[2*i + 1] = boneEnd; } // Now push it to the card FloatBuffer fb = FloatBuffer.allocate(vects.length * 3); for (Vec4d v : vects) { RenderUtils.putPointXYZ(fb, v); } fb.flip(); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _lineVertBuffer); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, fb.limit() * 4, fb, GL2GL3.GL_STATIC_DRAW); gl.glVertexAttribPointer(_posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); gl.glDisable(GL2GL3.GL_DEPTH_TEST); gl.glDrawArrays(GL2GL3.GL_LINES, 0, fb.limit() / 3); gl.glEnable(GL2GL3.GL_DEPTH_TEST); gl.glLineWidth(1.0f); gl.glBindVertexArray(0); }
Example 4
Source File: MeshProto.java From jaamsim with Apache License 2.0 | 2 votes |
private void renderSubLine(SubLine sub, int contextID, Renderer renderer, Mat4d modelMat, Mat4d modelViewMat, Mat4d subInstTrans, Camera cam) { Mat4d subModelViewMat = new Mat4d(); Mat4d subModelMat = new Mat4d(); subModelMat.mult4(modelMat, subInstTrans); AABB instBounds = sub._hull.getAABB(subModelMat); if (!cam.collides(instBounds)) { return; } subModelViewMat.mult4(modelViewMat, subInstTrans); GL2GL3 gl = renderer.getGL(); if (!sub.vaoMap.containsKey(contextID)) { setupVAOForSubLine(contextID, sub, renderer); } int vao = sub.vaoMap.get(contextID); gl.glBindVertexArray(vao); int prog = sub._progHandle; gl.glUseProgram(prog); Mat4d projMat = cam.getProjMat4d(); gl.glUniformMatrix4fv(sub._modelViewMatVar, 1, false, RenderUtils.MarshalMat4d(subModelViewMat), 0); gl.glUniformMatrix4fv(sub._projMatVar, 1, false, RenderUtils.MarshalMat4d(projMat), 0); gl.glUniform4fv(sub._colorVar, 1, sub._diffuseColor.toFloats(), 0); gl.glUniform1f(sub._cVar, Camera.C); gl.glUniform1f(sub._fcVar, Camera.FC); gl.glLineWidth(1); // Actually draw it gl.glDrawArrays(GL2GL3.GL_LINES, 0, sub._numVerts); gl.glBindVertexArray(0); }
Example 5
Source File: OverlayLine.java From jaamsim with Apache License 2.0 | 2 votes |
@Override public void render(int contextID, Renderer renderer, double windowWidth, double windowHeight, Camera cam, Ray pickRay) { if (!staticInit) { initStaticData(renderer); } GL2GL3 gl = renderer.getGL(); if (!VAOMap.containsKey(contextID)) { setupVAO(contextID, renderer); } int vao = VAOMap.get(contextID); gl.glBindVertexArray(vao); gl.glUseProgram(progHandle); gl.glUniform4fv(colorVar, 1, color.toFloats(), 0); gl.glUniform1i(hasTexVar, 0); // Set the size and offset in normalized (-1, 1) coordinates double scaleX = 2.0 / windowWidth; double scaleY = 2.0 / windowHeight; double pixelWidth = 2.0/windowWidth; double pixelHeight = 2.0/windowHeight; double xOffset = -1.0 + 0.5*pixelWidth; double yOffset = -1.0 + 0.5*pixelHeight; if (originTop) { scaleY *= -1.0; yOffset = 1.0 - 0.5*pixelHeight; } if (originRight) { scaleX *= -1.0; xOffset = 1.0 - 0.5*pixelWidth; } gl.glUniform2f(offsetVar, (float)xOffset, (float)yOffset); gl.glUniform2f(sizeVar, (float)scaleX, (float)scaleY); gl.glEnableVertexAttribArray(posVar); gl.glDisable(GL2GL3.GL_CULL_FACE); if (!gl.isGLcore()) gl.glLineWidth((float)lineWidth); else gl.glLineWidth(1.0f); // Build up a float buffer to pass to GL gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, lineGLBuff); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, lineBuffer.limit() * 4, lineBuffer, GL2GL3.GL_STATIC_DRAW); gl.glVertexAttribPointer(posVar, 2, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); gl.glDrawArrays(GL2GL3.GL_LINES, 0, lineBuffer.limit() / 2); gl.glLineWidth(1.0f); gl.glEnable(GL2GL3.GL_CULL_FACE); gl.glBindVertexArray(0); }
Example 6
Source File: DebugUtils.java From jaamsim with Apache License 2.0 | 2 votes |
/** * Render a number of lines segments from the points provided * @param vaoMap * @param renderer * @param lineSegments - pairs of discontinuous line start and end points * @param color * @param cam */ public static void renderLine(int contextID, Renderer renderer, FloatBuffer lineSegments, float[] color, double lineWidth, Camera cam) { GL2GL3 gl = renderer.getGL(); if (!_debugVAOMap.containsKey(contextID)) { setupDebugVAO(contextID, renderer); } int vao = _debugVAOMap.get(contextID); gl.glBindVertexArray(vao); gl.glUseProgram(_debugProgHandle); // Setup uniforms for this object Mat4d projMat = cam.getProjMat4d(); Mat4d modelViewMat = new Mat4d(); cam.getViewMat4d(modelViewMat); gl.glUniformMatrix4fv(_modelViewMatVar, 1, false, RenderUtils.MarshalMat4d(modelViewMat), 0); gl.glUniformMatrix4fv(_projMatVar, 1, false, RenderUtils.MarshalMat4d(projMat), 0); gl.glUniform4fv(_colorVar, 1, color, 0); gl.glUniform1f(_cVar, Camera.C); gl.glUniform1f(_fcVar, Camera.FC); if (!gl.isGLcore()) gl.glLineWidth((float)lineWidth); else gl.glLineWidth(1.0f); // Build up a float buffer to pass to GL gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, _lineVertBuffer); gl.glBufferData(GL2GL3.GL_ARRAY_BUFFER, lineSegments.limit() * 4, lineSegments, GL2GL3.GL_STATIC_DRAW); gl.glVertexAttribPointer(_posVar, 3, GL2GL3.GL_FLOAT, false, 0, 0); gl.glBindBuffer(GL2GL3.GL_ARRAY_BUFFER, 0); gl.glDrawArrays(GL2GL3.GL_LINES, 0, lineSegments.limit() / 3); gl.glLineWidth(1.0f); gl.glBindVertexArray(0); }