OpenGL is a definition of a cross-programming language , cross-platform programming interface specifications of the professional Graphics program Interface . It is used for three-bit image (two-dimensional also), is a powerful, easy to call the bottom-level graphics library. In the field of 3D game production, DirectX is a strong opponent. The following is a small instance of OpenGL in Ms Visual Stdio 2013 for getting started with OpenGL.
1, create the console project;
2, create C + + files;
3. Place the OpenGL folder under the project folder:
:
Contents in a Folder
4. Write the following code:
#include "Opengl/glut.h"
Hides the console window #pragma comment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "") void Display (void) {Glclear (gl_ Color_buffer_bit);//Clear Window screen//GLRECTF (0.5f, -0.5f, 0.5f, 0.5f);//Draw Rectangle glcolor3f (1.0, 1.0, 1.0);//Draw Line Glbegin (Gl_lines) ; Glvertex2i (Glvertex2i, 145); Glend ();//end drawing//Refresh Drawing Command Glflush ();} int main (int argc, char *argv[]) {//Initialize Glutglutinit (&ARGC, argv);//Set display mode Glutinitdisplaymode (Glut_rgb | Glut_single); Glutinitwindowposition (50, 50);//Set Window position glutinitwindowsize (400, 300);//Set Window size Glutcreatewindow ("Moon light in front of bed" ");//Create a window named" Moonlight Light In Bed "Glmatrixmode (gl_projection);//Set Projection parameters gluortho2d (0.0, 200.0, 0.0, 150.0); The orthogonal projection matrix//left and right are the minimum and maximum x values, and the top and bottom are the minimum and maximum Y values Glutdisplayfunc (&display);//Set the Display function Glutmainloop ();// Enter the display loop (without this sentence The program execution ends) return 0;}
5. Operation Result
PS: If you don't want each project to have this OpenGL folder, you can integrate OpenGL's five files into visual Stdio, which is related to the version corresponding to vs.
Example: Visual Stdio 2013 where each file is placed:
Glut.h:f:\visual studio\vc\include\gl\ (no GL folder can be created by itself)
Two static files: F:\Visual studio\vc\lib\
Two dynamic files: C:\Windows\System32
(where F:\Visual studio is my vs installation path)
OpenGL basics in Visual Stdio 2013 try to use Openglo