使用 FreeGLUT,如何创建 OpenGL 窗口,指定标题和屏幕位置?
FreeGLUT API 有几个窗口管理功能:
int glutCreateWindow(const char * title );
int glutCreateSubWindow(int window, int x, int y, int width, int height);
void glutDestroyWindow(int window);
void glutSetWindow(int window);
int glutGetWindow(void);
void glutSetWindowTitle(const char* title);
void glutSetIconTitle(const char* title);
void glutReshapeWindow(int width, int height);
void glutPositionWindow(int x, int y);
我完全不熟悉这。我将如何创建四个具有独特标题和位置的窗口?似乎一旦使用 glutCreateWindow() 创建了第二个窗口,就无法再次访问第一个窗口。
到目前为止,我可以使用 glutCreateWindow("window 1"); 创建一个窗口,然后使用 glutReshapeWindow(width, height) 和 glutPositionWindow 对其进行形状和重新定位(x, y),但我不知道如何同时管理多个窗口。
我正在 Windows XP 上运行 MinGW/MSYS,如果有帮助的话。
The FreeGLUT API has several functions for window management:
int glutCreateWindow(const char * title );
int glutCreateSubWindow(int window, int x, int y, int width, int height);
void glutDestroyWindow(int window);
void glutSetWindow(int window);
int glutGetWindow(void);
void glutSetWindowTitle(const char* title);
void glutSetIconTitle(const char* title);
void glutReshapeWindow(int width, int height);
void glutPositionWindow(int x, int y);
I'm completely new to this. How would I go about creating four windows, with unique titles and positions? It seems that once a second window has been created with glutCreateWindow()
, there is no way to access the first one again.
So far, I can create a single window with glutCreateWindow("window 1");
, then reshape and reposition it with glutReshapeWindow(width, height)
and glutPositionWindow(x, y)
, but I'm at a loss as to how to manage several windows simultaneously.
I'm running MinGW/MSYS on Windows XP, if that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次使用 glutCreateWindow 创建窗口时,它都会返回新窗口的窗口 ID。您可以将其存储在变量中,并稍后通过 glutSetWindow 使用它来访问窗口。
另请注意,您通常会在创建窗口后立即设置窗口的显示功能。
Each time you create a window with
glutCreateWindow
it returns the window ID of the new window. You can store this in a variable and use this to access the window later viaglutSetWindow
.Also note that you would normally set the display function for a window just after creating it.