void printer(void)
{
glClearColor(1.0,1.0,1.0,0.0); //putih
}
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
// segitiga sebelah kiri
glColor3f(1,0,0);
glVertex2f(-0.425f, 0.95f);
glVertex2f(-0.55f, -0.25f);
glVertex2f(-0.2f, -0.15f);
// segitiga sebelah kiri
glColor3f(1,0,0);
glVertex2f(-0.55f, -0.25f);
glVertex2f(-0.2f, -0.15f);
glVertex2f(-0.4f, -0.5f);
// segitiga sebelah kiri
glColor3f(1,0,0);
glVertex2f(-0.4f, -0.515f);
glVertex2f(-0.2f, -0.165f);
glVertex2f(-0.2f, -0.8f);
// segitiga sebelah kiri atas
glColor3f(1,0,0);
glVertex2f(-0.14f, 0.85f);
glVertex2f(0.0f, 0.675f);
glVertex2f(0.0f, 0.75f);
// segitiga sebelah kanan
glColor3f(1,0,0);
glVertex2f(0.425f, 0.95f);
glVertex2f(0.55f, -0.25f);
glVertex2f(0.2f, -0.15f);
// segitiga sebelah kanan
glColor3f(1,0,0);
glVertex2f(0.55f, -0.25f);
glVertex2f(0.2f, -0.15f);
glVertex2f(0.4f, -0.5f);
// segitiga sebelah kanan
glColor3f(1,0,0);
glVertex2f(0.4f, -0.515f);
glVertex2f(0.2f, -0.165f);
glVertex2f(0.2f, -0.8f);
// segitiga sebelah kanan atas
glColor3f(1,0,0);
glVertex2f(0.14f, 0.85f);
glVertex2f(0.0f, 0.675f);
glVertex2f(0.0f, 0.75f);
// segitiga yang membentuk segi empat di tengah
glColor3f(1,0,0);
glVertex2f(-0.19f, -0.8f);
glVertex2f(-0.135f, 0.825f);
glVertex2f(0.0f, 0.65f);
// segitiga yang membentuk segi empat di tengah
glColor3f(1,0,0);
glVertex2f(-0.19f, -0.8f);
glVertex2f(0.0f, 0.65f);
glVertex2f(0.0f, -0.65f);
// segitiga yang membentuk segi empat di tengah
glColor3f(1,0,0);
glVertex2f(0.19f, -0.8f);
glVertex2f(0.135f, 0.825f);
glVertex2f(0.0f, 0.65f);
// segitiga yang membentuk segi empat di tengah
glColor3f(1,0,0);
glVertex2f(0.19f, -0.8f);
glVertex2f(0.0f, 0.65f);
glVertex2f(0.0f, -0.65f);
glEnd();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(320, 320);
glutCreateWindow("GLUT 1st program");
printer();
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
Dan hasil yang akan muncul jika source code ini jalan adalah :
Tidak ada komentar:
Posting Komentar