conworlds

diff src/main.cc @ 12:778ed91cb7fd

fullscreen to rift now works in extended mode with freeglut
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 23 Aug 2014 12:03:29 +0300
parents 5dc4e2b8f6f5
children 283cdfa7dda2
line diff
     1.1 --- a/src/main.cc	Sat Aug 23 00:24:20 2014 +0300
     1.2 +++ b/src/main.cc	Sat Aug 23 12:03:29 2014 +0300
     1.3 @@ -17,6 +17,8 @@
     1.4  static void sball_motion(int x, int y, int z);
     1.5  static void sball_rotate(int x, int y, int z);
     1.6  
     1.7 +static bool fullscreen_pending;
     1.8 +
     1.9  int main(int argc, char **argv)
    1.10  {
    1.11  	glutInitWindowSize(1024, 600);
    1.12 @@ -74,6 +76,10 @@
    1.13  
    1.14  static void idle()
    1.15  {
    1.16 +	if(fullscreen_pending) {
    1.17 +		glutFullScreen();
    1.18 +	}
    1.19 +
    1.20  	glutPostRedisplay();
    1.21  }
    1.22  
    1.23 @@ -85,6 +91,7 @@
    1.24  static void keyb(unsigned char key, int x, int y)
    1.25  {
    1.26  	static bool fullscr;
    1.27 +	static int prev_xpos, prev_ypos;
    1.28  	static int prev_xsz, prev_ysz;
    1.29  
    1.30  	switch(key) {
    1.31 @@ -93,6 +100,8 @@
    1.32  		if(fullscr) {
    1.33  			int xoffs, yoffs;
    1.34  
    1.35 +			prev_xpos = glutGet(GLUT_WINDOW_X);
    1.36 +			prev_ypos = glutGet(GLUT_WINDOW_Y);
    1.37  			prev_xsz = glutGet(GLUT_WINDOW_WIDTH);
    1.38  			prev_ysz = glutGet(GLUT_WINDOW_HEIGHT);
    1.39  
    1.40 @@ -100,10 +109,12 @@
    1.41  			yoffs = vr_get_opti(VR_OPT_WIN_YOFFS);
    1.42  			if(xoffs || yoffs) {
    1.43  				printf("repositioning: %d,%d\n", xoffs, yoffs);
    1.44 -				glutPositionWindow(xoffs + 1, yoffs + 1);
    1.45 +				glutPositionWindow(xoffs, yoffs);
    1.46 +				fullscreen_pending = true;
    1.47  			}
    1.48 -			glutFullScreen();
    1.49  		} else {
    1.50 +			fullscreen_pending = false;
    1.51 +			glutPositionWindow(prev_xpos, prev_ypos);
    1.52  			glutReshapeWindow(prev_xsz, prev_ysz);
    1.53  		}
    1.54  		break;