SFML community forums

Help => General => Topic started by: Tchai on March 18, 2024, 03:33:31 pm

Title: ”Failed to activate OpenGL context“ After using VS Installer Project
Post by: Tchai on March 18, 2024, 03:33:31 pm
I'm using Win11 VisualStudio 2022 sfml2.6.1
My project includes <SFML>&&<SFML-Imgui>&&<openCV>, everything works fine when running in the visual studio.But sth went wrong after I tried to run the exe file Created by Visual Studio  Installer Project.
It says:
Failed to activate OpenGL context:
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 1.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Created: version = 0.0 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Failed to activate OpenGL context:
Failed to activate the window's context
Failed to activate OpenGL context:
Failed to activate the window's context
Failed to activate OpenGL context:
Failed to activate the window's context
Failed to activate OpenGL context:
Failed to activate the window's context
Failed to activate OpenGL context:
Failed to activate the window's context
.......
The window do come up and the Window's Events are Processed,but there is nothing Shown on the Screen.
I have built other project that includes SFML with Installer Project ,no problem occured .

int main() {
        sf::ContextSettings settings;
        settings.antialiasingLevel = 8;
        sf::RenderWindow window(sf::VideoMode(1240, 800), "Map Maker", sf::Style::Default,settings);
        font.loadFromFile("STXIHEI.TTF");
        sf::Clock deltaClock;
        ImGui::CreateContext();
        ImGui::SFML::Init(window);
        ImGui::StyleColorsLight();
        ImGuiIO& io = ImGui::GetIO(); (void)io;
        io.Fonts->Clear();
        ImFont* Font = io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\msyh.ttc", 25.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
        ImGui::SFML::UpdateFontTexture();
        while (window.isOpen()) {
                window.clear(sf::Color::White);
                ImGui::SFML::Update(window, deltaClock.restart());
                sf::Event event;
                while (window.pollEvent(event)) {
                        ImGui::SFML::ProcessEvent(event);
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                ImGui::SFML::Render(window);
                window.display();
        }
        ImGui::SFML::Shutdown();
        return 0;
}


Title: Re: ”Failed to activate OpenGL context“ After using VS Installer Project
Post by: eXpl0it3r on March 18, 2024, 03:59:32 pm
Not sure what "SFML with Installer Project" is, but it sounds like you end up using different DLLs, which can cause odd problems.

Make sure the necessary DLLs are next to your executable that you try to run.
Title: Re: ”Failed to activate OpenGL context“ After using VS Installer Project
Post by: Tchai on March 19, 2024, 08:02:47 am
Thank you for your reply! The problem is fixed ;)
I followed your instruction and found that I have an extra dll next to my exe ,after I deleted it ,the problem is fixed.
its OPENGL32.dll
Im not quite sure Why it appears in my project,or I put it here