Conditionally include GLES2 where needed

You have to use an OpenGL loader like glew or glad. OpenGL (ES) is a specification. The loader gives you access to the API functions which are provided by the graphics driver.

See OpenGL Loading Library – glad:

const SDL_GLContext context = SDL_GL_CreateContext(window);
if (context == nullptr) {
    std::cout << "SDL could not create context";
    return 1;
}

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
    std::cout << "Failed to initialize OpenGL context" << std::endl;
    return -1;
}

See Initialize GLEW:

const SDL_GLContext context = SDL_GL_CreateContext(window);
if (context == nullptr) {
    std::cout << "SDL could not create context";
    return 1;
}

if {glewInit() != GLEW_OK}
{
    std::cout << "Failed to initialize GLEW" << std::endl;
    return -1;
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top