为 GLUT 创建自定义窗口?
是否有一种方法可以为 GLUT 创建/指定自定义窗口,而不是使用 glutCreateWindow 方法?我想修改窗口的某些元素,例如删除边框、可能圆角等。
似乎没有任何内置函数来设置某个 HWND
句柄作为目标 GLUT 窗口(在 Windows 上)。
有什么想法吗?
詹格勒
Is there a method to create/specify a custom window for GLUT instead of using the glutCreateWindow method? I'd like to modify certain elements of the window, such as removing the border, possibly rounding the corners, etc.
There doesn't seem to be any built-in functions to set a certain HWND
handle as the targetted GLUT window (on Windows).
Any ideas?
Jengerer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Glut 以及 Glut 所基于的 OpenGL 旨在跨平台。每个平台对于窗口的制作都有自己的想法。为了解决这个问题,OpenGL 有自己的窗口概念或渲染上下文。渲染上下文是渲染 DIB(设备独立位图)的内存块,通常不包括窗口装饰(边框、X、窗口图标等)。除非有我不知道的特定于平台的扩展,否则无法传递 Glut 特定于 Windows 的 HWND。
您可以在其他地方创建渲染上下文,例如在您自己的代码或另一个库中。创建后,可能有一种方法可以将此上下文或指向该上下文的指针传递给 Glut。它支持 OpenGL,并且在它之上构建的许多库也是如此。
我不确定你为什么要改变窗口装饰,如果情况允许,使用本地支持此功能的库可能比将 Glut 绑定到解决方案中更容易。我知道 SDL、Ogre3d 控制窗口装饰的能力有限(不过我认为它们都不能圆角),如果你真的想使用 Glut,可以让这些库中的任何一个为你提供指针到他们使用的 OpenGL 渲染上下文。我没有使用过 QT,但我知道它可以更轻松地访问您想要的控件类型,并且能够为您创建 OpenGL 上下文。
但是,在查看了 Glut 的文档之后 http://www.opengl .org/documentation/specs/glut/spec3/spec3.html 它不使用“上下文”一词。这可能意味着,如果您使用 Glut,您将只能使用它提供的窗口装饰工具。这可能意味着您要么必须放弃过剩并使用功能更多的库,要么满足于操作系统提供的窗口装饰。
Glut, and OpenGL which Glut is built on, are intended to be crossplatform. Every platform has it's own ideas about what makes a window. To work around this OpenGL has it's own concept of windows, or rendering contexts. A rendering context is a chunk of memory where a DIB (Device Independent Bitmap) is rendered, which generally doesn't include window decorations (The borders, the X, the window icon, etc...). Unless there are platform specific extension which I am not aware of there is no way to pass Glut an HWND, which is specific to windows.
You may be able to create a rendering context somewhere else, such as in your own code or in another library. Once created there may be a way to pass this context or a pointer to the context into Glut. OpenGL this supports and so do many libraries built on top of it.
I am not sure why you want to alter window decorations, if the situation allows it might be easier to use a library that supports this natively rather than rigging Glut into a solution. I know SDL, Ogre3d have limited abilities to control the window decorations (I don't think either can round the corners though), and if you really want to work with Glut it is possible to get either of those libraries to give you a pointer to the OpenGL rendering context they use. I haven't used QT but I know it provides easier access to the kind of control you want and will be able to create an OpenGL context for you.
However, after looking at the documentation for Glut at http://www.opengl.org/documentation/specs/glut/spec3/spec3.html it does not use the word "context". This might mean that if you use Glut you are limited to the window decoration tools it provides. Which might mean that you either have to drop glut and use a library which does more, or settle for the window decorations the OS provides.