#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:
- Configuring OpenGL in Visual Studio 2015
- A strange problem in compiling OpenGL program
- 1 vs20152017 + OpenGL to configure and draw a white rectangle
- Vc2010 configuring OpenGL environment
- Vs2015 + OpenGL environment configuration
- Configure glut in Ubuntu and implement basic OpenGL experiment on CodeBlocks platform
- CodeBlocks configuring OpenGL
- The first day of OpenGL [vs2017 + OpenGL environment configuration]
- |-OpenGL – | some small problems about the glut Library
- The simplest course of configuring OpenGL in vs2015
- OpenGL programming error analysis
- CodeBlocks configuring OpenGL environment
- Using glut in CodeBlocks
- Vs compiling OpenGL project, the solution of unable to open the source file “GL / glaux. H” appears
- In VS2010, the compiler cannot open the file “GL / glaux. H”: no such file or directory
- Configuring OpenGL with win 10 + CodeBlocks
- Error in header file when calling OpenGL to open obj file in vs2013: unable to open include file: “GL / glut. H”: no such file or directories
- Configuring OpenGL in Chinese version of VS2010 and problem solving
- Error: unable to open include file: ‘GL / glut. H’
- Visual studio 2017, OpenGL program running prompt glut32.dll missing solution