# 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);

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

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

0.0. glEnd(). float y) { glPointSize(10).1).timer. glVertex2i(0.0)+y). glRotatef(sudut.0.0). glutPostRedisplay(). glVertex2i(0. glutTimerFunc(100. glColor3f(0.0).0). } void timer(int value){ sudut-=0.0).void panahDetik(){ glBegin(GL_POLYGON).7. glVertex2i(-5.240).0. glVertex2i(-5.0. glPushMatrix().jarak*(float)cos(n*PI/180.0.0.100. float x. } void angka(float jarak.. glPopMatrix().1).n+=30) glVertex2f(jarak*(float)sin(n*PI/180.0). glEnd().0.210).0. glPopMatrix().240). glVertex2i(5.210).7. glRotatef(sudut/720. glPushMatrix().n<360.0). glVertex2i(10.). panahDetik(). glPushMatrix().100.0.7).0. glPopMatrix().0.210).. glVertex2i(-10. for(n=0. panahMenit().0. glFlush().210). glVertex2i(5. angka(230. glRotatef(sudut/60.0.0. glColor3f(0.0). glPushMatrix(). lingkaran(250. lingkaran(20. glBegin(GL_POINTS). panahJam(). } void renderScene(void){ glClear(GL_COLOR_BUFFER_BIT).0). } .6. glColor3f(1. glColor3f(0. glPopMatrix().1).0)+x.

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

).0. return 0.320. glutIdleFunc(display)..).160...y2). gluOrtho2D(0. } void userdraw(void) { glBegin(GL_LINES). void drawDot(float x. float y2) { glBegin(GL_LINES).y1). drawLine(160.200.. green.1..0)..y). glutDisplayFunc(display). ..int main (int argc. glColor3f(1..1.argv). glEnd(). float y1.)..).).-200. glutCreateWindow ("Drawing by Segitiga"). float x2...0. drawLine(160.. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB). drawLine(160.480).240.//tengah setColor(0.640.0.)..-240.320.200.). glVertex2f(x2..100).200.. float green.0.//kiri setColor(0..1.h> #include<stdlib. } void drawLine(float x1. drawLine(10. glVertex2f(x.-200..1.-200.-200.char**argv) { glutInit (&argc. glEnd(). float blue) { glColor3f(red.).//bawah } void display (void) { glClear(GL_COLOR_BUFFER_BIT)..).. float y) { glBegin(GL_POINTS). glVertex2f(x1. glClearColor(1.0..0.1.0.h> void userdraw(void). blue).-200. } void setColor(float red.0.10.. glutInitWindowPosition (100.0.//kanan setColor(0. glutInitWindowSize (640... } ---------------- # include <stdio.h> #include <gl/glut. glutMainLoop().

1. return 0.1415926535 float sudut = 0. int i. glVertex2i(5.y). } void panahJam(){ glBegin(GL_POLYGON). } void panahMenit(){ .1. void lingkaran(int radius.480).240. glutInitWindowPosition (100.. int x_tengah.h> #include<stdlib. userdraw(). glColor3f(0. #define PI 3. glutInitWindowSize (640. glutDisplayFunc(display). glVertex2f(x.h> #include <math.200).). glVertex2i(-5.180). } int main (int argc.i++){ float sudut=i*(2*PI/jumlah_titik). glEnd().0. int jumlah_titik. int y_tengah) { glBegin(GL_POLYGON). glutCreateWindow ("Drawing by Segitiga").i<=360.0).180).640. float y=y_tengah+radius*sin(sudut). gluOrtho2D(0. glutSwapBuffers(). } glEnd(). glVertex2i(0. glVertex2i(-5.. for (i=0. } ----- # include <stdio.-240. glVertex2i(10. glVertex2i(-10.0. glutIdleFunc(display).h> #include <gl/glut.100).h> void userdraw(void).0.0).180).0.argv). glutMainLoop().0. float x=x_tengah+radius*cos(sudut).n.0).200). glClearColor(1.180).char**argv) { glutInit (&argc.. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB). glVertex2i(0.0). glVertex2i(5.

angka(230. glPopMatrix(). glVertex2i(-5.0.0)..1). } void panahDetik(){ glBegin(GL_POLYGON).n<360. } void renderScene(void){ glClear(GL_COLOR_BUFFER_BIT).7.200).0. glPopMatrix().0).0)+y). } void angka(float jarak.100. glVertex2i(0.0.0)+x. glVertex2i(-5. glPopMatrix().200).0).200).1). glVertex2i(-5.n+=30) glVertex2f(jarak*(float)sin(n*PI/180. glColor3f(1. glEnd(). glVertex2i(10.0.200).210).0).0. glEnd(). glVertex2i(10. glColor3f(0. glVertex2i(0. panahJam(). glEnd(). glColor3f(1. panahDetik().0. glVertex2i(-10.220).1). glVertex2i(5. glVertex2i(-10. glBegin(GL_POINTS).0). panahMenit().0.210).0).240).7. float x.7). lingkaran(250..1.0. glPopMatrix(). .240). glRotatef(sudut/60. glVertex2i(-5.1).0.220). glVertex2i(5. glColor3f(0. glPushMatrix(). glVertex2i(0. glPushMatrix().0. glVertex2i(0.).210). float y) { glPointSize(10). glVertex2i(5. glPushMatrix(). for(n=0.0. glVertex2i(5.0). glRotatef(sudut/720. glRotatef(sudut.0.jarak*(float)cos(n*PI/180.0. glBegin(GL_POLYGON). glPushMatrix().210).

. glutMainLoop(). glutTimerFunc(100.0).).0. } .0). glutTimerFunc(60.100..6. lingkaran(20. char **argv){ glutInit(&argc. glColor3f(0. glutDisplayFunc(renderScene). } void timer(int value){ sudut-=0. gluOrtho2D(-300.0.-300. argv). glutInitWindowPosition(100. } void main (int argc.timer. glutInitWindowSize(300.. glutPostRedisplay().300.100).0).timer.0).300). glFlush(). glutCreateWindow("JAM ANALOG: ").300.