C++ program to draw a rhombus using OpenGL
kw.cpp
#include <GL/glut.h>

int main(int agrc, char **argv)
{
    glutInit(&agrc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(500, 500);
    glutCreateWindow("Rhombus");
    glBegin(GL_POLYGON);
        glColor3f(1, 1, 1);
        glVertex2f(0, 1);
        glVertex2f(1, 0);
        glVertex2f(0, -1);
        glVertex2f(-1, 0);
    glEnd();
    glFlush();
    glutMainLoop();
}
Output
kodingwindow@kw:~$ g++ kw.cpp -lGL -lGLU -lglut
kodingwindow@kw:~$ ./a.out
Advertisement