0 VS2015 WIN7 Configuration OpenGL

Source: Internet
Author: User

Original link

OpenGL environment Configuration Freeglut and Glew

Freeglut: A third-party library that can be used to display windows, manage user input, and perform some other action.

Glew: A cross-platform third-party library simplifies the process of acquiring function addresses and includes some other OpenGL programming methods that can be used across platforms.

This article uses a library file that adds Freeglut and Glew to a directory that we have built under our project, and then configures the project in vs.

  • (1). Prepare resources:

    OpenGL configuration. rar

  • (2). Create a new VS project with the following steps:





Add source file *.cpp


    • (3). Unzip "OpenGL config. rar" and put the Dependencies folder into the project directory

    • (4). Add a third-party library file for the project, click on the project to select Properties by right-clicking:

Add Glew and freeglut two library paths
Edit Additional dependencies added: Opengl32.lib;freeglut.lib;glew32.lib; can copy from Lib.txt
    • (5). Source.cpp Enter the following code (PG61) :


    1. # include  "Dependencies\freeglut\freeglut.h"
    2. voidvoid)
    3. {
    4. //Window Color (red: [0.0~1.0] R, Green: [0.0~1.0]g, Blue: [0.0~1.0]b, transparency: [0.0~1.0]a]
    5. /* Use a positive projection to map the contents of the two-bit rectangular area of the world coordinate system to the screen, with the x-coordinate values from 0.0 to 200.0,y coordinate values from 0.0 to 150.0*/
    6. Glmatrixmode (Gl_program);
    7. void void )
    8.     glclear (gl_color_buffer_bit); //gl_color_buffer_bit is an OpenGL symbolic constant used to specify the bit value in its color cache (flush cache) that will use                                      glclearcolor The values specified in the function are set.
    9. glcolor3f (1.0f, 0.0f, 0.0f); //Set segment color to red

    10. /* Defines a two-dimensional straight line segment from the integer Cartesian endpoint coordinates (180,15) to (10, 145) */
    11. Glbegin (Gl_lines);
    12. Glvertex2i (180, 15);
    13. Glvertex2i (10, 145);
    14. Glend ();

    15. //Execute all OpenGL programs
    16. int main ( int argc, Char *argv[])
    17. // initialize gult
    18. Setting the display mode
    19. set the upper left corner window display position
    20. // set window display width and height
    21. an Example OpenGL program! "); / / Create a window
    22. executing the initialization program
    23. display the graphic in the window
    24. Show all and go to the waiting state
      • (6) Select "X64" to perform CTRL+F7 compilation (the computer is a 64-bit system):


      • (7). Copy the Freeglut.dll file to the/x64/debug directory to execute the CTRL+F5 run program


0 VS2015 WIN7 Configuration OpenGL

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.