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

The following examples show how to use com.jogamp.opengl.GL2#glVertex3f() . 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: BasicLine1.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.glTranslatef(0f, 0f, 2.0f);

    //Draw H  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3d(-0.9, -0.9, -1);
    gl.glVertex3d(0.9, 0.9, -1);
    gl.glEnd();

    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(1f, 1f, -1f);
    gl.glVertex3f(-1.0f, 1.0f, -1.0f);
    gl.glEnd();

}
 
Example 2
Source File: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix2(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,1,0 = yellow
		gl2.glColor3f(0,1,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,1 = teal 
		gl2.glColor3f(1,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 1,0,1 = magenta
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 3
Source File: MatrixHelper.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * See drawMatrix(gl2,p,u,v,w,1)
 * @param gl2
 * @param m
 * @param scale
 */
public static void drawMatrix(GL2 gl2,Matrix4d m,double scale) {
	boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_DEPTH_TEST);
	boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_LIGHTING);
	
	gl2.glPushMatrix();
		gl2.glTranslated(m.m03,m.m13,m.m23);
		gl2.glScaled(scale, scale, scale);
		
		gl2.glBegin(GL2.GL_LINES);
		gl2.glColor3f(1,0,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m00,m.m10,m.m20);  // 1,0,0 = red
		gl2.glColor3f(0,1,0);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m01,m.m11,m.m21);  // 0,1,0 = green 
		gl2.glColor3f(0,0,1);		gl2.glVertex3f(0,0,0);		gl2.glVertex3d(m.m02,m.m12,m.m22);  // 0,0,1 = blue
		gl2.glEnd();

	gl2.glPopMatrix();
	if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING);
	if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST);
}
 
Example 4
Source File: Main.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * 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 5
Source File: Local.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * @param gl
 */

protected void render(GL2 gl) {
   gl.glBegin(GL2.GL_QUADS);

   for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) {
      gl.glTexCoord2f(0, 1);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]);
      gl.glTexCoord2f(0, 0);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 0);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 1);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]);
   }
   gl.glEnd();
}
 
Example 6
Source File: Seq.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * 
 * @param gl The OpenGL context to render to.
 */

protected void render(GL2 gl) {
   gl.glBegin(GL2.GL_QUADS);

   for (int i = 0; i < (bodies * 3); i += 3) {
      gl.glTexCoord2f(0, 1);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]);
      gl.glTexCoord2f(0, 0);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 0);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 1);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]);
   }
   gl.glEnd();
}
 
Example 7
Source File: Main.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * 
 * @param gl The OpenGL context to render to.
 */

protected void render(GL2 gl) {
   gl.glBegin(GL2.GL_QUADS);

   for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) {
      gl.glTexCoord2f(0, 1);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]);
      gl.glTexCoord2f(0, 0);
      gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 0);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]);
      gl.glTexCoord2f(1, 1);
      gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]);
   }
   gl.glEnd();
}
 
Example 8
Source File: NBody.java    From aparapi-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Render all particles to the OpenGL context
 * @param gl
 */

protected void render(GL2 gl) {
    gl.glBegin(GL2.GL_QUADS);

    for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) {
        gl.glTexCoord2f(0, 1);
        gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]);
        gl.glTexCoord2f(0, 0);
        gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]);
        gl.glTexCoord2f(1, 0);
        gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]);
        gl.glTexCoord2f(1, 1);
        gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]);
    }
    gl.glEnd();
}
 
Example 9
Source File: J3DBasic.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.glTranslatef(0f, 0f, -3f);
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, 0);
    gl.glVertex3f(0f, 1f, 0);
    gl.glEnd();

    //3D  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, -2f);
    gl.glVertex3f(0f, 1f, -2f);
    gl.glEnd();

    //top  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, 0);
    gl.glVertex3f(-1f, 0f, -2f);
    gl.glEnd();

    //bottom  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(0f, 1f, 0);
    gl.glVertex3f(0f, 1f, -2f);
    gl.glEnd();
}
 
Example 10
Source File: Triangle.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();

    //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 11
Source File: GLScene.java    From depan with Apache License 2.0 5 votes vote down vote up
public static void convertGLVertex(GL2 gl,
    float x, float y, float z,
    float a, float b, float c,
    float k, float h, float p) {

  float[] result = convertVertex(x, y, z, a, b, c, k, h, p);
  //System.out.println(""+x+":"+y+":"+z);
  gl.glVertex3f(result[0], result[1], result[3]);
}
 
Example 12
Source File: Bezier3ControlPoint.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
/**
 * visualize the line in opengl
 * @param gl2
 */
public void render(GL2 gl2) {
	//Vector3f u,v,w;
	
	//MatrixHelper.drawMatrix(gl2, position.interpolate(0), u, v, w);
	//MatrixHelper.drawMatrix(gl2, position.interpolate(1), u, v, w);
	boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING);
	boolean isCM =  gl2.glIsEnabled(GL2.GL_COLOR_MATERIAL);
	boolean isDepth =  gl2.glIsEnabled(GL2.GL_DEPTH_TEST);

	gl2.glEnable(GL2.GL_DEPTH_TEST);
	gl2.glDisable(GL2.GL_LIGHTING);
	gl2.glDisable(GL2.GL_COLOR_MATERIAL);
	
	//*
	gl2.glColor4f(0, 0, 1, 1);
	gl2.glBegin(GL2.GL_LINES);
	gl2.glVertex3f(position.p0.x,position.p0.y,position.p0.z);
	gl2.glVertex3f(position.p1.x,position.p1.y,position.p1.z);
	
	gl2.glVertex3f(position.p2.x,position.p2.y,position.p2.z);
	gl2.glVertex3f(position.p3.x,position.p3.y,position.p3.z);
	gl2.glEnd();
	//*/
	
	gl2.glColor4f(0, 1, 0, 1);
	gl2.glBegin(GL2.GL_LINE_STRIP);
	final float NUM_STEPS=20;
	for(float i=0;i<=NUM_STEPS;++i) {
		Vector3f ipos = position.interpolate(i/NUM_STEPS);
		gl2.glVertex3f(ipos.x,ipos.y,ipos.z);
	}
	gl2.glEnd();
	
	if(isLit) gl2.glEnable(GL2.GL_LIGHTING);
	if(isCM) gl2.glEnable(GL2.GL_COLOR_MATERIAL);
	if(!isDepth) gl2.glDisable(GL2.GL_DEPTH_TEST);
}
 
Example 13
Source File: J3DTriangle.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 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);
    gl.glLoadIdentity();
    // Move triangle  
    gl.glTranslatef(-0.5f, 0.0f, -6.0f);
    gl.glRotatef(rotation, 0.0f, 1.0f, 0.0f);
    gl.glBegin(GL2.GL_TRIANGLES);

    // Front  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2f, 0.0f); // Top Of Triangle   

    gl.glColor3f(0.0f, 1.5f, 0.0f); // Green  
    gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Left Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(1.5f, -1.5f, 1.5f); // Right Of Triangle   

    // Right  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(1.5f, -1.5f, 1.5f); // Left Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(1.5f, -1.5f, -1.5f); // Right Of Triangle   

    // Back  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(1.5f, -1.5f, -1.5f); // Left Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Right Of Triangle   

    //left  
    gl.glColor3f(1.0f, 1.0f, 0.0f); // Yellow  
    gl.glVertex3f(1.5f, 2.0f, 0.0f); // Top Of Triangle   

    gl.glColor3f(1.0f, 0.0f, 1.0f); // Purple  
    gl.glVertex3f(-1.5f, -1.5f, -1.5f); // Left Of Triangle   

    gl.glColor3f(0.0f, 1.0f, 0.0f); // Green  
    gl.glVertex3f(-1.5f, -1.5f, 1.5f); // Right Of Triangle   

    gl.glEnd();
    gl.glFlush();
    rotation += 0.6f;
}
 
Example 14
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void drawImage(GL2 gl) {        
    
    gl.glColor3f(1f, 1f, 1f);
    gl.glBindTexture(GL2.GL_TEXTURE_2D, texture);
    gl.glBegin(GL2.GL_QUADS);
    // Front Face
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, 1.0f);
    // Back Face
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, -1.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, -1.0f);
    // Top Face
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(-1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, -1.0f);
    // Bottom Face
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(-1.0f, -1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(1.0f, -1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    // Right face
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, -1.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, -1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);
    // Left Face
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, -1.0f);
    gl.glTexCoord2f(1.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(1.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, -1.0f);
    gl.glEnd();
}
 
Example 15
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
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 16
Source File: J3DCube.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 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);
    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 17
Source File: JScaling.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override

    public void display(GLAutoDrawable drawable) {

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

        gl.glScalef(0.40f, 0.30f, 0.40f);

        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();

    }
 
Example 18
Source File: OpenGLVideoRenderer.java    From sagetv with Apache License 2.0 4 votes vote down vote up
public void renderFragmentProgram(GL2 gl, java.awt.Rectangle srcVideoRect, java.awt.Rectangle currVideoBounds)
{
  gl.glEnable(gl.GL_FRAGMENT_PROGRAM_ARB);
  gl.glBindProgramARB(gl.GL_FRAGMENT_PROGRAM_ARB, fragProg);
  gl.glActiveTexture(gl.GL_TEXTURE0);
  gl.glEnable(gl.GL_TEXTURE_RECTANGLE);
  gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,videot[0]);
  gl.glActiveTexture(gl.GL_TEXTURE1);
  gl.glEnable(gl.GL_TEXTURE_RECTANGLE);
  gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,videot[1]);
  gl.glActiveTexture(gl.GL_TEXTURE2);
  gl.glEnable(gl.GL_TEXTURE_RECTANGLE);
  gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,videot[2]);
  gl.glDisable(gl.GL_BLEND);
  gl.glColor4f(1,1,1,1);
  gl.glBegin(gl.GL_QUADS);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE0, srcVideoRect.x, srcVideoRect.y);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE1, srcVideoRect.x/2, srcVideoRect.y/2);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE2, srcVideoRect.x/2, srcVideoRect.y/2);
  gl.glVertex3f(currVideoBounds.x, currVideoBounds.y, 1.0f);

  gl.glMultiTexCoord2f(gl.GL_TEXTURE0, srcVideoRect.x+srcVideoRect.width, srcVideoRect.y);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE1, (srcVideoRect.x+srcVideoRect.width)/2, srcVideoRect.y/2);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE2, (srcVideoRect.x+srcVideoRect.width)/2, srcVideoRect.y/2);
  gl.glVertex3f(currVideoBounds.x+currVideoBounds.width, currVideoBounds.y, 1.0f);

  gl.glMultiTexCoord2f(gl.GL_TEXTURE0, srcVideoRect.x+srcVideoRect.width, srcVideoRect.y + srcVideoRect.height);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE1, (srcVideoRect.x+srcVideoRect.width)/2, (srcVideoRect.y + srcVideoRect.height)/2);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE2, (srcVideoRect.x+srcVideoRect.width)/2, (srcVideoRect.y + srcVideoRect.height)/2);
  gl.glVertex3f(currVideoBounds.x+currVideoBounds.width,
      currVideoBounds.y+currVideoBounds.height, 1.0f);

  gl.glMultiTexCoord2f(gl.GL_TEXTURE0, srcVideoRect.x, srcVideoRect.y + srcVideoRect.height);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE1, srcVideoRect.x/2, (srcVideoRect.y + srcVideoRect.height)/2);
  gl.glMultiTexCoord2f(gl.GL_TEXTURE2, srcVideoRect.x/2, (srcVideoRect.y + srcVideoRect.height)/2);
  gl.glVertex3f(currVideoBounds.x, currVideoBounds.y+currVideoBounds.height, 1.0f);
  gl.glEnd();
  gl.glActiveTexture(gl.GL_TEXTURE2);
  gl.glDisable(gl.GL_TEXTURE_RECTANGLE);
  gl.glActiveTexture(gl.GL_TEXTURE1);
  gl.glDisable(gl.GL_TEXTURE_RECTANGLE);
  gl.glActiveTexture(gl.GL_TEXTURE0);
  gl.glDisable(gl.GL_TEXTURE_RECTANGLE);
  gl.glDisable(gl.GL_FRAGMENT_PROGRAM_ARB);
}
 
Example 19
Source File: JCuboid.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 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);
    gl.glLoadIdentity();
    gl.glTranslatef(0f, 0f, -5.0f);

    gl.glRotatef(rotation, 1.0f, 1.0f, 1.0f);

    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(1f, 0f, 0f); //red color  

    //Top  
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-0.5f, 0.5f, 0.5f);

    //Bottom  
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);

    //Front  
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);
    //Back  

    gl.glVertex3f(-0.5f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);

    //Left  
    gl.glVertex3f(-0.5f, 0.8f, 0.9f);
    gl.glVertex3f(-0.5f, 0.8f, 0.5f);
    gl.glVertex3f(-0.5f, 0.5f, 0.9f);
    gl.glVertex3f(-0.5f, 0.5f, 0.5f);

    //Right  
    gl.glVertex3f(-1f, 0.8f, 0.9f);
    gl.glVertex3f(-1f, 0.8f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.5f);
    gl.glVertex3f(-1f, 0.5f, 0.9f);
    gl.glEnd();
    gl.glFlush();

    rotation -= 0.15f;
}
 
Example 20
Source File: JQuad.java    From MeteoInfo with GNU Lesser General Public License v3.0 3 votes vote down vote up
@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();

}