view3d

changeset 11:1a3799ff443a tip

merged fullscreen and minor edit
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 04 Sep 2012 05:11:13 +0300
parents d0896caa3e5b d2e283764fca
children
files
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/src/main.c	Tue Sep 04 05:10:47 2012 +0300
     1.2 +++ b/src/main.c	Tue Sep 04 05:11:13 2012 +0300
     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;