VC + + OpenGL is used as the development platform to design the program, which can generate any pixel on the screen, and use the pixel to draw the basic graphics

#include < GL/glut.h>
#include< Windows.h>
void init (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0);
glMatrixMode (GL_PROJECTION); //
gluOrtho2D (-5.0, 5.0, 5.0, 5.0); X:-5.0~5.0, Y:-5.0~5.0
{
begin (GL_POLYGON);
glBegin (GL_POLYGON);
glVertex2f (0.0f,-2.5f); //
glVertex2f (0.0f,-2.5f);
glVertex2f (1.0f,0.0f);
glVertex2f (1.0f,0.0f); //
glVertex2f (0.0f, 2.5f);
glVertex2f (-1.0f,0.0f);
glVertex2f (-1.0f,0.0f);
glEnd ();
}
Void myDisplay(void)
{
Clear (GL_COLOR_BUFFER_BIT);// to empty
GlLoadIdentity (); // Set the current matrix to the identity matrix
glRotatef(45,0.0,0.0,1.0);
glTranslatRef (0.0,2.5,0.0);
glColor3f (0.0, 1.0, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glRotatef(135,0.0,0.0,1.0);
glTranslatRef (0.0,2.5,0.0);
glColor3f (0.0, 1.0, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glRotatef(-45,0.0,0.0,1.0);
glTranslatRef (0.0,2.5,0.0);
glColor3f (0.0, 1.0, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glRotatef(-135,0.0,0.0,1.0);
glTranslatRef (0.0,2.5,0.0);
glColor3f (0.0, 1.0, 0.0);
drawDiamond ();

glLoadIdentity (); // Set the current matrix to the identity matrix
glColor3f(1.0,0.0,0.0);
glTranslatef (0.0, 2.5, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glColor3f(1.0,0.0,0.0);
glRotatef (90, 0.0, 1.0);
glTranslatef (0.0, 2.5, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glColor3f(1.0,0.0,0.0);
glRotatef (- 90, 0.0, 1.0);
glTranslatef (0.0, 2.5, 0.0);
drawDiamond ();
GlLoadIdentity (); // Set the current matrix to the identity matrix
glColor3f(1.0,0.0,0.0);
glTranslatef (0.0, 2.5, 0.0);
drawDiamond ();
glFlush ();
}
Int main (int argc, char *argv[])
{
utinit (& argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition (0, 0);
glutInitWindowSize (600, 600);
glutCreateWindow (” Hello Opengl!” );
init ();
glutDisplayFunc (& amp; myDisplay);
glutMainLoop ();
return 0;

}


Read More: