ini adalah soal uts yang saya dapatkan, terima kasih untuk kawan-kawan yang telah nenbei inspirasi dan dukungan. salam kompak selalu ....
#include "stdlib.h"
#include "gl/glut.h"
#include "math.h"
const double PI = 3.141592653589793;
int i;
void lingkaran(int radius, int jumlah_titik, int x_tengah, int y_tengah) {
glBegin(GL_POLYGON);
for (i=0;i<=360;i++){
float sudut=i*(2*PI/jumlah_titik);
float x=x_tengah+radius*cos(sudut);
float y=y_tengah+radius*sin(sudut);
glVertex2f(x,y);
}
glEnd();
}
void back(){
glBegin(GL_QUADS);
glColor3f(0.,0.3,0.2);
glVertex2d (-145,145);
glVertex2d(145,145);
glVertex2d(145,-145);
glVertex2d (-145,-145);
glEnd(); }
void Draw() {
glClear(GL_COLOR_BUFFER_BIT);
int x,y,b;
glBegin(GL_LINES);
glColor3f(0.,1.,0.);
glVertex2f(-150,0);
glVertex2f(150,0);
glEnd();
glBegin(GL_LINES);
glVertex2f(55,150);
glVertex2f(55,-150);
glEnd();
glBegin(GL_LINES);
glColor3f(0.,1.,0.);
glVertex2f(-55,150);
glVertex2f(-55,-150);
glEnd();
//==========================================================
x=-55;
y=0;
for (b=1;b<=2;b++)
{
glColor3f(0.,1.,0.);
lingkaran(40,100,x,y);
x+=110;
}
//===========================================================
glFlush();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(700, 600);
glutInitWindowPosition(0, 0);
glutCreateWindow("Basuki 09.10.031.802.046");
gluOrtho2D(-150., 150., -150., 150.);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
Wednesday, 2 May 2012
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment