glfwWindowShouldClose(window); generate exeption, why?

Viewed 63

Im starting with OpenGL and C++ but the first test code give me an error that I do not understend why or how to fix it. Im with some trobles to finally intall the libraries glfw3.h and glad.h, everithing works normal until I tap "glfwWindowShouldClose(window);" enter image description here

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

int main() {

    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    GLFWwindow* window = glfwCreateWindow(640, 480, "teste", NULL, NULL);
    glfwMakeContextCurrent(window);

    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();

    }


    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

Im trying this tutorial, if someone ask: https://www.youtube.com/watch?v=45MIykWJ-C4&t=260s&ab_channel=freeCodeCamp.org

1 Answers

You appear to have a typo and be setting the major version twice and not setting the minor version so creating the window is likely failing.

Related