I'm improving my game engine at the moment and have implemented an option to change the screen resolution in-game. I had originally hoped it would run at desktop resolution on all reasonably modern machines but I am receiving complaints of bad performance from some players.
The code I am using is:
sf::VideoMode newMode (width, height, 32U);
m_window->Create (newMode, m_title, sf::Style::Fullscreen);
glViewport(0, 0, m_window->GetWidth(), m_window->GetHeight());
CalculateGameViewWidth (); // aspect has probably changed
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, m_gameViewWidth, m_gameViewHeight, 0.0f); // top and bottom flipped to reverse vertical axis to match game engine (0=top)
// Synchronise SFML view system (for font usage)
m_window->GetDefaultView().SetFromRect(sf::FloatRect(0.0f, 0.0f, m_gameViewWidth, m_gameViewHeight));
m_window->UseVerticalSync(true);
m_window->SetFramerateLimit(61); // Limit to 60 frames per second (slightly more to prevent occasional stuttering on Mac)
This works nicely on my development machine but when testing on Oracle Virtual Box (Windows XP) all of the text and fonts turn white after changing resolution. Note that I am still using SFML v1.6 and the sprite rendering is my own OpenGL code, rather than SFML's. I am using SFML Graphics for text rendering.
I know from reading some other threads on the forum (and from Googling) that context loss is an issue on some hardware and causes the white texture issue. I also know that SFML 2.0 solves this to a large extent but won't help with my own OpenGL code.
If someone can point me in the right direction, the questions I have, are:
Can I detect the state that causes the white boxes somehow?
How does SFML 2 detect the issue and reload the textures?
I have been searching around for a solution to this myself, including looking on the SFML forums but I can't find the answer. Most of the Google results seem to relate to Android. The official OpenGL documentation I've been reading suggests that hardware/drivers manage textures and you don't get the texture loss problems like Direct-X, but clearly there are exceptions.
Any help much appreciated.
Thanks.