2

谁能告诉我是否有任何改变glu窗口大小的功能?还有人知道如何向过剩窗口添加滚动条吗?提前谢谢。

4

2 回答 2

3

你试过 glutReshapeWindow 吗?

void glutReshapeWindow(int width, int height);

glutReshapeWindow 请求改变当前窗口的大小。宽度和高度参数是以像素为单位的大小范围。宽度和高度必须为正值。

于 2011-02-21T14:49:19.690 回答
2

您没有指定您使用的版本,但 v2.2 附带了一些示例。如果您检查example5.cppexample3.cpp,您会注意到在 GLUT 窗口之上创建了一个 GLUI 窗口(请参见下面的代码):

int main_window = glutCreateWindow( "GLUI Example" ); // Creating GLUT window

// Setting up callbacks
glutDisplayFunc( myGlutDisplay );
GLUI_Master.set_glutReshapeFunc( myGlutReshape );  // Humm, this could be it!
GLUI_Master.set_glutKeyboardFunc( myGlutKeyboard );
GLUI_Master.set_glutSpecialFunc( NULL );
GLUI_Master.set_glutMouseFunc( myGlutMouse );

// Blah Blah to create objects and make it fancy

GLUI* glui = GLUI_Master.create_glui( "GLUI", 0, 400, 500 ); // Create GLUI window
glui->set_main_gfx_window( main_window );  // Associate it with GLUT

因此,您似乎有两个选择:第一个,直接执行回调myGlutReshape()以查看它是否调整了窗口大小(如下指定):

void myGlutReshape( int x, int y )
{
  int tx, ty, tw, th;
  GLUI_Master.get_viewport_area( &tx, &ty, &tw, &th );
  glViewport( tx, ty, tw, th );

  xy_aspect = (float)tw / (float)th;

  glutPostRedisplay();
}

或(第二个),它正在调用glutReshapeWindow()更改窗口尺寸(可能后跟glutPostRedisplay())。

glutReshapeWindow( 800, 600);
glutPostRedisplay(); // This call may or may not be necessary

请注意,这glutReshapeWindow()也是由回调执行的,所以这毕竟是答案。

于 2011-02-22T17:04:50.193 回答