Java Code Examples for com.jogamp.opengl.GL2#glVertex2d()

The following examples show how to use com.jogamp.opengl.GL2#glVertex2d() . 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 vote down vote up
@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: JMColor.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 3
Source File: BasicLine.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
    public void display(GLAutoDrawable drawable) {
        final GL2 gl = drawable.getGL().getGL2();

        //Draw H  
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex2d(-0.8, 0.6);
        gl.glVertex2d(-0.8, -0.6);
        gl.glVertex2d(-0.8, 0.0);
        gl.glVertex2d(-0.4, 0.0);
        gl.glVertex2d(-0.4, 0.6);
        gl.glVertex2d(-0.4, -0.6);
        gl.glEnd();
//Draw W  
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex2d(0.4, 0.6);
        gl.glVertex2d(0.4, -0.6);
        gl.glVertex2d(0.4, -0.6);
        gl.glVertex2d(0.6, 0);
        gl.glVertex2d(0.6, 0);
        gl.glVertex2d(0.8, -0.6);
        gl.glVertex2d(0.8, -0.6);
        gl.glVertex2d(0.8, 0.6);
        gl.glEnd();

    }
 
Example 4
Source File: JColor.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();

    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();
}
 
Example 5
Source File: JLight.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glColor3f(1f, 0f, 0f);
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glRotatef(rotation, 1.0f, 1.0f, 0.0f);

    gl.glBegin(GL2.GL_TRIANGLES);

    gl.glVertex2d(0, 0.5);

    gl.glVertex2d(-0.5, -0.5);

    gl.glVertex2d(0.5, -0.5);

    gl.glEnd();

    gl.glFlush();
    //Angle  
    rotation += 0.6f;

    gl.glEnable(GL2.GL_LIGHTING);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glEnable(GL2.GL_DEPTH_TEST);

    float[] ambientLight = {0f, 0f, 1f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight, 0);

    float[] specularLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specularLight, 0);

    float[] diffuseLight = {1f, 0f, 0f, 0f};
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuseLight, 0);
}
 
Example 6
Source File: Arrow.java    From depan with Apache License 2.0 5 votes vote down vote up
private void drawCurve(GL2 gl, ArcInfo arcInfo) {

    gl.glBegin(GL2.GL_LINE_STRIP);
    for (int segIndex = arcInfo.headSeg; segIndex <= arcInfo.tailSeg; segIndex++) {
      Point2D point = arcInfo.getPoint(segIndex);
      gl.glVertex2d(point.getX(), point.getY());
    }
    gl.glEnd();
  }
 
Example 7
Source File: DrawingPlugin.java    From depan with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}