Java Code Examples for com.jogamp.opengl.GL2#glLineWidth()
The following examples show how to use
com.jogamp.opengl.GL2#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: OpenGLGFXCMD.java From sagetv with Apache License 2.0 | 5 votes |
private void drawGLCurve(GL2 gl, float x, float y, float width, float height, float angs, float ange, int subdiv, int tlc, int trc, int brc, int blc, int xc, int yc, int widthc, int heightc, boolean full, int thickness) { if(full) { gl.glBegin(gl.GL_TRIANGLE_FAN); setInterpolatedGLColor(gl, tlc, trc, brc, blc, x-xc, y-yc, widthc, heightc); gl.glVertex2f(x, y); } else { gl.glLineWidth(thickness); gl.glBegin(gl.GL_LINE_STRIP); } for(int i=0; i<=subdiv; i++) { float posx, posy; float ang=angs+(ange-angs)*i/subdiv; posx=width * (float)java.lang.Math.cos(ang); posy=height * (float)java.lang.Math.sin(ang); setInterpolatedGLColor(gl, tlc, trc, brc, blc, posx+x-xc, posy+y-yc, widthc, heightc); gl.glVertex2f(x + posx, y + posy); //System.out.println("x: "+(x+posx)+" y: "+(y+posy)); } gl.glEnd(); }
Example 2
Source File: Sixi2Live.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderCartesianForce(GL2 gl2) { double len = Math.sqrt( cartesianForceDetected[0]*cartesianForceDetected[0]+ cartesianForceDetected[1]*cartesianForceDetected[1]+ cartesianForceDetected[2]*cartesianForceDetected[2]); if(len<1) return; //System.out.println(len); int previousState = OpenGLHelper.drawAtopEverythingStart(gl2); boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2); gl2.glLineWidth(4); double scale=1; gl2.glPushMatrix(); Matrix4d m4 = endEffector.getPoseWorld(); gl2.glTranslated(m4.m03, m4.m13, m4.m23); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(0, 0.6, 1); gl2.glVertex3d(0,0,0); gl2.glVertex3d( cartesianForceDetected[0]*scale, cartesianForceDetected[1]*scale, cartesianForceDetected[2]*scale); gl2.glColor3d(1.0, 0.5, 0.5); PrimitiveSolids.drawCircleYZ(gl2, cartesianForceDetected[3]*scale, 20); gl2.glColor3d(0.5, 1.0, 0.5); PrimitiveSolids.drawCircleXZ(gl2, cartesianForceDetected[4]*scale, 20); gl2.glColor3d(0.5, 0.5, 1.0); PrimitiveSolids.drawCircleXY(gl2, cartesianForceDetected[5]*scale, 20); gl2.glPopMatrix(); gl2.glLineWidth(1); OpenGLHelper.disableLightingEnd(gl2, lightWasOn); OpenGLHelper.drawAtopEverythingEnd(gl2, previousState); }
Example 3
Source File: CubeTexture.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
private void drawBoxGridsTicksLabels(GL2 gl) { gl.glColor3f(0.0f, 0.0f, 0.0f); gl.glLineWidth(1.0f); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(1f, 1f, -1f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1.0f, 1.0f, -1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1.0f, 1.0f, 1.0f); gl.glVertex3f(1.0f, 1.0f, 1.0f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(1.0f, 1.0f, 1.0f); gl.glVertex3f(1f, 1f, -1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(1f, 1f, -1f); gl.glVertex3f(1f, -1f, -1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(1f, -1f, -1f); gl.glVertex3f(1f, -1f, 1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(1f, -1f, 1f); gl.glVertex3f(1f, 1f, 1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1f, 1f, -1f); gl.glVertex3f(-1f, -1f, -1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1f, -1f, -1f); gl.glVertex3f(1f, -1f, -1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1f, 1f, 1f); gl.glVertex3f(-1f, -1f, 1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1f, -1f, 1f); gl.glVertex3f(-1f, -1f, -1f); gl.glEnd(); gl.glBegin(GL2.GL_LINES); gl.glVertex3f(-1f, -1f, 1f); gl.glVertex3f(1f, -1f, 1f); gl.glEnd(); // gl.glColor3f(1.0f, 0.0f, 0.0f); // gl.glBegin(GL2.GL_LINES); // gl.glVertex3f(0f, 0f, -1f); // gl.glVertex3f(0f, 0f, 0f); // gl.glEnd(); }
Example 4
Source File: DrawingPlugin.java From depan with Apache License 2.0 | 4 votes |
/** * Draw a node. */ @Override public boolean apply(NodeRenderingProperty property) { if (!property.isVisible) { return false; } GL2 gl = scene.gl; gl.glPushMatrix(); gl.glPushName(property.shapeId); // move property.shape.setTranslation(property.positionX * GLConstants.FACTOR, property.positionY * GLConstants.FACTOR, 0f); // scale property.shape.setScale(property.size, property.size * property.ratio, property.size); // fill the shape if (property.isFilled) { gl.glColor4f(property.fillColor.getRed() / 255f, property.fillColor.getGreen() / 255f, property.fillColor.getBlue() / 255f, property.fillColor.getAlpha() / 255f); property.shape.fill(gl); } // draw the border if (property.strokeWidth > 0.0f) { gl.glLineWidth(property.strokeWidth); gl.glColor4f(property.strokeColor.getRed() / 255f, property.strokeColor.getGreen() / 255f, property.strokeColor.getBlue() / 255f, property.strokeColor.getAlpha() / 255f); property.shape.draw(gl); } Rectangle2D bounds = property.shape.getDrawingBounds(); updateDrawingBounds(bounds); // we don't want the label to be clickable, // so we just pop the name before drawing it. gl.glPopName(); // draw the label if (property.isTextVisible) { paintLabel(property); } // draw a little "+" on the top right corner of the node if it has // nodes collapsed under. if (property.hasCollapsedNodeUnder) { double centerX = property.positionX+property.size/2; double centerY = property.positionY+property.size/2; double halfWidth = 0.7; double halfHeight = 4; gl.glBegin(GL2.GL_QUADS); gl.glColor4f(1f, 1f, 1f, 0.5f); // vertical line gl.glVertex2d(centerX - halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY - halfHeight); gl.glVertex2d(centerX - halfWidth, centerY - halfHeight); // left part of horizontal line gl.glVertex2d(centerX - halfHeight, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY - halfWidth); gl.glVertex2d(centerX - halfHeight, centerY - halfWidth); // right part. gl.glVertex2d(centerX + halfWidth, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY - halfWidth); gl.glVertex2d(centerX + halfWidth, centerY - halfWidth); gl.glVertex3d(0, 0, 0); gl.glEnd(); } gl.glPopMatrix(); return true; }
Example 5
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
@Override public void render(GL2 gl2) { if(subject==null) return; gl2.glDisable(GL2.GL_TEXTURE_2D); RobotOverlord ro = (RobotOverlord)getRoot(); ro.viewport.renderChosenProjection(gl2); gl2.glPushMatrix(); /*if(isBallHit) { Vector3d dp = this.getPosition(); ViewportEntity cameraView = ro.viewport; Ray ray = cameraView.rayPick(); Vector3d dr = ray.getPoint(100); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1, 1, 1); gl2.glVertex3d(ray.start.x, ray.start.y, ray.start.z); gl2.glVertex3d(dr.x, dr.y, dr.z); gl2.glVertex3d(dp.x,dp.y,dp.z); gl2.glVertex3d(pickPointOnBall.x, pickPointOnBall.y, pickPointOnBall.z); gl2.glEnd(); PrimitiveSolids.drawStar(gl2, dp,10); PrimitiveSolids.drawStar(gl2, pickPointOnBall,10); }//*/ IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); //boolean isDepth=gl2.glIsEnabled(GL2.GL_DEPTH_TEST); //gl2.glDisable(GL2.GL_DEPTH_TEST); boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_LIGHTING); IntBuffer lineWidth = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_LINE_WIDTH, lineWidth); gl2.glLineWidth(2); gl2.glPushMatrix(); renderOutsideCircle(gl2); MatrixHelper.applyMatrix(gl2, FOR); gl2.glScaled(ballSize.get(),ballSize.get(),ballSize.get()); if(isRotateMode()) { renderRotation(gl2); } else { renderTranslation(gl2); } gl2.glPopMatrix(); // set previous line width gl2.glLineWidth(lineWidth.get()); if (isLit) gl2.glEnable(GL2.GL_LIGHTING); //if(isDepth) gl2.glEnable(GL2.GL_DEPTH_TEST); gl2.glDepthFunc(depthFunc.get()); gl2.glPopMatrix(); }
Example 6
Source File: ViewCubeEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void render(GL2 gl2) { RobotOverlord ro = (RobotOverlord)getRoot(); ViewportEntity cameraView = ro.viewport; gl2.glClear(GL2.GL_DEPTH_BUFFER_BIT); gl2.glEnable(GL2.GL_DEPTH_TEST); gl2.glEnable(GL2.GL_CULL_FACE); gl2.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glPushMatrix(); cameraView.renderOrtho(gl2,1); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glPushMatrix(); double c = cubeSize.get(); PoseEntity camera = cameraView.getAttachedTo(); Matrix4d m = camera.getPoseWorld(); Vector3d p = camera.getPosition(); Vector3d vx = MatrixHelper.getXAxis(m); Vector3d vy = MatrixHelper.getYAxis(m); Vector3d vz = MatrixHelper.getZAxis(m); vz.scale(-100); vx.scale(cameraView.getCanvasWidth() /10 -c*2); vy.scale(cameraView.getCanvasHeight()/10 -c*2); p.add(vx); p.add(vy); p.add(vz); gl2.glTranslated(p.x, p.y, p.z); gl2.glScaled(c,c,c); model.render(gl2); gl2.glDisable(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_COLOR_MATERIAL); gl2.glDisable(GL2.GL_TEXTURE_2D); // the big lines gl2.glLineWidth(4); gl2.glPushMatrix(); gl2.glTranslated(-1.05,-1.05,-0.95); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1, 0, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(2.5, 0, 0); gl2.glColor3d(0, 1, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 2.5, 0); gl2.glColor3d(0, 0, 1); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 0, 2.5); gl2.glEnd(); gl2.glPopMatrix(); gl2.glLineWidth(1); gl2.glPopMatrix(); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glPopMatrix(); gl2.glMatrixMode(GL2.GL_MODELVIEW); }