Monday, 26 May 2014

Grafkom praktikum 6

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <glut.h>
//#include <glu.h>
#include <iostream>

float _angle = 45.0f;
//draws the 3D scene
void mydisplay()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //menghapus layar
    glMatrixMode(GL_MODELVIEW); //switch to setting the camera perspective
    glLoadIdentity();//reset the camera
    //glTranslatef(0.5f, 0.0f, 0.0f);//translasi
    //glScalef(2.0f, 2.0f, 3.0f);//skala
    //glRotatef(_angle, 0.0f, 0.0f, 1.0f);
    glPushMatrix();//save the transformations performed thus far
    glBegin(GL_POLYGON);
    glVertex3f(-0.1f, -0.1f, 0.0f);
    glVertex3f(-0.1f, 0.1f, 0.0f);
    glVertex3f(0.1f, 0.1f, 0.0f);
    glVertex3f(0.1f, -0.1f, 0.0f);
    glEnd();
    glPopMatrix();//undo the move to the center of the trapezoid
    glutSwapBuffers();//send the 3D scene to the screen
    glFlush();
}



void update(int value){
    _angle += 9.0f;
    if(_angle > 360){
        _angle -= 360;
    }
    glutPostRedisplay();//tell glut that the display changed
    //Tell glut to call update
    glutTimerFunc(25, update, 0);
}
int main(int argc, char** argv)
{
glutInitWindowSize(400,400);
printf("Contoh Sederhana Kotak ");
glutCreateWindow("Praktikum");
glutDisplayFunc(mydisplay);
glutTimerFunc(25, update,0);
glutMainLoop();
return 0;
}

No comments:

Post a Comment

Konversi Suhu

#include <iostream> #include <conio.h> //#include <cstdlib> //#include <iostream.h> void main( float Celcius, Kelvi...