# include <stdio.

h>
#include<stdlib.h>
#include <gl/glut.h>
void userdraw(void);
void drawDot(float x, float y)
{
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
}
void drawLine(float x1, float y1, float x2, float y2)
{
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glEnd();
}

void setColor(float red, float green, float blue)
{
glColor3f(red, green, blue);
}
void userdraw(void)
{

glBegin(GL_LINES);

glColor3f(1.,0.,0.);
drawLine(160.,200.,10.,-200.);//kiri
setColor(0.,0.,1.);
drawLine(160.,200.,160.,-200.);//tengah
setColor(0.,1.,0.);
drawLine(160.,200.,320.,-200.);//kanan
setColor(0.,1.,0.);
drawLine(10.,-200.,320.,-200.);//bawah

}

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 ("Drawing by Segitiga");
glClearColor(1.0,1.0,1.0,0.0);
gluOrtho2D(0.,640.,-240.,240.);
glutIdleFunc(display);
glutDisplayFunc(display);

char**argv) { glutInit (&argc.y1)... } ----- # include <stdio.1.320. glutMainLoop().//bawah } void display (void) { glClear(GL_COLOR_BUFFER_BIT). float x2.y2).. glVertex2f(x1.-200. float y) { glBegin(GL_POINTS)..-200.0.200... drawLine(160. drawLine(160.//tengah setColor(0.0. . } int main (int argc...h> #include<stdlib..0. } void setColor(float red. glColor3f(1. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB).1..200. } void drawLine(float x1..0.h> void userdraw(void).1.100). glEnd(). float y1.480).h> #include <gl/glut.argv).). glVertex2f(x. void drawDot(float x.)..320. glutInitWindowSize (640.200. } void userdraw(void) { glBegin(GL_LINES).. glEnd().0.). userdraw().). blue)..-200.10..). glutInitWindowPosition (100. glVertex2f(x2.... drawLine(160.-200.). green.y). glutSwapBuffers(). drawLine(10.). float blue) { glColor3f(red. return 0.//kiri setColor(0.. float y2) { glBegin(GL_LINES).//kanan setColor(0..-200.). float green.160.

. glVertex2i(5.0).1. glutIdleFunc(display). glutCreateWindow ("Drawing by Segitiga"). glVertex2i(0. return 0.h> #include <gl/glut. } void panahJam(){ glBegin(GL_POLYGON). glVertex2i(10. glVertex2i(5. glVertex2i(-5.0. glutDisplayFunc(display).0.200). void lingkaran(int radius. } glEnd(). glVertex2i(-5. for (i=0.220).200). glEnd().. glVertex2i(0.640.0.180).). glVertex2i(-10. glEnd(). glVertex2i(0..240. glVertex2i(0. int y_tengah) { glBegin(GL_POLYGON).-240. int jumlah_titik. glVertex2i(5. glVertex2i(-5. float y=y_tengah+radius*sin(sudut).y).0). glVertex2i(5. glVertex2f(x.0).i<=360.0.180). glVertex2i(10.h> #include<stdlib. glClearColor(1. float x=x_tengah+radius*cos(sudut).200).0).180).180).1.0.0).h> void userdraw(void). glVertex2i(-5.i++){ float sudut=i*(2*PI/jumlah_titik). glColor3f(0.200).200). } void panahMenit(){ glBegin(GL_POLYGON). glVertex2i(-10. glColor3f(1. int i. } .1.0). int x_tengah. } ---- # include <stdio. #define PI 3.1). glutMainLoop().n.1415926535 float sudut = 0.200).220). gluOrtho2D(0.h> #include <math.

panahMenit().0)+y). } void renderScene(void){ glClear(GL_COLOR_BUFFER_BIT). glPushMatrix().7). glVertex2i(5.0).210). glVertex2i(-5.0. glRotatef(sudut/720.0. glVertex2i(-5. glVertex2i(5.7.0). glPopMatrix().1).0.0.).240).6. glutTimerFunc(100. panahDetik(). glRotatef(sudut. angka(230.0.0). float y) { glPointSize(10).0.0).210).0.. glVertex2i(0. glColor3f(0.210). glEnd().0).. glBegin(GL_POINTS).210).1).n+=30) glVertex2f(jarak*(float)sin(n*PI/180. panahJam().0).0.0. glVertex2i(0.0.n<360.1). glPopMatrix(). glRotatef(sudut/60. } . } void angka(float jarak. float x. glColor3f(0.timer. glutPostRedisplay(). glPushMatrix().0. glPushMatrix().0)+x. glPopMatrix(). glVertex2i(10.0. glEnd().0. glVertex2i(-10. lingkaran(250.0.0).void panahDetik(){ glBegin(GL_POLYGON). for(n=0. lingkaran(20.100. glFlush(). glPushMatrix().jarak*(float)cos(n*PI/180.0.240).100. } void timer(int value){ sudut-=0.7. glPopMatrix().0). glColor3f(1. glColor3f(0.

glVertex2f(x2.-200. } void setColor(float red.0. } - # include <stdio. glVertex2f(x1. char **argv){ glutInit(&argc.300.h> #include <gl/glut.//tengah setColor(0.300.-200. float y) { glBegin(GL_POINTS).0.1.timer. drawLine(160. gluOrtho2D(-300. glutCreateWindow("JAM ANALOG: ").. float x2... } .)..). glutTimerFunc(60. glutInitWindowSize(300. glEnd().0).-200. drawLine(160.1. void drawDot(float x.. glColor3f(1...-200. green. blue). drawLine(160..320. drawLine(10.200.1.y1)..).. float y1. glEnd()..0.//kanan setColor(0..160.200.320.. argv).. glutSwapBuffers(). glVertex2f(x. glutInitWindowPosition(100. } void userdraw(void) { glBegin(GL_LINES).).).).200.. float y2) { glBegin(GL_LINES). float green....-300. glutMainLoop().100).-200.).0... userdraw(). } void drawLine(float x1. float blue) { glColor3f(red.0.).).y).h> #include<stdlib..//kiri setColor(0. glutDisplayFunc(renderScene).300).h> void userdraw(void)...y2).void main (int argc.10.//bawah } void display (void) { glClear(GL_COLOR_BUFFER_BIT).

1.640..1. glutIdleFunc(display). glutDisplayFunc(display).240. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB).0.480). glutMainLoop().0). glutCreateWindow ("Drawing by Segitiga").char**argv) { glutInit (&argc. glClearColor(1.100). return 0. } .. gluOrtho2D(0.0.-240. glutInitWindowSize (640..).0.int main (int argc.argv).0. glutInitWindowPosition (100.