如何为 wxWidgets OpenGL 程序启用多重采样?
多重采样是应用全屏的一种方式3D 应用程序中的抗锯齿 (FSAA)。 我需要在我的 OpenGL 程序中使用多重采样,该程序当前嵌入在 wxWidgets GUI 中。 有没有办法做到这一点? 仅当您知道实现此目的的详细步骤时才请回复。
我知道使用 WGL< 启用多重采样/a> (Win32 对 OpenGL 的扩展)。 但是,由于我的 OpenGL 程序不是用 MFC 编写的(并且我希望代码可以跨平台移植),所以这对我来说不是一个选择。
Multisampling is a way of applying full screen anti-aliasing (FSAA) in 3D applications. I need to use multisampling in my OpenGL program, which is currently embedded in a wxWidgets GUI. Is there a way to do this? Please respond only if you know the detailed steps to achieve this.
I'm aware of enabling multisampling using WGL (Win32 extensions to OpenGL). However, since my OpenGL program isn't written in MFC (and I want the code to be multi-platform portable), that's not an option for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于在我的 wxWidgets OpenGL 程序中实现了多重采样。 现在有点混乱,但具体情况如下:
wxWidgets 目前在其稳定版本中没有多重采样支持(最新版本在此)时间为2.8.8)。 但是,它可以作为补丁提供,也可以通过他们的每日快照提供。 (后者令人振奋,因为这意味着补丁已被接受,如果没有问题,应该会出现在以后的稳定版本中。)
因此,有 2 个选项:
从他们的 每日快照。
获取补丁 用于您工作的 wxWidgets 安装。
我发现第二个选项不太麻烦,因为我不想尽可能地干扰我的工作安装。 如果您不知道如何在 Windows 上打补丁,请参阅此。
至少,对于 Windows,该补丁将修改以下文件:
打补丁后,重新编译 wxWidgets 库。
要在您的 wxWidgets OpenGL 程序中启用多重采样,需要对代码进行少量更改。
需要将属性列表传递给 wxGLCanvas 构造函数:
如果您已经在使用属性列表,则向其中添加带有
GL_SAMPLE_BUFFERS, GL_TRUE
的行。 否则,请将此属性列表定义添加到您的代码中。然后修改您的 wxGLCanvas 构造函数,以将此属性列表作为参数:
创建 wxGLCanvas 元素后,默认情况下会打开多重采样。 要随意禁用或启用它,请使用相关的 OpenGL 调用:
多重采样现在应该与 wxWidgets OpenGL 程序一起使用。 希望 wxWidgets 的稳定版本很快就会支持它,从而使此信息变得无关紧要:-)
I finally got Multisampling working with my wxWidgets OpenGL program. It's a bit messy right now, but here's how:
wxWidgets doesn't have Multisampling support in their stable releases right now (latest version at this time is 2.8.8). But, it's available as a patch and also through their daily snapshot. (The latter is heartening, since it means that the patch has been accepted and should appear in later stable releases if there are no issues.)
So, there are 2 options:
Download and build from their daily snapshot.
Get the patch for your working wxWidgets installation.
I found the 2nd option to be less cumbersome, since I don't want to disturb my working installation as much as possible. If you don't know how to patch on Windows, see this.
At the very least, for Windows, the patch will modify the following files:
After patching, recompile the wxWidgets libraries.
To enable multisampling in your wxWidgets OpenGL program, minor changes to the code are required.
An attribute list needs to be passed to the wxGLCanvas constructor:
If you were already using an attribute list, then add the line with
GL_SAMPLE_BUFFERS, GL_TRUE
to it. Else, add this attribute list definition to your code.Then modify your wxGLCanvas constructor to take this attribute list as a parameter:
After the wxGLCanvas element is created, multisampling is turned on by default. To disable or enable it at will, use the related OpenGL calls:
Multisampling should now work with the wxWidgets OpenGL program. Hopefully, it should be supported in the stable release of wxWidgets soon, making this information irrelevant :-)