1

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

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • [What is a debugger and how can it help me diagnose problems?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problem) – Jesper Juhl Sep 04 '22 at 01:23
  • 1
    Please post the error message as text (and provide an English translation for it). And you set the major version twice, but never the minor version. You also skipped the error checking of window as done by the tutorial – BDL Sep 04 '22 at 09:08
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 04 '22 at 12:12

1 Answers1

1

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.

jcoder
  • 29,554
  • 19
  • 87
  • 130