membuat rumah dengan dev c++

16 Feb

ini adalah tugas praktikum grafika komputer, mungkin berguna buat temen-temen untuk dijadikan referensi. hasil outputnya adalah sebuah rumah yang dibangun dari koding program persegi empat dan segitiga.

 

#include <gl/glut.h>
void myhome(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);

glColor3f(0.70,0.77,0.9); // biru warna langit itu gunung

glVertex2f(1.0,1.0);

glVertex2f(1.0,-0.1);

glVertex2f(-1.0,-0.1);

glVertex2f(-1.0,1.0);

glEnd();

glBegin(GL_TRIANGLES);// segitiga atap
glColor3f(0.1f, 0.0f, 1.0f);glVertex3f(-0.30, 0.10,0.00);
glColor3f(1.0f, 0.0f, 1.0f);glVertex3f(0.30, 0.10, 0.00);
glColor3f(1.0f, 1.0f, 1.0f);glVertex3f(0.00, 0.40, 0.00);
glEnd();

glBegin(GL_POLYGON);// segiempat dinding

glColor3f(0.1f, 0.0f, 1.0f) ;glVertex2f(-0.2,0.1);

glColor3f(1.0f, 1.1f, 1.0f);glVertex2f(0.2,0.1);

glColor3f(0.0f, 0.0f, 1.0f);glVertex2f(0.2,-0.2);

glColor3f(1.0f, 0.0f, 1.0f);glVertex2f(-0.2,-0.2);

glEnd();

glLineWidth(5.0f);//jendela
glBegin(GL_LINES);
glColor3f(0.90,0.90,0.9);
glVertex3f(-0.10, 0.10, 0.0);
glVertex3f(-0.10, -0.10,0.0);
glVertex3f(-0.10, -0.10, 0.0);
glVertex3f(0.10, -0.10, 0.0);
glVertex3f(0.10, -0.10, 0.0);
glVertex3f(0.10, 0.10, 0.0);

glEnd();

glLineWidth(5.0f);//jendela
glBegin(GL_LINES);
glColor3f(0.90,0.90,0.9);
glVertex3f(0.00, 0.10, 0.0);
glVertex3f(0.00, -0.10, 0.0);

glEnd();

glBegin(GL_POLYGON); //awan
glColor3f(0.90,0.90,0.9);
glVertex2f(-6.0,-0.9);
glVertex2f(-6.0,5.0);
glVertex2f(0.0,1.0);

glEnd();

glBegin(GL_POLYGON); //awan
glColor3f(0.90,0.90,0.9);
glVertex2f(7.0,-0.9);
glVertex2f(6.0,8.0);
glVertex2f(0.0,1.0);

glEnd();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(250,250);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow(“myhome”);
glutDisplayFunc(myhome);
glClearColor (0.4,0.4,0.4,0.4);// warna dasar abu-abu
glutMainLoop ();
return 0;
}

2 Responses to “membuat rumah dengan dev c++”

  1. Hfid March 2, 2011 at 8:46 pm #

    Trims y info codeny..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: