Advertisement
bardlokas

Untitled

Nov 28th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. /* 4d) initiate a 2D vertex array and a 2-D color array */
  2.  
  3.         static final float hjornepunkter[][] = {{1.0f,1.0f,0.0f}, {3.0f,1.0f,0.0f}, {3.0f,2.0f,0.0f}, {1.0f,2.0f,0.0f}, {2.0f,1.5f,3.0f}};
  4.         static final float colors[][] = {{1.0f,0.0f,0.0f}, {1.0f,1.0f,0.0f}, {0.0f,1.0f,.0f},{0.0f,1.0f,1.0f}, {0.0f,0.f,1.0f}};
  5.  
  6.  
  7.      /* 4e) Draw a triangle using a vertex array */
  8.  
  9.         public void polygon( GLAutoDrawable glDrawable, int a, int b, int c) {
  10.  
  11.             GL gl = glDrawable.getGL();
  12.             gl.glLoadIdentity();
  13.  
  14.             gl.glTranslatef(0.0f,1.5f,-7.0f);
  15.  
  16.             gl.glColor3fv(colors[a], 0);
  17.  
  18.             gl.glBegin(GL.GL_POLYGON);
  19.                 gl.glVertex3fv(hjornepunkter[a], 0);
  20.                 gl.glVertex3fv(hjornepunkter[b], 0);
  21.                 gl.glVertex3fv(hjornepunkter[c], 0);
  22.             gl.glEnd();
  23.         }
  24.  
  25.     /* 4f)  Draw a polygon/quad using a vertex array */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement