X11 fullscreen?

cozman wrote on Tuesday, August 09, 2005:

I have an application which works fine in windowed mode but in fullscreen only takes up a portion fo the screen. I’ve traced the problem to when I set the viewport. I wrote a small demo displaying the behavior, it should draw a white line from the top left corner to the bottom right, but on my system (xorg 6.8.2, Radeon 9600 Pro with fglrx drivers) it does not take up the entire screen.

Sample Code:

#include <GL/glfw.h>
#include <GL/gl.h>

int main()
{
glfwInit();
glfwOpenWindow(800, 600, 8, 8, 8, 8, 0, 0, GLFW_FULLSCREEN);

glViewport\(0, 600, 800, 600\);
glMatrixMode\(GL\_PROJECTION\);
glLoadIdentity\(\);
glOrtho\(0, 800, 600, 0, -1.0, 1.0\);
glMatrixMode\(GL\_MODELVIEW\);
glLoadIdentity\(\);

do
\{
    glClear\(GL\_COLOR\_BUFFER\_BIT\);

    glBegin\(GL\_LINES\);
    glVertex2f\(0,0\);
    glVertex2f\(800,600\);
    glEnd\(\);

    glfwSwapBuffers\(\);
\} while\(glfwGetWindowParam\(GLFW\_OPENED\) &amp;&amp; glfwGetKey\(GLFW\_KEY\_ESC\) \!= GLFW\_PRESS\);


glfwCloseWindow\(\);
glfwTerminate\(\);

}

I’ve also been told that the code works fine in Windows (but have not had a chance to test it myself). Does this code work on other people’s systems or is there some sort of GLFW/X11 bug I’m encountering here?

yukiikyuta wrote on Friday, December 02, 2005:

Firstly, your glViewport command does seem to be a bit misunderstood; try “glViewport(0, 0, 800, 600);” instead. The first two arguments are `x’ and `y’, the offset of where you draw in the window from the bottom left.

In your case, you’ve set the viewport exactly outside of your drawing area. (it’s drawing above the screen!)

Secondly, it’s up to your X server whether or not it’ll obey the GLFW_FULLSCREEN flag, as it’s up to the X server whether or not it’ll let itself be resized; not a flaw in GLFW.