OpenGL 和 D3D 像素格式之间的差异
我正在继续尝试为我的软件开发 OpenGL 路径。我使用抽象类和两者的具体实现,但显然我需要一个通用的像素格式枚举器,以便我可以描述两者之间的纹理、后缓冲区/前缓冲区和渲染目标格式。我在每个具体实现中提供一个函数,它接受我的抽象标识符(例如 R8G8B8A8),并为具体实现提供适合 D3D 或 OpenGL 的枚举。
我可以使用 CheckDeviceFormat 轻松枚举所有 D3D 像素格式。对于OpenGL,我首先迭代Win32可用的加速格式(使用DescribePixelFormat),然后查看PIXELFORMATDESCRIPTOR以了解它是如何组成的,因此我可以将其分配给我的枚举之一。这就是我的问题开始的地方:
我希望能够发现 OpenGL 在任何给定系统上支持的所有加速格式,与 D3D 格式相当。但根据格式描述符,不存在任何 RGB 格式(它们都是 BGR)。此外,DXT1 - 5 格式等在 D3D 中可枚举的格式无法使用上述方法进行枚举。对于后者,我想我可以假设扩展是否可用,它是硬件加速格式。
对于前者(如何用 RGB/BGR 等解释格式描述符),我不太确定它是如何工作的。
有人知道这件事吗?
回应表示赞赏。
I'm continuing to try and develop an OpenGL path for my software. I'm using abstract classes with concrete implementations for both, but obviously I need a common pixel format enumerator so that I can describe texture, backbuffer/frontbuffer and render target formats between the two. I provide a function in each concrete implementation that accepts my abstract identifier for say, R8G8B8A8, and provides the concrete implementation with an enum suitable for either D3D or OpenGL
I can easily enumerate all D3D pixel formats using CheckDeviceFormat. For OpenGL, I'm firstly iterating through Win32 available accelerated formats (using DescribePixelFormat) and then looking at the PIXELFORMATDESCRIPTOR to see how it's made up, so I can assign it one of my enums. This is where my problems start:
I want to be able to discover all accelerated formats that OpenGL supports on any given system, as comparable to a D3D format. But according to the format descriptors, there aren't any RGB formats (they're all BGR). Further, things like DXT1 - 5 formats, enumerable in D3D, aren't enumerable using the above method. For the latter, I suppose I can just assume if the extension is available, it's a hardware accelerated format.
For the former (how to interpret the format descriptor in terms of RGB/BGR, etc.), I'm not too sure how it works.
Anyone know about this stuff?
Responses appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我想我找到了我要找的东西:
OpenGL 图像格式
一些图像格式是由规范(用于后台缓冲区/深度模板、纹理、渲染目标等),因此在某种程度上保证这些将可用(它们不需要枚举)。像素格式描述符仍然可以用于计算给定窗口的可用前端缓冲区格式。
Ok, I think I found what I was looking for:
OpenGL image formats
Some image formats are defined by the spec (for backbuffer/depth-stencil, textures, render-targets, etc.), so there is a guarantee, to an extent, that these will be available (they don't need enumerating). The pixel format descriptor can still be used to work out available front buffer formats for the given window.