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.
Add source file *.cpp
Add Glew and freeglut two library paths
Edit Additional dependencies added: Opengl32.lib;freeglut.lib;glew32.lib; can copy from Lib.txt
- # include "Dependencies\freeglut\freeglut.h"
- voidvoid)
- {
- //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]
- /* 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*/
- Glmatrixmode (Gl_program);
- void void )
- 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.
- glcolor3f (1.0f, 0.0f, 0.0f); //Set segment color to red
- /* Defines a two-dimensional straight line segment from the integer Cartesian endpoint coordinates (180,15) to (10, 145) */
- Glbegin (Gl_lines);
- Glvertex2i (180, 15);
- Glvertex2i (10, 145);
- Glend ();
- //Execute all OpenGL programs
- int main ( int argc, Char *argv[])
- // initialize gult
- Setting the display mode
- set the upper left corner window display position
- // set window display width and height
- an Example OpenGL program! "); / / Create a window
- executing the initialization program
- display the graphic in the window
- Show all and go to the waiting state
-
0 VS2015 WIN7 Configuration OpenGL