Java Code Examples for com.jogamp.opengl.GL2#glEnd()
The following examples show how to use
com.jogamp.opengl.GL2#glEnd() .
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: JRotation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer gl.glLoadIdentity(); // Reset The View //triangle rotation gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f); gl.glBegin(GL2.GL_TRIANGLES); //Green Color gl.glColor3f(0.0f, 1.0f, 0.0f); gl.glVertex2d(0, 0.5); gl.glVertex2d(-0.5, -0.5); gl.glVertex2d(0.5, -0.5); gl.glEnd(); gl.glFlush(); //Assign the angle rotation += 0.6f; }
Example 2
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
static public void drawStar(GL2 gl2,Vector3d p,double size) { // save the current color double [] params = new double[4]; gl2.glGetDoublev(GL2.GL_CURRENT_COLOR, params, 0); boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2); int depth = OpenGLHelper.drawAtopEverythingStart(gl2); size/=2.0f; gl2.glPushMatrix(); gl2.glTranslated(p.x, p.y, p.z); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1, 0, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(size, 0, 0); gl2.glColor3d(0, 1, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, size, 0); gl2.glColor3d(0, 0, 1); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 0, size); gl2.glEnd(); gl2.glPopMatrix(); OpenGLHelper.drawAtopEverythingEnd(gl2,depth); OpenGLHelper.disableLightingEnd(gl2,lightWasOn); // restore color gl2.glColor4dv(params,0); }
Example 3
Source File: Main.java From aparapi-examples with Apache License 2.0 | 6 votes |
/** * Render all particles to the OpenGL context * * @param gl */ protected void render(GL2 gl) { gl.glBegin(GL2.GL_QUADS); int sz = range.getGlobalSize(0); for (int i = 0; i < sz; i++) { Body currBody = bodies[i]; if(currBody.isHeavy()) gl.glColor3f(1f, 0f, 0f); else gl.glColor3f(0f, 0f, 1f); gl.glTexCoord2f(0, 1); gl.glVertex3f(currBody.getX(), currBody.getY() + 1, currBody.getZ()); gl.glTexCoord2f(0, 0); gl.glVertex3f(currBody.getX(), currBody.getY(), currBody.getZ()); gl.glTexCoord2f(1, 0); gl.glVertex3f(currBody.getX() + 1, currBody.getY(), currBody.getZ()); gl.glTexCoord2f(1, 1); gl.glVertex3f(currBody.getX() + 1, currBody.getY() + 1, currBody.getZ()); } gl.glEnd(); }
Example 4
Source File: JMColor.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glBegin(GL2.GL_TRIANGLES); //Yellow Color gl.glColor3f(1.0f, 1.0f, 0f); gl.glVertex2d(0, 0.5); //Red Color gl.glColor3f(1f, 0f, 0f); gl.glVertex2d(-0.5, -0.5); //Blue Color gl.glColor3f(0f, 0f, 1f); gl.glVertex2d(0.5, -0.5); gl.glEnd(); }
Example 5
Source File: Star.java From depan with Apache License 2.0 | 6 votes |
@Override public void fill(GL2 gl) { //gl.glPushMatrix(); //gl.glTranslatef(translateX, translateY, translateZ); //gl.glScalef(scaleX, scaleY, scaleZ); gl.glBegin(GL2.GL_TRIANGLE_FAN); GLScene.V(gl, translateX, translateY); // point 0:0 : center of this star //GLScene.V(gl, 0, 0); for (Point2D.Float p : controlPoints) { GLScene.V(gl, p.x * scaleX + translateX, p.y * scaleY + translateY); //GLScene.V(gl,p.x, p.y); } GLScene.V(gl, controlPoints[0].x * scaleX + translateX, controlPoints[0].y * scaleY + translateY); //GLScene.V(gl,controlPoints[0].x, controlPoints[0].y); gl.glEnd(); //gl.glPopMatrix(); }
Example 6
Source File: Star.java From depan with Apache License 2.0 | 6 votes |
@Override public void draw(GL2 gl) { //gl.glPushMatrix(); //gl.glTranslatef(translateX, translateY, translateZ); //gl.glScalef(scaleX, scaleY, scaleZ); gl.glBegin(GL2.GL_LINE_STRIP); for (Point2D.Float p : controlPoints) { GLScene.V(gl, p.x * scaleX + translateX, p.y * scaleY + translateY); //GLScene.V(gl,p.x, p.y); } GLScene.V(gl, controlPoints[0].x * scaleX + translateX, controlPoints[0].y * scaleY + translateY); //GLScene.V(gl,controlPoints[0].x, controlPoints[0].y); gl.glEnd(); //gl.glPopMatrix(); }
Example 7
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 8
Source File: PoseEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderLineage(GL2 gl2) { boolean isTex = gl2.glIsEnabled(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_TEXTURE_2D); // save the lighting mode boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_LIGHTING); IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); //boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST); //gl2.glDisable(GL2.GL_DEPTH_TEST); gl2.glColor4d(1,1,1,1); gl2.glBegin(GL2.GL_LINES); // connection to children for(Entity e : children ) { if(e instanceof PoseEntity) { Vector3d p = ((PoseEntity)e).getPosition(); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(p.x,p.y,p.z); } } gl2.glEnd(); //if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST); gl2.glDepthFunc(depthFunc.get()); // restore lighting if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING); if(isTex) gl2.glDisable(GL2.GL_TEXTURE_2D); }
Example 9
Source File: Triangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); //drawing the base gl.glBegin(GL2.GL_LINE_STRIP); gl.glVertex3f(-0.50f, -0.50f, 0); gl.glVertex3f(0.50f, -0.50f, 0); gl.glVertex3f(0f, 0.50f, 0); gl.glVertex3f(-0.50f, -0.50f, 0); gl.glEnd(); gl.glFlush(); }
Example 10
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
static public void drawCircleXZ(GL2 gl2,double radius,int steps) { double stepSize = Math.PI*2 / (double)(steps+1); gl2.glBegin(GL2.GL_LINE_LOOP); for(double n=0;n<Math.PI*2;n+=stepSize) { double c = Math.cos(n); double s = Math.sin(n); gl2.glVertex3d(c*radius,0, s*radius); } gl2.glEnd(); }
Example 11
Source File: Arrowheads.java From depan with Apache License 2.0 | 5 votes |
/** * Draws a triangular open arrow head on the given <code>GL</code> * instantiation. * * @param gl Graphics object that will draw this object. */ @Override public void draw(GL2 gl) { gl.glPushMatrix(); float[] translate = GLScene.P(translateX, translateY); gl.glTranslatef(translate[0], translate[1], translate[2]); gl.glScalef(scaleX, scaleY, scaleZ); gl.glRotated(rotation * 180 / Math.PI, 0, 0, 1); gl.glBegin(GL2.GL_LINE_STRIP); GLPanel.V(gl, controlPoints[1].x, controlPoints[1].y); GLPanel.V(gl, controlPoints[0].x, controlPoints[0].y); GLPanel.V(gl, controlPoints[2].x, controlPoints[2].y); gl.glEnd(); gl.glPopMatrix(); }
Example 12
Source File: OneTriangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
protected static void render( GL2 gl2, int width, int height ) { gl2.glClear( GL.GL_COLOR_BUFFER_BIT ); // draw a triangle filling the window gl2.glLoadIdentity(); gl2.glBegin( GL.GL_TRIANGLES ); gl2.glColor3f( 1, 0, 0 ); gl2.glVertex2f( 0, 0 ); gl2.glColor3f( 0, 1, 0 ); gl2.glVertex2f( width, 0 ); gl2.glColor3f( 0, 0, 1 ); gl2.glVertex2f( width / 2, height ); gl2.glEnd(); }
Example 13
Source File: CubeSample2.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); // 視点位置と視線方向 // glu.gluLookAt(3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); // 図形の回転 gl.glTranslatef(0.5f, 0.5f, 0.5f); gl.glRotatef(r, 0.0f, 1.0f, 0.0f); gl.glTranslatef(-0.5f, -0.5f, -0.5f); // 図形の描画 gl.glColor3f(0.0f, 0.0f, 0.0f); gl.glBegin(GL_LINES); for (int i = 0; i < 12; i++) { gl.glVertex3fv(vertex[edge[i][0]], 0); gl.glVertex3fv(vertex[edge[i][1]], 0); } gl.glEnd(); //一周回ったら回転角を 0 に戻す if (r++ >= 360.0f) r = 0; System.out.println("anim:" + animator.isAnimating() + ", r:" + r); if(willAnimatorPause) { animator.pause(); System.out.println("animoator paused:"); willAnimatorPause = false; } drawable.swapBuffers(); }
Example 14
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void showPickingTest(GL2 gl2) { renderChosenProjection(gl2); gl2.glPushMatrix(); Ray r = rayPick(); double cx=cursorX; double cy=cursorY; int w = canvasWidth; int h = canvasHeight; setCursor(0,0); Ray tl = rayPick(); setCursor(w,0); Ray tr = rayPick(); setCursor(0,h); Ray bl = rayPick(); setCursor(w,h); Ray br = rayPick(); cursorX=cx; cursorY=cy; double scale=20; tl.direction.scale(scale); tr.direction.scale(scale); bl.direction.scale(scale); br.direction.scale(scale); r.direction .scale(scale); Vector3d tl2 = new Vector3d(tl.direction); Vector3d tr2 = new Vector3d(tr.direction); Vector3d bl2 = new Vector3d(bl.direction); Vector3d br2 = new Vector3d(br.direction); Vector3d r2 = new Vector3d(r.direction ); tl2.add(tl.start); tr2.add(tr.start); bl2.add(bl.start); br2.add(br.start); r2.add(r.start); gl2.glDisable(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_LIGHTING); gl2.glColor3d(1, 0, 0); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(tl.start.x, tl.start.y, tl.start.z); gl2.glVertex3d(tl2.x, tl2.y, tl2.z); gl2.glVertex3d(tr.start.x, tr.start.y, tr.start.z); gl2.glVertex3d(tr2.x, tr2.y, tr2.z); gl2.glVertex3d(bl.start.x, bl.start.y, bl.start.z); gl2.glVertex3d(bl2.x, bl2.y, bl2.z); gl2.glVertex3d(br.start.x, br.start.y, br.start.z); gl2.glVertex3d(br2.x, br2.y, br2.z); gl2.glColor3d(1, 1, 1); gl2.glVertex3d(r.start.x, r.start.y, r.start.z); gl2.glVertex3d(r2.x,r2.y,r2.z); gl2.glEnd(); gl2.glColor3d(0, 1, 0); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(tl2.x, tl2.y, tl2.z); gl2.glVertex3d(tr2.x, tr2.y, tr2.z); gl2.glVertex3d(br2.x, br2.y, br2.z); gl2.glVertex3d(bl2.x, bl2.y, bl2.z); gl2.glEnd(); gl2.glColor3d(0, 0, 1); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(tl.start.x, tl.start.y, tl.start.z); gl2.glVertex3d(tr.start.x, tr.start.y, tr.start.z); gl2.glVertex3d(br.start.x, br.start.y, br.start.z); gl2.glVertex3d(bl.start.x, bl.start.y, bl.start.z); gl2.glEnd(); PrimitiveSolids.drawStar(gl2,r2,5); gl2.glPopMatrix(); }
Example 15
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 16
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
/** * draw box based on depth,width, and height with the origin in the bottom center. * @param gl2 * @param depth * @param width * @param height */ static public void drawBox(GL2 gl2,double depth,double width,double height) { width/=2; depth/=2; gl2.glPushMatrix(); gl2.glBegin(GL2.GL_QUADS); // bottom gl2.glNormal3f( 0, 0,-1); gl2.glVertex3d(-width, depth,0); gl2.glVertex3d( width, depth,0); gl2.glVertex3d( width,-depth,0); gl2.glVertex3d(-width,-depth,0); // top gl2.glNormal3f( 0, 0, 1); gl2.glVertex3d( width, depth,height); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d( width,-depth,height); // side gl2.glNormal3f( 0, 1, 0); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d( width, depth,height); gl2.glVertex3d( width, depth,0); gl2.glVertex3d(-width, depth,0); gl2.glNormal3f( 0,-1, 0); gl2.glVertex3d( width,-depth,height); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d(-width,-depth,0); gl2.glVertex3d( width,-depth,0); gl2.glNormal3f( 1, 0, 0); gl2.glVertex3d( width, depth,0); gl2.glVertex3d( width, depth,height); gl2.glVertex3d( width,-depth,height); gl2.glVertex3d( width,-depth,0); gl2.glNormal3f(-1, 0, 0); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d(-width, depth,0); gl2.glVertex3d(-width,-depth,0); gl2.glEnd(); gl2.glPopMatrix(); }
Example 17
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); }
Example 18
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 19
Source File: J3DCube.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -2.0f); gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f); gl.glBegin(GL2.GL_QUADS); gl.glColor3f(0f, 0f, 1f); //Blue color //Top Quadrilateral gl.glVertex3f(0.5f, 0.5f, -0.5f); //Upper Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, 0.5f, 0.5f); // Bottom Right //Below Quadrilateral gl.glColor3f(1f, 0f, 0f); //Red color gl.glVertex3f(0.5f, -0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right //Front Quadrilateral gl.glColor3f(0f, 1f, 0f); //Green color gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Right //Back Quadrilateral gl.glColor3f(1f, 1f, 0f); //Yellow gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Right gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Left //Left Quadrilateral gl.glColor3f(1f, 0f, 1f); //Purple gl.glVertex3f(-0.5f, 0.5f, 0.5f); // Upper Right gl.glVertex3f(-0.5f, 0.5f, -0.5f); // Upper Left gl.glVertex3f(-0.5f, -0.5f, -0.5f); // Bottom Left gl.glVertex3f(-0.5f, -0.5f, 0.5f); // Bottom Right //Right Quadrilateral gl.glColor3f(0f, 1f, 1f); //Cyan gl.glVertex3f(0.5f, 0.5f, -0.5f); // Upper Right gl.glVertex3f(0.5f, 0.5f, 0.5f); // Upper Left gl.glVertex3f(0.5f, -0.5f, 0.5f); // Bottom Left gl.glVertex3f(0.5f, -0.5f, -0.5f); // Bottom Right gl.glEnd(); gl.glFlush(); rotation += 0.6f; }
Example 20
Source File: JQuad.java From MeteoInfo with GNU Lesser General Public License v3.0 | 3 votes |
@Override public void display(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glBegin(GL2.GL_QUADS); gl.glVertex3f(0.0f, 0.5f, 0); gl.glVertex3f(-0.5f, 0f, 0); gl.glVertex3f(0f, -0.5f, 0); gl.glVertex3f(0.5f, 0f, 0); gl.glEnd(); }