2010-12-10 95 views
2

任何人都可以告诉我,如果有改变glui窗口大小的功能吗?也有人有任何想法如何添加滚动条到过剩窗口? Thanx提前。更改glui窗口的大小

回答

4

你试过glutReshapeWindow吗?

void glutReshapeWindow(int width, int height); 

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

+0

我在问GLUI窗口。 GLUT和GLUI窗口是不同的 – Shweta 2011-02-22 04:52:46

2

您没有指定您使用的版本,但v2.2附带了一些示例。如果检查example5.cppexample3.cpp,你会发现,是在供过于求窗口顶部创建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 

因此,看来你有2种选择:第一,执行回调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()也是由回调执行的,所以这个寒冷毕竟是答案。