Failed to Initialize GLEW. Missing GL version

前端 未结 5 1680
-上瘾入骨i
-上瘾入骨i 2020-12-16 11:27

I\'ve tried to set up SFML 2.0 with the latest version of the qt creator, I\'ve set up SFML right and I imported a small game I wrote in visual studio. Upon compilation, I g

相关标签:
5条回答
  • 2020-12-16 11:44

    putting the glewInit(); after the sf::window creation that solves my problem for using glew with sfml

    0 讨论(0)
  • 2020-12-16 11:50

    It's because you are not initializing OpenGL. Example with the lib glut.

    Wrong:

     glewInit();  // ERROR MISSING GL VERSION
     glutInitDisplayMode(GLUT_RGB); 
    

    Good:

     glutInitDisplayMode(GLUT_RGB);
     glewInit();
    

    EDIT I think for SFML:

     sf::Window   App(sf::VideoMode(400, 400, 32), "Window");
     glewInit();
    

    EDIT 2 Test this code.

    #include <SFML/Window.hpp>
    #include <iostream>
    #include <GL/glew.h>
    
    int
    main(int, const char**)
    {
        GLenum      err;
    
        std::cout << "Start" << std::endl;
        std::cout << "Test 1" << std::endl;
        if ((err = glewInit()) != GLEW_OK)
            std::cout << glewGetErrorString(err) << std::endl;
    
        std::cout << "Init window" << std::endl;
        sf::Window  app(sf::VideoMode(400, 400, 32), "Windows");
    
        std::cout << "Test 2" << std::endl;
        if ((err = glewInit()) != GLEW_OK)
            std::cout << glewGetErrorString(err) << std::endl;
        std::cout << "End" << std::endl;
        return 0;
    }
    

    My output:

    Start
    Test 1
    Missing GL version
    Init window
    Test 2
    End
    

    Compile with: g++ -W -Wall -Werror main.cpp -lsfml-window -lGLEW

    Good Luck ;)

    0 讨论(0)
  • 2020-12-16 12:01

    If you're using glew with glfw, use glfwMakeContextCurrent (https://github.com/Cloudef/glhck/issues/15)

    0 讨论(0)
  • 2020-12-16 12:03

    For those using SDL2's Renderer functions, it needs to be right after SDL_CreateRenderer.

    0 讨论(0)
  • 2020-12-16 12:07

    At the request of user3648895, I am posting my answer outside of the comments separately.

    For those using GLFW instead of SFML, you need to call glewInit() after glfwMakeContextCurrent

    0 讨论(0)
提交回复
热议问题