Membuat Persegi Panjang 2D- Pemrograman Grafik
#include <GL/glut.h> void renderScene(void) { glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f (-0.7f, -0.5f); glVertex2f (-0.7f, 0.2f); glVertex2f (0.7f, 0.2f); glVertex2f (0.7f, -0.5f); glColor3f (1.0, 0.0, 0.0); glEnd(); glFlush(); } int main(int argc, char* argv[]) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA); glutCreateWindow("Bangun Persegi Panjang"); glutInitWindowPosition(200, 200); glutInitWindowSize(400,400); glutDisplayFunc (renderScene); glutMainLoop(); return 0; }