It doesn't seem to be ok, in fact it exibits behaviour as though I have to reload the opengl settings.
It's worth mentioning that I'm on a windows machine, actually, as I've read that that other media library, SDL, had this problem on windows. Of course, I switched to SFML, for more than just that problem.
Anyway, all my code is OO, and the project has gotten pretty big at this point, so I won't post all the code. These are the related parts:
Edit: WINDOW::<var name> is a global static class that stores any changes in resolution or state (like fullscreen), and allows all sub-classes read-only access to the window size, and a read-write for the fullscreen variable. I'm aware this is not very OOP-oriented.
1. The initiazliation happens like so:
// create the window
createWindow();
// set the framerate limit
currentWindow.SetFramerateLimit(tmpFRL); // tmpFRL is read from a file, or defaults to 0
// NOW
// init glew
GLenum error = glewInit();
if (error != GLEW_OK)
{
cout << "Error Initializing GLEW!\n";
cerr << "Error: " << glewGetString(error) << endl;
initOk = false;
}
// setup opengl
setupOpenGL();
2. Create window looks like this:
void Game::createWindow()
{
int targetWidth = (WINDOW::FULLSCREEN) ? (fullscreenWidth) : (WINDOW::WIDTH);
int targetHeight = (WINDOW::FULLSCREEN) ? (fullscreenHeight) : (WINDOW::HEIGHT);
currentWindow.Create(sf::VideoMode(targetWidth, targetHeight, 32),
"my title is here",
(WINDOW::FULLSCREEN) ? (sf::Style::Fullscreen) :
(sf::Style::Resize | sf::Style::Close | sf::Style::Titlebar),
currentWindowSettings);
fullscreen = WINDOW::FULLSCREEN;
WINDOW::HEIGHT = currentWindow.GetHeight();
WINDOW::WIDTH = currentWindow.GetWidth();
}
This load fine, even in fullscreen.
3. I try to change to fullscreen in the update(..) function, which is executed right before drawing begins. It looks like so:
void Game::update()
{
// World function update
pWorld->update(timer.GetElapsedTime() );
timer.Reset();
// the WINDOW::FULLSCREEN can be set by a number of other classes
if (fullscreen != WINDOW::FULLSCREEN)
{
// need to go fullscreen
if (WINDOW::FULLSCREEN)
{
currentWindow.Create(sf::VideoMode(fullscreenWidth, fullscreenHeight, 32),
"my title was here",
sf::Style::Fullscreen,
currentWindowSettings);
}
// else, need to go windowed
else
{
currentWindow.Create(sf::VideoMode(windowedWidth, windowedHeight, 32),
"my title was here",
sf::Style::Resize | sf::Style::Close | sf::Style::Titlebar,
currentWindowSettings);
}
// update the global height and width to be correct
WINDOW::HEIGHT = currentWindow.GetHeight();
WINDOW::WIDTH = currentWindow.GetWidth();
// update the local state to match the global state
fullscreen = WINDOW::FULLSCREEN;
}
}
As mentioned the above code, when executed to go or leave fullscreen, messes up my graphics setup. More precisely, it seems to disable all lighting, and lower my farplane to something under 5.0. I haven't tested it with texture loading yet, but I doubt it will be good.