TUGAS GRAFKOM Q 3
Friday, 7 December 2012
KINCIR ANGIN
keterangan :
pakek openGL microsoft visual c++ 2010 express.
kincir angin ini bisa di control dengan meng klik tombol di keyboard
tombol d : muter ke kiri.
tombol s : muter ke kanan..
source code
#include <glut.h>
#include <stdlib.h>
static GLfloat spin = 0.0;
void init(void)
{
glClearColor (1.1, 1.1, 1.1, 1.1);
glShadeModel (GL_FLAT);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); // pembuatan tiang
glPushMatrix();
glColor3f(1.0, 0.0, 1.0);
glRectf(-8.0, -50.0, 8.0, 10.0);
glPopMatrix();
glPushMatrix(); // pembuatan baling 1
glRotatef(spin, 0.0, 0.0, 1.0);
glColor3f(0.0, 0.0, 1.0); //pembuatan baling 1 warna biru
glRectf(-5.0, -30.0, 5.0, 30.0);
glColor3f(0.0, 1.0, 0.0); //pembuatan baling 2 hijau
glRectf(-30.0, -5.0, 30.0, 5.0);
glPopMatrix();
glutSwapBuffers();
}
void spinDisplay(void)
{
spin = spin + 0.3;
if (spin > 360.0)
spin = spin - 360.0;
glutPostRedisplay();
}
void spinDisplay2(void)
{
spin = spin - 0.3;
if (spin > 360.0)
spin = spin - 360.0;
glutPostRedisplay();
}
void reshape(int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case 'd':
glutIdleFunc(spinDisplay);
break;
case 's':
glutIdleFunc(spinDisplay2);
break;
}
}
/*void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case 'd':
day = (day + 10) % 360;
glutPostRedisplay();
break;
case 'D':
day = (day - 10) % 360;
glutPostRedisplay();
break;
case 'y':
year = (year + 5) % 360;
glutPostRedisplay();
break;
case 'Y':
year = (year - 5) % 360;
glutPostRedisplay();
break;
default:
break;
}
}*/
/*
* Request double buffer display mode.
* Register mouse input callback functions
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
Subscribe to:
Post Comments (Atom)
aplikasi untuk cek BRAND KAMU, apakah sedang bisa digunakan untuk semua sosmed termasuk website ataukah tidak.
aplikasi untuk cek BRAND KAMU, apakah sedang bisa digunakan untuk semua sosmed termasuk website ataukah tidak. https://handle.tools/?utm_s...

This comment has been removed by the author.
ReplyDelete