画面をフルサイズと通常サイズに、さらに重要なことに、画面サイズを通常サイズに変更すると、フルサイズにする前の位置に戻る関数を作成しようとしています。どうすればよいですか。 。
これが私がしたことです
//global Variables
int scr_pos_x = 100, scr_pos_y = 150;
//somewhere else in main method
glutInitWindowPosition(scr_pos_x, scr_pos_y);
....
glutKeyboardFunc(myKeyboard);
//myKeyBoardFunction
void myKeyboard(unsigned char key, int x, int y){
if(key == 'f'){
int scr_pos_x = glutGet((GLenum)GLUT_WINDOW_X);
int scr_pos_y = glutGet((GLenum)GLUT_WINDOW_Y);
cout << " while f press "<<scr_pos_x <<" "<<scr_pos_y << endl; // to check
glutFullScreen();
}else if(key=='x'){
cout << " while x press "<<scr_pos_x <<" "<<scr_pos_y << endl; // to check
glutPositionWindow(scr_pos_x, scr_pos_y);
glutReshapeWindow(640, 480);
}
}
「f」を押すと、scr_pos_xとscr_pos_yが適切な値に設定されていることがわかりますが、「x」を押すと、これらの値はどういうわけか100と150に変わります。