Tag Archives: OpenGL

glCreateProgram error

Troubleshut< opengl>:

Problem Description:

Today, I encountered an OpenGL error. I doubted my life. The error report is as follows:
glcreateprogram() is a function in glew. I thought that the library connection was wrong. Then I connected all kinds of glew32.lib to the computer for a long time. By chance, I found that glew had no init and fainted…

Solution:

Execute before calling:
/* initialize glew. */
glewexperimental = GL_ TRUE;
GLenum err = glewInit();
if (err != GLEW_ OK)
{
std::cout << “Error initializing GLEW: ” << glewGetErrorString(err)
<< std::endl;
std::exit(EXIT_ FAILURE);
}

OpenGL programming error analysis


C :\ Program Files (x86)\ Microsoft Visual Studio 11.0\ VC \ Include \ GL \glew.h 84 1 consoleApplication8
Solution:
#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
#error gl.h included before glew.h

#include <GL/glew.h>
#include <GL/glut.h>

Glew.h is written in front of GLUT.

error
1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is found in the function “void __cdecl init(void)” (?
1> init @@yaxxz)
1>; ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is found in the function “void __cdecl init(void)” (?
1> init @@yaxxz)
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewBindBuffer
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____ glewbufferData
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewGenBuffers
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewAttachShader
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____ glewcompileShader
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewCreateProgram
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewCreateShader
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewDeleteShader
1>; ConsoleApplication8. Obj: error LNK2001: cannot resolve the external symbol of __imp____glewEnableVertexAttribArray
1 & gt; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewGetProgramInfoLog
; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewGetProgramiv
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____ glewgetShaderInfolog
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewGetShaderiv
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewLinkProgram
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewShaderSource
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____glewUseProgram
1>; ConsoleApplication8.obj: error LNK2001: Unable to parse external symbol __imp____ glewvertexattribute
; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____ glewbindVertexArray
1>; ConsoleApplication8.obj: error LNK2001: Unable to resolve external symbol __imp____ glewGenvertexArrays
Solution:

#pragma comment(lib,"glew32.lib")

Error:

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is displayed in the function “void __cdecl display(void)” (?Display @@yaxxz)

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is referenced in function _main

Solution:

#pragma comment(lib,"glut32.lib")

error:

1> ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is displayed in the function “void __cdecl display(void)” (?Display @@yaxxz) is referenced in
1> init @@yaxxz)
1>; ConsoleApplication8.obj: error LNK2019: Cannot resolve external symbol [email protected], which is displayed in the function “void __cdecl display(void)” (?Display @@yaxxz) is referenced in
1>; ConsoleApplication8.obj: error LNK2019: Unable to resolve external symbol [email protected], which is used in the function “void __cdecl initShader(char const *,char const *)” ([email protected]@[email protected]) is referenced
Solution:

#pragma comment(lib,"OpenGL32.lib")

After the vs2013 + OpenGL environment is set up, there is an error in running the first program

The computer reinstalled the secondary system, so I reconfigured the OpenGL environment. After the configuration is completed, I wrote an OpenGL program and found the following error message:

Solutions:
1. Add #define GLUT_DISABLE_ATEXIT_HACK before #include
2. Compile with Visual Studio 2012(V110) environment

Configuring OpenGL in Chinese version of VS2010 and problem solving

Under normal circumstances, the need to install first GLUT. Download address: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\ GL “
2. Let the glut of decompression. Lib and glut32. Lib in “” Programfiles (x86) 10.0 VC \ \ lib \ Microsoft Visual studio” (ditto)
3.
4.
4.
5.
5.
5.
5.
5.
5.
5. Open VS2010, open any project or create a new one, and be careful to add.c to the file name when creating the CPP file (for example, opengl.c). Under the Solution ->; Right-click item ->; Property – & gt; Configure properties ->; Input – & gt; Add a dependency, where you add opengl32.lib; glu32.lib ; glut32 ;
 
Possible problems:
ERROR LNK1104: Could not open the file ‘opengl32.lib glu32.lib glut32.lib’
1. Note that these files are connected by semicolon, change to opengl32.lib; glu32.lib ; glut32 ;
2. The compiler did not find the path to these files, so you need to manually add: right-click project ->; Property – & gt; VC++ directory, in the include directory and library directory to add the path to store these files.
 
“Stdafx. h” : No such file or directory
1. Verify that the environment configuration is: Properties →C/C++→ Precompiled Header → “No Precompiled Header”.
#include < #include < stdafx.h> In general, except for MFC projects, precompiled headers are not used.
 
 

Glfw configuration

Download from GLFW
Download the 32-bit version

The file structure after decompression is as follows:

Copy the GLFW folder in include to VC/include in the VS installation directory

If you are using VS2013, copy the lib file from lib-vc2013 to VC/lib in the VS2013 installation directory
Then copy the DLL file from lib-vc2013 to system32 or system64

When writing a program, properties in the project ->; The linker – & gt; Input – & gt; Add glfw3.lib to the attached dependencies
#pragma comment(lib, “glfw3.lib”)

If it fails to start at runtime, then copy the DLL file in lib-vc2013 to the Debug/Release folder

Simple configuration of glfw + glad in vs2015 OpenGL development environment

A tutorial learning OpenGL reference is https://learnopengl-cn.github.io
this tutorial is based on GLFW (window) + glad (cross-platform), the following VS2015 a simple method of environment configuration:
1. New projects
Simply create an empty project and add a blank CPP file.
2. Add the Nupengl Core library
Add method: VS->; Tools – & gt; NUGET Package Manager -> Package management console
and then in the bottom of the Package management console input Install – Package nupengl. Enter the core instruction can
at this point, your this project has been configured glut GLFW glew
3. The configuration is glad
If you don’t need glad, you can skip this step, but glad is used in the tutorial above, so it should also be configured incidentally:

Open the Glad online service, set the Language to C/C++ and, from the API options, select OpenGL version 3.3 and above (we will use version 3.3 for this tutorial, but newer versions will work just fine). Generate
a
ader is selected. Generate
loader is selected. Generate
a
loader is selected. Ignore the Extensions for now (for now). When you have selected everything, click the Generate button to Generate the library files.

: Packages \nupengl. Core.0.1.0.1\build\native\include
: Packages \nupengl. Core.0.1.0.1\build\native\include

After these previous steps, the environment is actually configured
4. Test

#include <glad/glad.h>
#include <GLFW/glfw3.h>

#include <iostream>

void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);

// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

int main()
{
    // glfw: initialize and configure
    // ------------------------------
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

#ifdef __APPLE__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif

    // glfw window creation
    // --------------------
    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
    if (window == NULL)
    {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

    // glad: load all OpenGL function pointers
    // ---------------------------------------
    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
    {
        std::cout << "Failed to initialize GLAD" << std::endl;
        return -1;
    }    

    // render loop
    // -----------
    while (!glfwWindowShouldClose(window))
    {
        // input
        // -----
        processInput(window);

        // render
        // ------
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

        // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
        // -------------------------------------------------------------------------------
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    // glfw: terminate, clearing all previously allocated GLFW resources.
    // ------------------------------------------------------------------
    glfwTerminate();
    return 0;
}

// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
    if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
        glfwSetWindowShouldClose(window, true);
}

// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
    // make sure the viewport matches the new window dimensions; note that width and 
    // height will be significantly larger than specified on retina displays.
    glViewport(0, 0, width, height);
}

If the configuration is successful, a window like

Vs2015 configuring OpenGL (glfw, glew)

I was in charge of the model part, so I picked up the OpenGL I had learned before. By the way, I have been learning OpenGL in Xubuntu before
. Linux configuration programming environment is really quite convenient. Due to project reasons, have to Windows under the implementation of again. But the configuration environment feels more troublesome, so there is this article, just for the convenience of Xiaobai.

* VS2015
glfw
*>w
VS2015 Community Edition is free, easy to debug, the disadvantage is too big, but it is really the best IDE under Windows.
GLFW GLFW homepage can also use GLUT, just to feel a little bit new.
GLEW GLEW home page updated to version 2.0.


Set up project
Select the Win32 Console project and right-click on the solution ->;

ah select linker ->;
:
:>; Input is added in the additional dependencies OpenGL32. Lib, glfw32. Lib, glew32s. Lib

Here to say a bit, you can use glfw32dll. Lib, glew32. Lib. This requires the corresponding DLL to be placed in the project directory. However, if you select glew32.lib, many functions will not be linked, so it is recommended to choose glfw32s.lib.
Then look for a slightly more complicated program on the Internet

#include <iostream>

// GLEW
#define GLEW_STATIC
#include <GL/glew.h>

// GLFW
#include <GLFW/glfw3.h>


// Function prototypes
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);

// Window dimensions
const GLuint WIDTH = 800, HEIGHT = 600;

// Shaders
const GLchar* vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 position;\n"
"void main()\n"
"{\n"
"gl_Position = vec4(position.x, position.y, position.z, 1.0);\n"
"}\0";
const GLchar* fragmentShader1Source = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\n\0";
const GLchar* fragmentShader2Source = "#version 330 core\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
"color = vec4(1.0f, 1.0f, 0.0f, 1.0f); // The color yellow \n"
"}\n\0";

// The MAIN function, from here we start the application and run the game loop
int main()
{
    // Init GLFW
    glfwInit();
    // Set all the required options for GLFW
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    // Create a GLFWwindow object that we can use for GLFW's functions
    GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr);
    glfwMakeContextCurrent(window);

    // Set the required callback functions
    glfwSetKeyCallback(window, key_callback);

    // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
    glewExperimental = GL_TRUE;
    // Initialize GLEW to setup the OpenGL Function pointers
    glewInit();

    // Define the viewport dimensions
    int width, height;
    glfwGetFramebufferSize(window, &width, &height);
    glViewport(0, 0, width, height);


    // Build and compile the shader programs (we ignored compile log checks for readability (if you do encounter issues, add the compile-checks!))
    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    GLuint fragmentShaderOrange = glCreateShader(GL_FRAGMENT_SHADER); // The first fragment shader that outputs the color orange
    GLuint fragmentShaderYellow = glCreateShader(GL_FRAGMENT_SHADER); // The second fragment shader that outputs the color yellow
    GLuint shaderProgramOrange = glCreateProgram();
    GLuint shaderProgramYellow = glCreateProgram(); // The second shader program
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);
    glShaderSource(fragmentShaderOrange, 1, &fragmentShader1Source, NULL);
    glCompileShader(fragmentShaderOrange);
    glShaderSource(fragmentShaderYellow, 1, &fragmentShader2Source, NULL);
    glCompileShader(fragmentShaderYellow);
    // Link the first program object
    glAttachShader(shaderProgramOrange, vertexShader);
    glAttachShader(shaderProgramOrange, fragmentShaderOrange);
    glLinkProgram(shaderProgramOrange);
    // Then link the second program object using a different fragment shader (but same vertex shader) this time.
    // This is perfectly allowed since the inputs and outputs of both the vertex and fragment shaders are equally matched.
    glAttachShader(shaderProgramYellow, vertexShader);
    glAttachShader(shaderProgramYellow, fragmentShaderYellow);
    glLinkProgram(shaderProgramYellow);


    // Set up vertex data (and buffer(s)) and attribute pointers
    // We add a new set of vertices to form a second triangle (a total of 6 vertices); the vertex attribute configuration remains the same (still one 3-float position vector per vertex)
    GLfloat firstTriangle[] = {
        -0.9f, -0.5f, 0.0f,  // Left 
        -0.0f, -0.5f, 0.0f,  // Right
        -0.45f, 0.5f, 0.0f,  // Top 
    };
    GLfloat secondTriangle[] = {
        0.0f, -0.5f, 0.0f,  // Left
        0.9f, -0.5f, 0.0f,  // Right
        0.45f, 0.5f, 0.0f   // Top 
    };
    GLuint VBOs[2], VAOs[2];
    glGenVertexArrays(2, VAOs);
    glGenBuffers(2, VBOs);
    // ================================
    // First Triangle setup
    // ===============================
    glBindVertexArray(VAOs[0]);
    glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(firstTriangle), firstTriangle, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);   // Vertex attributes stay the same
    glEnableVertexAttribArray(0);
    glBindVertexArray(0);
    // ================================
    // Second Triangle setup
    // ===============================
    glBindVertexArray(VAOs[1]); // Note that we bind to a different VAO now
    glBindBuffer(GL_ARRAY_BUFFER, VBOs[1]); // And a different VBO
    glBufferData(GL_ARRAY_BUFFER, sizeof(secondTriangle), secondTriangle, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)0); // Because the vertex data is tightly packed we can also specify 0 as the vertex attribute's stride to let OpenGL figure it out.
    glEnableVertexAttribArray(0);
    glBindVertexArray(0);

    // Game loop
    while (!glfwWindowShouldClose(window))
    {
        // Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions
        glfwPollEvents();

        // Render
        // Clear the colorbuffer
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

        // Now when we want to draw the triangle we first use the vertex and orange fragment shader from the first program.
        glUseProgram(shaderProgramOrange);
        // Draw the first triangle using the data from our first VAO
        glBindVertexArray(VAOs[0]);
        glDrawArrays(GL_TRIANGLES, 0, 3);   // This call should output an orange triangle
                                            // Then we draw the second triangle using the data from the second VAO
                                            // When we draw the second triangle we want to use a different shader program so we switch to the shader program with our yellow fragment shader.
        glUseProgram(shaderProgramYellow);
        glBindVertexArray(VAOs[1]);
        glDrawArrays(GL_TRIANGLES, 0, 3);   // This call should output a yellow triangle
        glBindVertexArray(0);

        // Swap the screen buffers
        glfwSwapBuffers(window);
    }
    // Properly de-allocate all resources once they've outlived their purpose
    glDeleteVertexArrays(2, VAOs);
    glDeleteBuffers(2, VBOs);
    // Terminate GLFW, clearing any resources allocated by GLFW.
    glfwTerminate();
    return 0;
}

// Is called whenever a key is pressed/released via GLFW
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}

Configure OpenGL development environment (vs2015)

Configuring the OpenGL development environment (VS2015)
There are a lot of configuration VS + OpenGL tutorials online, for the configuration of the super treasure of the good and bad are mixed, mainly the official website did not give a good compiled library, many need to compile their own, so for beginners, it is difficult to configure successfully.
 
The following is a blog post that explains the configuration process and the rationale behind it
http://www.it165.net/pro/html/201504/38164.html
 
For beginners, everyone wants to be able to run the example given in the super bible. Here I directly give several twists and turns, all kinds of files generated after compilation, according to the following configuration can be run in VS2015 super treasure in the example, to achieve development.
 
I. Required allocation of resources

Resource download: http://download.csdn.net/download/ax_hacker/10107105
The zip package contains two folders, CJBD5_CODE and OpenGL. The former contains the sample program, and the latter is the three files required for configuration.
 
Include
Lib
Dll
 

How do I configure the development environment, as I explained in a previous blog post
http://blog.csdn.net/ax_hacker/article/details/78140003
The following is the configuration process for OpenGL.
 
1, Copy the files in the DLL folder to C:\Windows\ Syswow64 and C:\Windows\System32
 
2. Create an empty project, add a source file, and configure the project properties
 
1) Put the include from the previous folder under the include directory

 
2) lib in the library directory

 
3) Linker ->; Input – & gt; Additional dependencies freeglutd.lib; GLTools.lib; freeglut.lib; glew32s.lib

The simplest way to configure OpenGL development environment with vs2015

This method I think is the simplest!
Before I wrote this, I did a lot of research online on what to do with GLUT, GLEW, FreeGLUT, and what files to add to the site. Now I can tell you that VS2015 is so powerful that none of these operations are needed! VS has a tool called NuGet, which is a package manager for.NET. NuGet allows developers to create, share, and use libraries. We use OpenGL, which should be called libraries using OpenGL.
VS2015 steps to configure OpenGL. First, you need to have a project, and then add the OpenGL library to your project by clicking Project ->; Manage NuGet package, and then in a TAB, click on the “browse” input “NupenGL” into the search box, search will appear two libraries, we should both to our engineering to installation, after the success of the installation, you can find them in the installed base, in the right of the child window, you can learn about the installation of the library information.



It is not particularly easy to install GLUT, FreeGLUT, and GLEW libraries in just a few simple steps.
>
>
>
>
>
>
> I won’t post the source code.

You look at the picture below, is it time to put your heart at ease?

But again simple things, some people will still appear all kinds of problems. First of all, every time you create a new OpenGL project, you have to install a library. Some people hate this tedious, but I can’t help it. It won’t take you half a minute to install these two libraries, and you don’t have to do that on other computers. Also, turn off the 360, it’s so annoying!

On the configuration of OpenGL Red Book eighth edition environment in vs2013

I just started learning OpenGL, bought a copy of OpenGL Red Book 8,
The first example has been studied for a while and is finally ready to run. I wonder if there are any children’s shoes that have the same problem as me.
Here’s how I configured it:
First go to http://www.opengl-redbook.com/ and download the source code of the Little Red Book. Unzip it to get this

Then open VS2013 and create an empty Win32 console project.
Then right-click on the project properties and click on the VC ++ directory

Include directory – Edit and add the include folder in the Red Book source directory

Library directory – Edit and add the lib folder
in the Red Book source directory

Add and source files to the project, and paste the code from the first example of the Little Red Book

///
//
// triangles.cpp
//
///
#include <iostream>
using namespace std;
#include "vgl.h"
#include "LoadShaders.h"
enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };
GLuint VAOs[NumVAOs];
GLuint Buffers[NumBuffers];
const GLuint NumVertices = 6;
//---------------------------------------------------------------------
//
// init
//
void init(void)
{
	glGenVertexArrays(NumVAOs, VAOs);
	glBindVertexArray(VAOs[Triangles]);
	GLfloat vertices[NumVertices][2] = {
		{ -0.90, -0.90 }, // Triangle 1
		{ 0.85, -0.90 },
		{ -0.90, 0.85 },
		{ 0.90, -0.85 }, // Triangle 2
		{ 0.90, 0.90 },
		{ -0.85, 0.90 }
	};
	glGenBuffers(NumBuffers, Buffers);
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
		vertices, GL_STATIC_DRAW);
	ShaderInfo shaders[] = {
		{ GL_VERTEX_SHADER, "triangles.vert" },
		{ GL_FRAGMENT_SHADER, "triangles.frag" },
		{ GL_NONE, NULL }
	};
	GLuint program = LoadShaders(shaders);
	glUseProgram(program);
	glVertexAttribPointer(vPosition, 2, GL_FLOAT,
		GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(vPosition);
}
//---------------------------------------------------------------------
//
// display
//
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glBindVertexArray(VAOs[Triangles]);
	glDrawArrays(GL_TRIANGLES, 0, NumVertices);
	glFlush();
}

//---------------------------------------------------------------------
//
// main
//
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA);
	glutInitWindowSize(512, 512);
	glutInitContextVersion(4, 3);
	glutInitContextProfile(GLUT_CORE_PROFILE);
	glutCreateWindow(argv[0]);
	if (glewInit()) {
		cerr << "Unable to initialize GLEW ... exiting" << endl;
		exit(EXIT_FAILURE);
	}
	init();
	glutDisplayFunc(display);
	glutMainLoop();
}

compile once found not through, will quote cannot resolve external command error,

This is because loadShaders.cpp could not be found
In the Little Red Book source directory there is a lib folder with LoadShaders
Right-click on the project’s source file to add an existing item

The libcmtd.lib library is in conflict with other libraries, so we can ignore it
Right-click on the project — Properties — Linker — Enter and add it in Ignore the specific default library

Now in the compilation once found can pass out

But it’s a white triangle, not a blue triangle, and you need to create two new texts in the project directory
Renamed Triangles. Vert and Triangles. Frag

The code is as follows:

triangles.vert

#version 430 core
layout(location = 0) in vec4 vPosition;
void
main()
{
	gl_Position = vPosition;
}

triangles.frag

#version 430 core
out vec4 fColor;
void
main()
{
	fColor = vec4(0.0, 0.0, 1.0, 1.0);
}

>
>

OpenGL class library and environment configuration under win10 and vs2015

Quote:
The OpenGL Super Bibliography (Fifth Edition) and the OpenGL Programming Guide (Eighth Edition) are two practical OpenGL learning books. The difference is that the former has more examples and is easier to follow step by step, while the latter focuses on the API, so it’s best to read the former first.  
OpenGL class library configuration has been troubled by many beginners, I browse the configuration methods of various reference articles, found that in VS2015 configuration encountered many problems, after a few days of groping finally solved.
This article mainly refer to https://www.cnblogs.com/zpcdbky/p/6724772.html
http://blog.csdn.net/brillianteagle/article/details/51623208
http://www.it165.net/pro/html/201504/38164.html
Thanks to the contributions of the authors.
In this paper, all the resources have been packaged well, download address: http://download.csdn.net/download/shs1992shs/10142198
I. GLEW configuration
Glew’s official website: http://glew.sourceforge.net/
glew making official homepage: https://github.com/nigels-com/glew
glew is a cross-platform OpenGL extensions library, supporting multiple operating system, the url has to provide the latest version of glew.

1. Download Source and Binaries respectively, where the Binaries version is the compiled glew file and the Source is the Source.
2. Find the VS2015 installation directory, if it is installed in C disk, most is similar to C: Program Files(x86)\Microsoft Visual Studio 15.0 such path (the next is Microsoft Visual Studio 14.0), can also be in other disk directory; For the convenience of expression, the following will be explained according to the directory “D:\ Software Installation \VS2015”.
3. Locate the C++ header directory, such as “D:\ software installation \VS2015\VC\include”, and create a new GL folder under the include directory (if there is none).
4. Page 1 Binaries glew – 2.1.0/include/GL folder 4 header files are copied to 3 GL in the folder.
5. Copy glew32.dll from Binaries version to D:\ software installation \VS2015\VC\bin.
6. Copy the Binaries version of glew-2.1.0\lib\Release\Win32 to the directory D:\ software installation \VS2015\VC\lib.
Note that it is not necessary to copy the DLL file to C:\Windows\System32 or C:\Windows\SysWOW64.
At this point, glew is configured.

FreeGLUT configuration

1. GLEW obtains the latest version of OpenGL API. The FreeGLUT is used to replace the GLUT library. So, the glew and freeGLUT libraries are configured to completely replace the glu and GLUT libraries, and the latest version of the API is available for Shader programming.

f
The latest stable version of ReeGLUT is 3.0, which can be downloaded at:
http://freeglut.sourceforge.net/

Open the page and see the following section:

Download the Prepackaged version of MSVC and click the red button to get to the next page

Click on the red box to download the file named FreeGlut-MSVC-3.0.0-2.MP.zip

2.
“FreeGlut-MSVC-3.0.0-2.MP.zip” to extract the FreeGlut-MSVC-3.0.0-2.MP.zip folder.
There are four header files in the FreeGLUT /include/GL directory. Copy the three header files except GLUT. H to the D:\ software installation \VS2015\VC\include\GL directory.

Copy the FreeGlut. DLL file from FreeGlut. bin to D:\ software installation \VS2015\VC\bin.

4. Copy the FreeGlut. lib file to D:\ software installation \VS2015\VC\lib.

At this point, the FreeGLUT is configured.

Third, GLUT configuration

The GLUT library is old and hasn’t been updated since 2000, and many of them can be downloaded online or packaged with the resource bundles I uploaded.

Glut.h, Glut.dll, Glut32.dll, Glut.lib, Glut32.lib. Glut.h, Glut.dll, Glut32.dll, Glut.lib, Glut32.lib

2. Copy Glut. h to D:\ software installation \VS2015\VC\include\GL.

3. Copy ULT. DLL, GLUT32.DLL to D:\ software installation \VS2015\VC\bin.

4. Copy Glut. lib and Glut32. lib to D:\ VS2015\VC\lib.

At this point, GLUT is configured.

Note: When using the OpenGL Super Bibliotheca example, you need to add #pragma comment(lib,”gltools.lib”) to the beginning of the program. Used to connect to gltools.lib.

Four, GLTools configuration

The GLTools library is provided by the author of the OpenGL Super Bibliome. It is cumbersome to configure. I can use the files packaged in my resource pack, or I can compile them myself.

1. Copy all 11 header files from the gltools\include directory to the D:\ software installation \VS2015\VC\include directory (note the include directory, not the GL subdirectory).

2. Copy gltools.lib to D:\ software installation \VS2015\VC\lib.
> At this point, GLTools is configured.
> At this point, OpenGL is configured.

Self-compilation method:

Unzip the resource bundle and get the gltools folder. This folder has two folders, include and SRC, in its directory. Since GLTools compilations depend on glew, you can see that GLTools \include\GL is a version of the glew header, and GLTools \ SRC has the glew.c source.  

Since you have already used the latest version of glew-2.1.0, you need to replace all the header files in the gltools\include\GL directory and select
with
Glew-2.1.0 version glew.c source file replaces glew.c in gltools\ SRC. (The Source version of glew-2.1.0\ SRC \glew.c as mentioned earlier).

Note 1: GLTools in the resource pack is all packaged and does not need to be changed. Readers who need to update the resource pack should follow the above method.

Note 2: when using the OpenGL super treasure dian example, found that transformation pipeline header file GLGeometryTransform. H compile error, a large number of can’t find the identifier, so the revised, if readers encounter such problems, in the resource bundle of gltools within a folder GLGeometryTransform – fix GLGeometryTransform. H header file to replace to D: \ software \ VS2015 VC \ \ the include directory, can be normal use.

Generate gltools. Lib

1. Copy all 11 header files from the gltools\include directory to the D:\ software installation \VS2015\VC\include directory (note the include directory, not the GL subdirectory).

2.
Start VS2015 and create a Win32 application called GLTools.

3. Select “Static Library” and uncheck the “Precompiled Header” box.

4. Copy the six files in the gltools\ SRC directory to the project directory you just created (for example, E: gltools\gltools).
5. Right-click ‘Source File’ –>; “Add”, & gt; “Existing Items”, add 6 of the 4 files to the project.



C/C++ > C/C++ > C/C++ > Add _CRT_SECURE_NO_WARNINGS to the preprocessor definition to the right of the preprocessor,
Otherwise, the function will be warned that it is not safe to use and will not compile successfully.

7. To generate – & gt; Generate gltools
I have seen a compilation in Release mode and a compilation in Debug mode in different articles, so far I can’t see the specific difference, just to be safe, I can compile in both modes.

There were a bunch of “DLL link inconsistencies” warnings on the compile, but the compilation was successful.

8. The generated gltools.lib files can be found in the E: gltools\Debug directory and the E: gltools\Release directory respectively. To copy the gltools.lib file from the Release file, refer to the lib file placement format of FreeGLUT. You can copy the gltools.lib file from the Release file to the D:\ software installation \VS2015\VC\lib directory.

At this point, you are done.