Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Screen Resolution Change - White Textures  (Read 2285 times)

0 Members and 1 Guest are viewing this topic.

Sui

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://www.suisoft.co.uk/
Screen Resolution Change - White Textures
« on: September 20, 2012, 12:20:22 pm »
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.
Gary Marples, Developer of games and other stuff.
www.suisoft.co.uk/games/BlogTwitter

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11053
    • View Profile
    • development blog
    • Email
Re: Screen Resolution Change - White Textures
« Reply #1 on: September 20, 2012, 01:33:30 pm »
Afaik there's a problem with Virtual Box...

Otherwise make sure you follow the offical tutorial specially about OpenGL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sui

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://www.suisoft.co.uk/
Re: Screen Resolution Change - White Textures
« Reply #2 on: September 20, 2012, 01:46:36 pm »
Afaik there's a problem with Virtual Box...

Otherwise make sure you follow the offical tutorial specially about OpenGL.

Thanks for the quick reponse.

I read on another thread that there are some known problems with context loss when recreating the SFML window (in my case using it to change resolution):
http://en.sfml-dev.org/forums/index.php?topic=9022.msg60861#msg60861

I am concerned that this issue may crop up on some machines when the updated game is released live.

Has anyone encountered the white texture issue when changing resolution?

Thanks.
Gary Marples, Developer of games and other stuff.
www.suisoft.co.uk/games/BlogTwitter

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11053
    • View Profile
    • development blog
    • Email
Re: Screen Resolution Change - White Textures
« Reply #3 on: September 20, 2012, 02:16:27 pm »
Well I haven't used XP in over a year but iirc there was never such a problem, nor is it on Windows 7. You could try another VM than VB.

Btw please make use of the code=cpp tag. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything