Terdapat tiga transformasi objek yaitu:
1. Translasi (perpindahan)
2. Rotasi (perputaran)
3. Scale (perbesar atau perkecil)
Selamat mencobaaaaa...!! Baca Selengkapnya...
Senin, Oktober 24, 2011 | 0 Comments
#include "stdlib.h" #include "gl/glut.h" void drawQuad(){ glBegin(GL_QUADS); glVertex2f(0.,0.); glVertex2f(0.,10.); glVertex2f(20.,10.); glVertex2f(20.,0.); glEnd(); } void bg(){ glColor3f(1,1,0); glBegin(GL_QUADS); glVertex2f(200.,200.); glVertex2f(-200.,200.); glVertex2f(-200.,-200.); glVertex2f(200.,-200.); glEnd(); } void renderScene(void){ glClear(GL_COLOR_BUFFER_BIT); bg(); glScalef(1.5,1.5,0); // men-scale semua objek glColor3f(1.,1.,1.); drawQuad(); glTranslatef(0,10,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(-20,0,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(0,-10,0); glColor3f(1.,1.,1.); drawQuad(); glRotatef(180,1,1,0); glTranslatef(30,-30,0); glColor3f(1.,1.,1.); drawQuad(); glTranslatef(0,10,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(0,70,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(0,10,0); glColor3f(1.,1.,1.); drawQuad(); glRotatef(180,1,1,0); glTranslatef(-20,-50,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(-20,0,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(-20,0,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(-20,0,0); glColor3f(1.,0.,0.); drawQuad(); glTranslatef(10,-10,0); glColor3f(1.,1.,1.); drawQuad(); glTranslatef(40,0,0); glColor3f(1.,1.,1.); drawQuad(); glFlush(); } void main(int argc, char **argv){ glutInit (&argc, argv); glutInitWindowPosition (100,100); glutInitWindowSize (480,480); glutCreateWindow ("SPONGEBOB"); gluOrtho2D(-100.0,100.0,-70.0,100.0); glutDisplayFunc (renderScene); glutMainLoop (); }
Mengalahkan orang lain itu hebat, tapi lebih hebat orang yang mengalahkan dirinya sendiri.
Copyright © 2008 Liphoe . All Rights Reserved.
Design by Padd IT Solutions - Blogger Notes Template by Blogger Templates
Tidak ada komentar:
Posting Komentar