That Intel driver is pretty much 1 year old and as such not the latest driver, but it may be the latest driver for your HP device. Unfortunately HP (and other vendors) often restrict their users in some weird ways to get the latest updates and then they don't update their special driver versions.
From my point of view this is not really an SFML issue and you might find better help on some general Windows/HP support forum.
I've
quickly googled a bit and you're certainly not the only one experiencing issues with the switching. I've seen posts where people mentioned that reinstalling the Nvidia driver helped. Or that some said using the "official" HP drivers instead of the latest Nvidia driver fixed the switching issue.
I ran the following test example on my notebook with 2 GPUs and it either ran on the Intel GPU or the Nvidia GPU depending which one I told it to run on.
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "Multi GPU", sf::Style::Fullscreen);
window.setFramerateLimit(60);
// load font
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
{
std::cerr << "Failed to load font!" << std::endl;
return 1;
}
sf::Text text("0", font);
sf::Clock clock;
while (window.isOpen())
{
auto dt = clock.restart();
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
else if (event.type == sf::Event::KeyReleased)
{
if (event.key.code == sf::Keyboard::Escape)
{
window.close();
}
else if (event.key.code == sf::Keyboard::Return)
{
window.create(sf::VideoMode::getDesktopMode(), "Multi GPU", sf::Style::Fullscreen);
}
else if (event.key.code == sf::Keyboard::Space)
{
window.create(sf::VideoMode::getDesktopMode(), "Multi GPU", sf::Style::Default);
}
}
}
text.setString(std::to_string(1.f / dt.asSeconds()));
window.clear();
window.draw(text);
window.display();
}
}