#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
- 1 vs20152017 + OpenGL to configure and draw a white rectangle
- [181124] VC + + use OpenGL to draw 3D graphics example source code
- Configure glut in Ubuntu and implement basic OpenGL experiment on CodeBlocks platform
- Vc2010 configuring OpenGL environment
- A strange problem in compiling OpenGL program
- 076_ OpenGL graphics program development practice
- OpenGL basic graphics programming – OpenGL and 3D graphics world
- #During OpenGL development, fatal error C1083: can’t open include file: “GL / glut. H”: no such file or directory
- Vs2015 + OpenGL environment configuration
- Solve the problem of VC6.0 open crash and OpenGL glut32.lib library
- OpenGL learning — problems encountered in compiling OpenGL program for the first time
- Visual studio 2017, OpenGL program running prompt glut32.dll missing solution
- 0028opengl program running prompt glut32.dll missing one of the solutions
- A series of problems in configuring OpenGL development environment in vs2015
- OpenGL program running prompt glut32.dll missing problem
- 2016.11.1 OpenGL learning, black screen does not display graphics
- [OpenGL] cannot start this program because the computer is missing glut32.dll. Try to re install the program to fix this problem. …
- OpenGL configuration file, as well as unable to parse the file solution
- After the vs2013 + OpenGL environment is set up, there is an error in running the first program