#include <stdlib.h>
#include <glut.h>
#include <math.h>
#define PI 3.1415926535
bool atas = true;
int lingkaranp = 0;
int i;
int gerak = 0;
void lingkaran(int ganti){
glPopMatrix();
glPushMatrix();
glTranslatef(0,gerak,0);
glRotatef(lingkaranp+ganti,0,0,100);
glBegin(GL_POLYGON);
for (i=0;i<=360;i++){
float sudut = i * (2*PI/360);
float x=150+20*cos(sudut);
float y=20*sin(sudut);
glVertex2f(x,y);
}
glEnd();
}
void segitiga(){
glPopMatrix();
glPushMatrix();
glTranslatef(0,gerak,0);
glBegin(GL_TRIANGLES);
glColor3f(1.,1.,0.);
glVertex2f(0,100);//a
glVertex2f(-100,-50);//b
glVertex2f(100,-50);//c
glEnd();
}
void timer(int t){
if (atas){
gerak += 10;
} else {
gerak -= 10;
}
if (gerak > 300) {
atas = false;
} else if(gerak < -300){
atas = true;
}
if (lingkaranp < 360){
lingkaranp += 10;
} else {
lingkaranp = 0;
}
glutPostRedisplay();
glutTimerFunc(10,timer,0);
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
segitiga();
lingkaran(0);
lingkaran(90);
lingkaran(270);
lingkaran(360);
glFlush();
}
void main(int argc, char **argv){
glutInit(&argc, argv);
/*...*/
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400,400);
glutCreateWindow("Mahfuz - 100533405403");
gluOrtho2D(-640.,640.,-640.,640.);
glutDisplayFunc(display);
glutTimerFunc(1,timer,0);
glutMainLoop();
}
#include <glut.h>
#include <math.h>
#define PI 3.1415926535
bool atas = true;
int lingkaranp = 0;
int i;
int gerak = 0;
void lingkaran(int ganti){
glPopMatrix();
glPushMatrix();
glTranslatef(0,gerak,0);
glRotatef(lingkaranp+ganti,0,0,100);
glBegin(GL_POLYGON);
for (i=0;i<=360;i++){
float sudut = i * (2*PI/360);
float x=150+20*cos(sudut);
float y=20*sin(sudut);
glVertex2f(x,y);
}
glEnd();
}
void segitiga(){
glPopMatrix();
glPushMatrix();
glTranslatef(0,gerak,0);
glBegin(GL_TRIANGLES);
glColor3f(1.,1.,0.);
glVertex2f(0,100);//a
glVertex2f(-100,-50);//b
glVertex2f(100,-50);//c
glEnd();
}
void timer(int t){
if (atas){
gerak += 10;
} else {
gerak -= 10;
}
if (gerak > 300) {
atas = false;
} else if(gerak < -300){
atas = true;
}
if (lingkaranp < 360){
lingkaranp += 10;
} else {
lingkaranp = 0;
}
glutPostRedisplay();
glutTimerFunc(10,timer,0);
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
segitiga();
lingkaran(0);
lingkaran(90);
lingkaran(270);
lingkaran(360);
glFlush();
}
void main(int argc, char **argv){
glutInit(&argc, argv);
/*...*/
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400,400);
glutCreateWindow("Mahfuz - 100533405403");
gluOrtho2D(-640.,640.,-640.,640.);
glutDisplayFunc(display);
glutTimerFunc(1,timer,0);
glutMainLoop();
}
0 komentar:
Posting Komentar