使用 OpenGL 枚举适配器和模式的像素格式

发布于 2024-10-08 22:06:36 字数 1148 浏览 9 评论 0原文

我正在尝试为我的 3D 引擎编写 OpenGL 路径。 D3D 路径枚举每个适配器的所有设备适配器、所有模式(我所说的模式是指位深度、尺寸、可用窗口和刷新率),然后枚举可用于给定模式和适配器的所有像素格式,以及某些有用的上限(着色器)版本、过滤器类型等)。因此,我在类中大致获得了以下受保护的函数:

// Enumerate all back/front buffer combinations.

virtual void EnumerateBackFrontBufferCombinations(CComPtr<IDirect3D9>& d3d9);

// Enumerate all depth/stencil formats.

virtual void EnumerateDepthStencilFormats(CComPtr<IDirect3D9>& d3d9);

// Enumerate all multi-sample formats.

virtual void EnumerateMultiSampleTypes(CComPtr<IDirect3D9>& d3d9);

// Enumerate all device formats, i.e. dynamic, static, render target, etc.

virtual void EnumerateMapFormats(CComPtr<IDirect3D9>& d3d9);

// Enumerate all capabilities.

virtual void EnumerateCapabilities(CComPtr<IDirect3D9>& d3d9);

使用 EnumDisplayDevices 枚举适配器,使用 EnumDisplaySettings 枚举模式(分辨率和刷新率),因此可以为 GL 或 D3D 完成此操作。我不太确定 OpenGL 的其他功能。 IDirect3D9 的 CheckDeviceType、CheckDeviceFormat、CheckDeviceMultiSampleType、CheckDepthStencilMatch 的等效项是什么?我知道我可以使用DescribePixelFormat,给定一个DC,但是您需要先创建窗口,然后才能使用DC,但是在您知道要使用什么格式之前,您无法正确创建窗口使用。

你能给我什么建议吗?

谢谢。

I'm trying to code an OpenGL path for my 3D engine. The D3D path enumerates all device adaptors, all modes (by mode I mean bit depth, dimensions, available windowed, and refresh rate) for each adaptor and then all pixel formats available for the given mode and adaptor, along side certain useful caps (shader version, filter types, etc.). So, I have broadly got the following protected functions in the class:

// Enumerate all back/front buffer combinations.

virtual void EnumerateBackFrontBufferCombinations(CComPtr<IDirect3D9>& d3d9);

// Enumerate all depth/stencil formats.

virtual void EnumerateDepthStencilFormats(CComPtr<IDirect3D9>& d3d9);

// Enumerate all multi-sample formats.

virtual void EnumerateMultiSampleTypes(CComPtr<IDirect3D9>& d3d9);

// Enumerate all device formats, i.e. dynamic, static, render target, etc.

virtual void EnumerateMapFormats(CComPtr<IDirect3D9>& d3d9);

// Enumerate all capabilities.

virtual void EnumerateCapabilities(CComPtr<IDirect3D9>& d3d9);

The adaptors are enumerated with EnumDisplayDevices, the modes (resolutions and refresh rates) are enumerated with EnumDisplaySettings, so this can be done for either GL or D3D. The other functions I'm not so sure about with OpenGL. What are the equivalents to the IDirect3D9's CheckDeviceType, CheckDeviceFormat, CheckDeviceMultiSampleType, CheckDepthStencilMatch? I know I can use DescribePixelFormat, given a DC, but you kind-of need to have created the window before you can use a DC with it, but you can't create the window correctly until you know what formats you're going to use.

Any tips you can give me?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我纯我任性 2024-10-15 22:06:36

但是除非您知道要使用什么格式,否则您无法正确创建窗口

为什么?

标准方法是:

  1. 创建窗口。
  2. 枚举窗口的DC所代表的设备支持的所有格式。
  3. 使用您喜欢的格式调用 SetPixelFormat() 来设置格式。
  4. 创建 OpenGL 上下文。

but you can't create the window correctly until you know what formats you're going to use

Why?

The standard approach is:

  1. Create the window.
  2. Enumerate all the formats supported by the device represented by the DC of the window.
  3. Call SetPixelFormat() with you favorite format to set the format.
  4. Create OpenGL context.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文