Skip to content

Instantly share code, notes, and snippets.

@dwichan0905
Last active November 11, 2019 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwichan0905/5c725d70a225b733596ea06fa528bb48 to your computer and use it in GitHub Desktop.
Save dwichan0905/5c725d70a225b733596ea06fa528bb48 to your computer and use it in GitHub Desktop.
Melakukan Rotasi di OpenGL
#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