view3d

changeset 9:d2e283764fca

fixed fullscreen separate idle func so it works on windows too
author nuclear@neutrino-win7.lan
date Sat, 28 Jan 2012 02:56:27 +0200
parents 5562a637e5aa
children 1a3799ff443a
files src/main.c
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/src/main.c	Mon Jan 23 08:51:59 2012 +0200
     1.2 +++ b/src/main.c	Sat Jan 28 02:56:27 2012 +0200
     1.3 @@ -16,6 +16,7 @@
     1.4  void proj_matrix(float eye);
     1.5  void view_matrix(float eye);
     1.6  
     1.7 +void idle(void);
     1.8  void reshape(int x, int y);
     1.9  void keyb(unsigned char key, int x, int y);
    1.10  void keyb_up(unsigned char key, int x, int y);
    1.11 @@ -63,7 +64,7 @@
    1.12  	glutSpaceballRotateFunc(sball_rotate);
    1.13  	glutSpaceballButtonFunc(sball_button);
    1.14  	if(auto_rot) {
    1.15 -		glutIdleFunc(glutPostRedisplay);
    1.16 +		glutIdleFunc(idle);
    1.17  	}
    1.18  
    1.19  	glewInit();
    1.20 @@ -172,6 +173,11 @@
    1.21  	glRotatef(cam_theta, 0, 1, 0);
    1.22  }
    1.23  
    1.24 +void idle(void)
    1.25 +{
    1.26 +	glutPostRedisplay();
    1.27 +}
    1.28 +
    1.29  void reshape(int x, int y)
    1.30  {
    1.31  	glViewport(0, 0, x, y);
    1.32 @@ -235,7 +241,7 @@
    1.33  	case ' ':
    1.34  		auto_rot = !auto_rot;
    1.35  		if(auto_rot) {
    1.36 -			glutIdleFunc(glutPostRedisplay);
    1.37 +			glutIdleFunc(idle);
    1.38  		} else {
    1.39  			glutIdleFunc(0);
    1.40  		}
    1.41 @@ -245,10 +251,16 @@
    1.42  	case 'f':
    1.43  		{
    1.44  			static int fullscr;
    1.45 +			static int orig_xsz, orig_ysz;
    1.46  			if(++fullscr & 1) {
    1.47 +				int vp[4];
    1.48 +				glGetIntegerv(GL_VIEWPORT, vp);
    1.49 +				orig_xsz = vp[2];
    1.50 +				orig_ysz = vp[3];
    1.51  				glutFullScreen();
    1.52  			} else {
    1.53 -				glutPositionWindow(20, 20);
    1.54 +				glutReshapeWindow(orig_xsz, orig_ysz);
    1.55 +				glutPositionWindow(20, 40);
    1.56  			}
    1.57  		}
    1.58  		break;