#include
void kotak(int x1, int y1, int x2, int y2, int r, int g, int b)
{
glColor3f(r,g,b);
glBegin(GL_LINES);
for(int i=y1; i<=y2; i++)
{
glVertex2i(x1,i);
glVertex2i(x2,i);
}
glEnd();
}
void jajar_tidur(int x1,int y1,int x2,int y2,int d,int r,int g,int b)
{
glColor3f(r,g,b);
glBegin(GL_LINES);
for(int i=x1;i<=x2;i++)
{
glVertex2i(i,y1);
glVertex2i(i+d,y2);
}
glEnd();
}
void jajar_tegak(int x1,int y1, int x2,int y2,int d,int r,int g,int b)
{
glColor3f(r,g,b);
glBegin(GL_LINES);
for(int i=y1;i<=y2;i++)
{
glVertex2i(x1,i);
glVertex2i(x2,i+d);
}
glEnd();
}
void userdraw()
/* {
kotak(10,10,100,100,0,0,1);//kotak luar
kotak(15,15,60,95,1,0,1); //kotak dalam
kotak(65,80,80,95,0,1,1); //kotak 1
kotak(65,55,80,70,0,1,1); //kotak 2
kotak(65,15,80,20,0,1,1); //kotak 3
jajar_tidur(10,100,100,150,30,1,1,0); //jajar tidur
jajar_tidur(40,110,70,140,20,0,0,0); //jajar tidur
jajar_tegak(100,10,130,100,50,0,1,0); //jajar tegak
}*/
{
kotak(10,10,300,300,0,0,1);//kotak luar
kotak(15,15,210,275,1,0,1); //kotak dalam
kotak(230,210,290,275,0,1,1); //kotak 1
kotak(230,100,290,150,0,1,1); //kotak 2
kotak(230,20,290,50,0,1,1); //kotak 3
jajar_tidur(10,300,300,350,50,1,1,0); //jajar tidur
jajar_tidur(50,310,270,340,30,0,0,0); //jajar tidur
jajar_tegak(300,10,350,300,50,0,1,0); //jajar tegak
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
userdraw();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(640,480);
glutCreateWindow("Oven");
glClearColor(1,1,1,0.0);
gluOrtho2D(0,640,0,480);
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Tidak ada komentar:
Posting Komentar