OpenGL basics in Visual Stdio 2013 try to use Openglo

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.