Last active
November 11, 2019 12:35
-
-
Save dwichan0905/5c725d70a225b733596ea06fa528bb48 to your computer and use it in GitHub Desktop.
Melakukan Rotasi di OpenGL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <GL\glut.h> | |
#include <math.h> | |
void rotasi() { | |
glBegin(GL_POLYGON); //membuat persegi | |
glVertex2f(0.0,0.0); | |
glVertex2f(0.0, 50.0); | |
glVertex2f(200.0, 50.0); | |
glVertex2f(200.0, 0.0); | |
glEnd(); | |
} | |
void render3() { | |
glColor3f(0.0, 1.0, 0.0); //memberi warna hijau objek rotasi | |
rotasi(); | |
glRotatef(-90, 0, 0, 1); //rotasi objek berdasar sudut,x,y,z | |
glColor3f(1.0, 0.0, 0.0); // warna merah | |
rotasi(); | |
glFlush(); | |
} | |
// uncomment this section to run | |
int main(int argc, char** argv) { | |
glutInit(&argc, argv); | |
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | |
glutInitWindowSize(480, 480); | |
glutInitWindowPosition(0, 0); | |
glutCreateWindow("Rotasi Objek"); //Judul Window | |
gluOrtho2D(-320.0, 320.0, -320.0, 320.0); | |
glutDisplayFunc(render3); | |
glutMainLoop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment