The GL Library in OpenGL is the core library, Glu is a utility library, glut is a utility library, GL is the core, Glu is part of the package for GL, glut is OpenGL's cross-platform tool Library, GL contains the most basic 3D functions, and Glu seems to support GL, if the arithmetic is good, The same effect can be done without the glu of the case. Glut is the basic window interface, is independent of GL and Glu, if you do not like to use glut can use MFC and Win32 window, etc., but glut is cross-platform, which ensures that our program is a cross-platform, If you use MFC or WIN32 only on Windows operating systems. One of the big reasons for choosing OpenGL is that it's cross-platform, so we can use the glut library as much as possible.
Construction of GLUT:
1.Download for glut:
(1). to http://www.ibiblio.org/pub/packages/development/graphics/glut/download glut3.7
(2). To http://www.opengl.org/resources/libraries/glut/glut_downloads.php download glut35.zip for compilation (note that Glutmake.bat is executed before compiling).
2.Configuration of glut
(1). Place the glut.h in the Microsoft Visual STUDIO\VC\INCLUDE\GL directory. (depending on your compiler and installation location, there may be a Microsoft Sdks\windows\v7.1a\include\gl or Windows KITS\8.1\INCLUDE\UM\GL, where there may be a number change in the path, If the sample compiles all the time but can be placed in these three locations)
(2). Place Glut.lib and Glut32.lib in the VC\bin directory (depending on your compiler and installation location)
(3). 32-bit system: Put Glut.dll and Glut32.dll in c:\Windows\System32\
64-bit system: Put Glut.dll and Glut32.dll in c:\Windows\SysWOW64\
3. Compiler settings
Add Glut32.lib and Glut.lib to the connection items in the project properties
4. First instance of the program
The project option should be sure that Windows is not the console
#include <GL/glut.h>
#pragma comment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")//Remove the console
void Renderscene (void) //Render function
{
glclear (gl_color_buffer_bit);
Glbegin (gl_triangles);
glvertex3f (0.0, 0.0, 0.0);
glvertex3f (0.5, 0.0, 0.0);
glvertex3f (0.0, 0.5, 0.0);
Glend ();
Glflush ();
}
int main (int argc, char **argv)
{
glutinit (&ARGC, argv);
Glutinitdisplaymode (glut_depth | Glut_single | GLUT_RGBA);
Glutinitwindowposition (+);
Glutinitwindowsize (a);
Glutcreatewindow ("GLUT");
Glutdisplayfunc (renderscene); Set the Render function
glutmainloop ();
}
If you still can't solve the problem, try the following code
#include <gl/glut.h>
#include <gl/GLU.h>
#include <gl/GL.h>
#pragma comment (lib, " Opengl32.lib ")
#pragma comment (lib," Glut32.lib ") //If you do not find these files can use absolute path, note that the path ' \ ' to change to ' \ \ '
#pragma Comment (lib, "Glu32.lib")
#pragma comment (lib, "Glut.lib")
void Renderscene (void)
{
glclear (gl_ Color_buffer_bit | Gl_depth_buffer_bit);
Glloadidentity ();
Glbegin (gl_triangles);
glvertex3f (6.0f, 2.0f, 0.0f);
glvertex3f ( -1.0f, -1.0f, 0.0f);
glvertex3f (1.0f, -1.0f, 0.0f);
Glend ();
Gltranslatef (3.0f, 0.0f, -1.0f);
Glutswapbuffers ();
}
int main (int argc, char * argv[])
{
glutinit (&ARGC, (char**) argv);
Glutinitdisplaymode (glut_depth | glut_double | GLUT_RGBA);
Glutinitwindowposition (+);
Glutinitwindowsize (+/-);
Glutcreatewindow ("Hello OpenGL");
Glutdisplayfunc (renderscene);
Glutidlefunc (renderscene);
Glenable (gl_depth_test);
Glutmainloop ();
return 0;
}