Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 4d) initiate a 2D vertex array and a 2-D color array */
- 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}};
- 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}};
- /* 4e) Draw a triangle using a vertex array */
- public void polygon( GLAutoDrawable glDrawable, int a, int b, int c) {
- GL gl = glDrawable.getGL();
- gl.glLoadIdentity();
- gl.glTranslatef(0.0f,1.5f,-7.0f);
- gl.glColor3fv(colors[a], 0);
- gl.glBegin(GL.GL_POLYGON);
- gl.glVertex3fv(hjornepunkter[a], 0);
- gl.glVertex3fv(hjornepunkter[b], 0);
- gl.glVertex3fv(hjornepunkter[c], 0);
- gl.glEnd();
- }
- /* 4f) Draw a polygon/quad using a vertex array */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement