Advertisement

Linker errors when setting up VS 2017 for OpenGL

Started by October 06, 2017 08:40 AM
1 comment, last by NubDevice 7 years, 4 months ago

Hello all,

I set up Visual Studio 2017 for OpenGL and ran this and this codes successfully.

I get these linker errors when compiling the following code:


#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)
{
    static const 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 }
    };
    glCreateBuffers(NumBuffers, Buffers);
    glNamedBufferStorage(Buffers[ArrayBuffer], sizeof(vertices),
        vertices, 0);
    ShaderInfo shaders[] = {
        { GL_VERTEX_SHADER, "triangles.vert" },
        { GL_FRAGMENT_SHADER, "triangles.frag" },
        { GL_NONE, NULL }
    };
    GLuint program = LoadShaders(shaders);
    glUseProgram(program);
    glGenVertexArrays(NumVAOs, VAOs);
    glBindVertexArray(VAOs[Triangles]);
    glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
    glVertexAttribPointer(vPosition, 2, GL_FLOAT,
        GL_FALSE, 0, BUFFER_OFFSET(0));
    glEnableVertexAttribArray(vPosition);
}
//--------------------------------------------------------------------
//
// display
//
void
display(void)
{
    static const float black[] = { 0.0f, 0.0f, 0.0f, 0.0f };
    glClearBufferfv(GL_COLOR, 0, black);
    glBindVertexArray(VAOs[Triangles]);
    glDrawArrays(GL_TRIANGLES, 0, NumVertices);
}
//--------------------------------------------------------------------
//
// main
//
int
main(int argc, char** argv)
{
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(640, 480, "Triangles", NULL,
        NULL);
    glfwMakeContextCurrent(window);
    gl3wInit();
    init();

    while (!glfwWindowShouldClose(window))
    {
        display();
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwDestroyWindow(window);
    glfwTerminate();
}

 

Is there any way to solve this issue?

 

 

 

 

looks to me like you are trying to use GL3W now after trying out GLAD and didn't swap out the c files. 

 

edit: Just now, I've upgraded opengl function pointer loading from GLEW to GL3W in my personal framework. Took a touch of google to help with the transition, but the experience was satisfying. Worth the effort? pfffttt...but its done.

Dev careful. Pixel on board.

This topic is closed to new replies.

Advertisement