开发者

Changing size of glui window

开发者 https://www.devze.com 2023-01-29 16:04 出处:网络
Can anyone tell me if there is any function for changing size of glui window? Also do anyone have 开发者_如何学Goany idea about how to add scroll bars to glut window?

Can anyone tell me if there is any function for changing size of glui window? Also do anyone have 开发者_如何学Goany idea about how to add scroll bars to glut window? Thanx in advance.


did you try glutReshapeWindow?

void glutReshapeWindow(int width, int height);

glutReshapeWindow requests a change in the size of the current window. The width and height parameters are size extents in pixels. The width and height must be positive values.


You didn't specify the version you are using, but v2.2 comes with some examples. If you check example5.cpp and example3.cpp, you'll notice that a GLUI window is created on top of a GLUT window (see the code below):

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

So it seems you have 2 options: the first, execute the callback myGlutReshape() directly to see if it resizes the window (specified below):

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();
}

or (the second), which is calling glutReshapeWindow() to change the window dimensions (probably followed by glutPostRedisplay()) .

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

Notice that glutReshapeWindow() is also executed by the callback, so this cold be the answer after all.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号