Pada kesempatan kali ini saya akan membuat sebuah gambar berbentuk burung dengan program codeblocks
pasitkan freeglut sudah terinstal
atau bisa download disini
freeglut-MinGW-2.8.0-1.mp
pertama masukan code di bawah ini
jika sudah build code tersebut jika tanpa kesalahan akan menjadi seperti ini
cukup sekian postingan saya kali ini terimakasih
Salam Luarbiasa
pasitkan freeglut sudah terinstal
atau bisa download disini
freeglut-MinGW-2.8.0-1.mp
pertama masukan code di bawah ini
#include
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);//warna background
//kita bisa menyimpan suatu vertex dengan array
//pertama kita deklarasi arraynya
//contoh float arayvertex[2]={0.5f,0.5f};
//kemudian dalam verteknya bukan menggunakan glcolor2f , tapi glVertex2fv(arayvertex);
//otomatis glcolorv akan mengambil yang ada diarray
glBegin(GL_TRIANGLES);
//segitiga atas kanan
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.0f, 0.90f);
glVertex2f(0.0f, 0.78f);
glVertex2f(0.10f, 0.92f);
//segitiga atas kiri
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.0f, 0.90f);
glVertex2f(0.0f, 0.78f);
glVertex2f(-0.10f, 0.92f);
//segitiga leher 1
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.0f, 0.75f);
glVertex2f(0.0f, -0.20f);
glVertex2f(0.06f, 0.82f);
//segitiga leher 2
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.0f, 0.75f);
glVertex2f(0.0f, -0.20f);
glVertex2f(-0.06f, 0.82f);
//segitiga leher 3
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.06f, 0.82f);
glVertex2f(0.00f, -0.20f);
glVertex2f(0.18f, -0.40f);
//segitiga leher 4
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-0.06f, 0.82f);
glVertex2f(-0.00f, -0.20f);
glVertex2f(-0.18f, -0.40f);
//segitiga bawah kanan
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.14f, 0.12f);
glVertex2f(0.40f, -0.03f);
glVertex2f(0.19f, -0.40f);
//segitiga bawah kiri
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-0.14f, 0.12f);
glVertex2f(-0.40f, -0.03f);
glVertex2f(-0.19f, -0.40f);
//segitiga sayap bawah kanan
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.15f, 0.12);
glVertex2f(0.41f, -0.03f);
glVertex2f(0.60f, 0.18f);
//segitiga sayap bawah kiri
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-0.15f, 0.12);
glVertex2f(-0.41f, -0.03f);
glVertex2f(-0.60f, 0.18f);
//segitiga sayap atas kanan
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(0.16f, 0.13);
glVertex2f(0.60f, 0.19f);
glVertex2f(0.70f, 0.95f);
//segitiga sayap atas kiri
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-0.16f, 0.13);
glVertex2f(-0.60f, 0.19f);
glVertex2f(-0.70f, 0.95f);
glEnd();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(500, 500);
glutCreateWindow("Membuat persegi berwarna");
glutDisplayFunc(renderScene);
glutMainLoop();//program akan menggambar terus menerus
return 0;
}
jika sudah build code tersebut jika tanpa kesalahan akan menjadi seperti ini
cukup sekian postingan saya kali ini terimakasih
Salam Luarbiasa
No comments:
Post a Comment