gurumutant icon

OpenGL Lingkaran Sederhana

gurumutant | PRO | 09/07/17 04:10:15 AM UTC | 0 ⭐ | 628 👁️ | Never ⏰ | []
C++ |

900 B

|

None

|

0 👍

/

0 👎

#include <iostream>
#include <GL/glut.h>
using namespace std;
#define PI 3.14
void lingkaran(float center_x, float center_y, float jari2, int res = 100) {
    glBegin(GL_LINE_LOOP);
        for(int i = 0; i <= res;i++) { glVertex2f(
                center_x + (jari2 * cos(i * (2.0f * PI) / res)),
                center_y + (jari2 * sin(i * (2.0f * PI) / res))
            ); }
    glEnd();
}
void tampil() {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3ub(0,255,0);
    lingkaran(100,100,70);
    glutSwapBuffers();
}
int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
    glutInitWindowPosition(100,100); glutInitWindowSize(480,480);
    glutCreateWindow("Pemrograman Grafik RPL 2017");
    glClearColor(1.0,1.0,1.0,0);
    gluOrtho2D(0.,200.,0.,200.); // proyeksi bidang gambar
    glutDisplayFunc(tampil); glutMainLoop(); return 0;
}

Comments