Tugas Grafik
Pakai C++ Open GL
Tugas 1
Tuga2
Tugas 3
Tugas 1
Script
/* OpenGL animation code goes
here */
glClearColor (1, 1,
1, 1);
glClear
(GL_COLOR_BUFFER_BIT);
glPushMatrix ();
//glRotatef (theta,
0.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glColor3f(0,0,90);
glVertex3f(0,20,20);
glEnd ();
glPopMatrix ();
SwapBuffers (hDC);
theta -= 2.0f;
Sleep (1);
}
}
Output :

Tuga2
PERSEGI
Script
/* OpenGL animation
code goes here */
glClearColor (0, 0, 0, 0);
glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix ();
//
glRotatef (theta, 2.0f, 2.0f, 2.0f);
glBegin (GL_POLYGON);
glColor3f(1.f,1.f,1.f);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd
();
glPopMatrix ();
SwapBuffers (hDC);
theta
+= 5.0f;
Sleep
(1);
}
}
Output :

Tugas 3
PERSEGI PANJANG
/* OpenGL animation code goes here */
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix ();
glBegin(GL_POLYGON);
glVertex3f (0.15, 0.95, 0.0);
glVertex3f (0.15, 0.85, 0.0);
glVertex3f (0.85, 0.85, 0.0);
glVertex3f (0.85, 0.95, 0.0);
glEnd
();
glPopMatrix ();
SwapBuffers (hDC);
theta
+= 1.0f;
Sleep
(1);
}
}
Output :

Comments