In this section, we will study the development environment of OpenGL in WIN10 64 and VS1013 environment.
(1) Select a compilation environment:
Now the main compiler tools for OpenGL in Windows are visual Studio,broland C + + Builder,dev C + +, we choose Visual Studio2013 as the development environment.
(2) Resources used:
We used the three libraries of Glew,freeglut and Gltools . Here is an introduction to them:
1) Glew:
The OpenGL Extension Wrangler Library (Glew) is a cross-platform open-source C + + Extension loading library. Glew provides efficient run-time mechanisms for determining which OpenGL extensions is supported on the target platform. OpenGL core and extension functionality is exposed in a single header file. Glew have been tested on a variety of operating systems, including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris.
Glew is a cross-platform OpenGL Extension library that supports multiple operating systems.
2) Freeglut:
Freeglut is a free-software/open-source alternative to the OpenGL Utility Toolkit (GLUT) library. (Freeglut is a free software/open source Alternative OpenGL Utility Kit (GLUT) library.) )
3) Gltools:
The main purpose is to obtain the compiled Gltools.lib file for this project.
(3) Configuration of the development environment:
1) Download the file:
Filename |
My files |
Download website |
1.GLEW |
Http://files.cnblogs.com/files/MenAngel/glew-1.7.0-win64.zip |
http://glew.sourceforge.net/ |
2.freeglut need to compile the package (no no NO) |
Http://files.cnblogs.com/files/MenAngel/freeglut-3.0.0.tar.gz |
http://freeglut.sourceforge.net/ |
3.GLTools need to compile package (not OK) |
Http://files.cnblogs.com/files/MenAngel/GLTools-master.zip |
Https://codeload.github.com/HazimGazov/GLTools/zip/master |
4.freeglut (only Freeglut.lib and. dll) |
Http://files.cnblogs.com/files/MenAngel/freeglut_2.8.0.zip |
http://download.csdn.net/detail/wocaowogannimei/8082851 |
5.GL and GLTools.lib Pack |
http://files.cnblogs.com/files/MenAngel/GL%E5%92%8Cgltools.dll.lib.7z
|
Custom package: GL can be used directly, but also contains GLTools.lib |
2) The resulting files are configured separately after decompression:
Handling Glew:
The Include folder is the header file, and the GL folder located under the Include folder is copied to the Visual Studio 2013 installation directory \vc\include;
The files under the Lib folder are copied to the "Visual Studio 2013 installation directory \vc\lib";
Files under the Bin folder are copied to C:\Windows\SysWOW64; (32-bit system in System32)
Handling Freeglut:
Does not provide a compiled package, you need to use CMake self-compiling: (Surf the Internet to download a copy of the CMake software, CMake is used to control software using a simple platform and compiler compiler process standalone configuration file. )
1. Open CMake, configure the path of the input file "Freeglut" and the path of the compiled output file:
2. Click Configure to configure, pop up the following page, select the type of output file is visual Studio Win64 bit:
3. Click Finish, wait for CMake to process for a few seconds and then pop up the dialog box:
4. Note the two lines marked in blue:
The first line is the location of the generated Freeglut library file, which is the default in C (System disk), as far as possible to define an additional file output location, this location will output the files we need to use;
The second line is to generate the static LIB, tick this option when the install will have an error, because do not generate this static Lib also does not have much influence, this option is canceled here.
After configuring the CMake option, the project for generate generated visual studio2013 is as follows:
5. Open Freeglut.sln:
6. Right click on the INSTALL project, click on Build, will recompile the 13 projects, in VS build is the meaning of the compilation, at this time in our cmake_install_prefix configuration of the path output file is:
There are three folders under the 7.temp output folder include, Bin, lib, similar to Glew, to copy its contents to the appropriate location:
Warning: A fatal error occurred while configuring:
Error 1. What we need is freeglut.dll and freeglut.lib, and here is Freeglutd.dll and freeglutd.lib. The reason is that an error occurred while using the CMake tool. Later I re-downloaded the freeglut.lib and freeglut.dll files. (". dll" file is placed in the system directory, ". lib" file into the VS directory )
Error 2 . you can observe that the added folder is named Windows/system32 , in fact, Win32 bit of the choice to put the. dll extension file here, because my computer is 64 bits, so should be placed in windows/syswow64 folder.
The Freeglut configuration is complete.
Handling Gltools
For Gltools, the primary is to obtain the GLTools.lib file, and then Copy the GLTools.lib to Visual Studio 12.0\vc\lib.
We can get GLTools.lib by compiling the Gltools project, or we can get the gltools directly with someone else compiling the project:
1.: http://download.csdn.net/download/u010255642/6896993
2. How to compile:
See document: Http://www.cnblogs.com/wangguchangqing/p/4425745.html
See document: Http://www.ithao123.cn/content-967031.html
The result of the copy:
At this point, the OpenGL development environment configuration is complete.
(4) An OpenGL test project:
1) Create a new Visual C + + type of Win32 Console program in the VS2013 Project, empty project:
2) After creating the empty project, and choosing not to precompile the header, right-click on the Open property page on the OpenGL test project:
3). Add Gltools.lib,glew32s.lib,freeglutd.lib to additional dependencies on the input page of the linker, and add LIBCMT and MSVCRT to omit specific default libraries.
Remind:
Error 3: Because of the wrong front, it is also wrong here. This changes the freeglutd.lib to Freeglut.lib.
4) Select Right click on the source file and create a new C + + file named text1.c. (The. cpp file by default)
5) Copy the following test code into TEXT1.C:
1 //#include "stdafx.h" error Cause: vs2013/2012 contains "stdafx.h" by default, so you don't have to write it again. 2#include <GL/glut.h>3 voidInitvoid)4 {5Glclearcolor (0.0,0.0,0.0,0.0);//set the background color to black6Glshademodel (Gl_smooth);//set to smooth shading mode7 }8 voidMydisplay (void)9 {TenGlclear (Gl_color_buffer_bit);//clears the cache to a pre-set value, which is the black One //Gltranslatef (0.8, 0.0, 0.0);//the translation function can be used temporarily without AGlbegin (Gl_triangles);//Start Drawing triangles -GLCOLOR3F (1.0,0.0,0.0);//sets the first vertex to be a red -GLVERTEX2F (-1.0, -1.0);//set the coordinates of the first vertex theGLCOLOR3F (0.0,1.0,0.0);//set a second vertex to be green -GLVERTEX2F (0.0, -1.0);//set the coordinates of a second vertex -GLCOLOR3F (0.0,0.0,1.0);//set the third vertex to blue -GLVERTEX2F (-0.5,1.0);//set the coordinates of a third vertex +Glend ();//Triangle End -Glflush ();//forcing OpenGL functions to run for a limited time + } A voidMyreshape (Glsizei W, Glsizei h) at { -Glviewport (0,0, W, h);//Set Viewport -Glmatrixmode (gl_projection);//indicates that the current matrix is gl_projection -Glloadidentity ();//displace the current matrix as a unit array - if(W <=h) -Gluortho2d (-1.0,1.5, -1.5,1.5* (Glfloat) H/(Glfloat) W);//defining a two-dimensional face projection matrix in Else -Gluortho2d (-1.0,1.5* (Glfloat) w/(Glfloat) H,-1.5,1.5); toGlmatrixmode (Gl_modelview);//indicates that the current matrix is Gl_modelview + } - intMainintargcChar**argv) the { * /*Initialize*/ $Glutinit (&argc, argv);Panax NotoginsengGlutinitdisplaymode (Glut_single | GLUT_RGB);//single-buffered, RGB-mode -Glutinitwindowsize ( -, -); theGlutinitwindowposition ( $, $); +Glutcreatewindow ("Triangles");//Window Title A init (); the /*Drawing and displaying*/ +Glutreshapefunc (Myreshape);//behavior to take when the window size has changed -Glutdisplayfunc (Mydisplay);//Show Drawing drawing $Glutmainloop ();//Loops $ return(0); -}
Click the local Windows debugger to run the result as:
Plus this sentence will show the error shown:
Error reason: vs2013/2012 contains "stdafx.h" by default, so you don't have to write it again.
OpenGL learning Process (2) Building the OpenGL development environment