Nama :
-
Ananda Putri Syaviri 130533608243
-
Darma Rusdianto 130533608
-
Iman Zulfahmi Mawarid 1305336082
1) Animasi 3D
Sintaks :
// dimodifikasi dari http://cg.lskk.ee.itb.ac.id/SemesterII-20132014/TugasTutorial/23213347
#include <stdio.h> glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity();
gluPerspective(45.0, (float)width/(float)height, 1.0, 300.0);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
}
void myTimeOut(int id) {
// dipanggil jika timer event
// ...advance the state of animation incrementally... //penambahan rotasi animasi
rot+=15;
glutPostRedisplay(); // pemanggilan redsiplay
glutTimerFunc(100, myTimeOut, 0); // pemanggilan untuk timer event selanjutnya }
void myKeyboard(unsignedchar key,int x, int y) //tombol untuk merubah ukuran objek {
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0f,z_pos);
glColor3f(0.0,1.0,0.0);
glutSwapBuffers();
}
void init() {
glClearColor( 0.0, 0.0, 0.0, 1.0 ); // A Background Clear Color glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (GLdouble)500.0/(GLdouble)500.0, 0, 100); glMatrixMode(GL_MODELVIEW);
glutInit(&argc,argv);
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowSize(500,500);
glutCreateWindow("ANIMASI OBJEK 3D");
// pemanggilan fungsi glutDisplayFunc(mydisplay); glutKeyboardFunc(myKeyboard); glutTimerFunc(100, myTimeOut, 0); glutReshapeFunc(resize);
init();
glutMainLoop();
return 0; }
Screenshoot :
mengecil jika menekan tombol ( a/ p)
membesar jika menekan tombol ( j /n.)
2) Screensaver
Sintaks:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdarg.h>
#include<glut.h>
float z_pos=-8.0f;
float rot=0.0f;
// dipanggil jika timer event
// ...advance the state of animation incrementally... //penambahan rotasi animasi
rot+=10;
glutPostRedisplay(); // pemanggilan redsiplay
glutTimerFunc(200, myTimeOut, 0); // pemanggilan untuk timer event selanjutnya }
void init() {
glClearColor( 0.0, 0.0, 0.0, 1.0 ); // A Background Clear Color glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30, (GLdouble)100.0/(GLdouble)100.0, 0, 50); glMatrixMode(GL_MODELVIEW);
return; }
void mydisplay() {
glClear(GL_COLOR_BUFFER_BIT); glTranslatef(0.0,0.0f,z_pos); glRotatef(rot, 1, -4, 0); glBegin(GL_POLYGON); glColor3f(0,0,1);
glutSwapBuffers();
}
int main (int argc, char** argv) {
glutInitWindowSize(500,500); glutCreateWindow("Screensaver biasa"); glutDisplayFunc(mydisplay);
init();
glutTimerFunc(200, myTimeOut, 0); glutMainLoop();
}