Fullscreen issue in linux

pradstherealone wrote on Saturday, December 14, 2013:

I am porting one of my game from Windows to Linux using GLFW3 for window creation. The code runs perfectly well when I run it in Windows (using GLFW3 and opengl) but when I compile and run it in ubuntu 12.10, there is an issue in fullscreen mode (in windowed mode it runs well) where the right part (about 25%) of the frame gets stretched and goes off screen. Here’s how I am creating GLFW window:

window = glfwCreateWindow(1024, 768, "Chaos Shell", glfwGetPrimaryMonitor(), NULL);

And here’s my opengl initialisation code:

glViewport(0, 0, 1024, 768);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-512.0f, 512.0f, -384.0f, 384.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Above code should load up the game in fullscreen mode with 1024 by 768 resolution. When I run it, glfwCreateWindow changes the screen resolution from my current screen resolution (1366 by 768) to 1024 by 768, but the right part of the frame goes off screen. If I manually change the resolution to 1024 by 768 and then run the game, everything looks alright. Also, running this same code in windows doesn’t show any issue no matter what my current screen resolution is. It just changes the resolution to 1024 by 768 and then everything looks perfect. If someone can find why it is acting weird in ubuntu then I will really appreciate…

dougbinks wrote on Sunday, December 15, 2013:

It’s been a while since I’ve had to sort out X issues in Linux, so someone else may have a better idea of what’s going on here. However to me it sounds like your X configuration has a mode for 1024x768 which is incorrectly set and is being picked up by glx as the default mode for that resolution. You may find that choosing a different refresh rate using the GLFW_REFRESH_RATE hint helps, passing in the refresh rate you found for the mode which worked.