通常在设置OpenGL上下文时,我只需填写一个带有必要信息的PIXELFORMATDESCRIPTOR结构,并调用ChoosePixelFormat(),然后使用ChoosePixelFormat()返回的匹配像素格式调用SetPixelFormat().然后我只是简单地传递了初始描述符而没有过多考虑原因.
但现在我使用wglChoosePixelFormatARB()而不是ChoosePixelFormat(),因为我需要一些扩展特性,如sRGB和多重采样.它需要一个整数的属性列表,就像Linux上的XLib/GLX,而不是PIXELFORMATDESCRIPTOR结构.那么,我真的必须填写SetPixelFormat()的描述符来使用吗?SetPixelFormat()在已有pixelformat描述符索引时使用描述符是什么?为什么我必须在两个不同的位置指定相同的pixelformat属性?哪一个优先; wglChoosePixelFormatARB()的属性列表,或传递给SetPixelFormat()的PIXELFORMATDESCRIPTOR属性?
以下是函数原型,以使问题更清晰:
/* Finds a best match based on a PIXELFORMATDESCRIPTOR,
and returns the pixelformat index */
int ChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd);
/* Finds a best match based on an attribute list of integers and floats,
and returns a list of indices of matches, with the best matches at the head.
Also supports extended pixelformat traits like sRGB color space,
floating-point framebuffers and multisampling. */
BOOL wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList,
const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats,
UINT *nNumFormats
);
/* Sets the pixelformat based on the pixelformat index */
BOOL SetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd);
Run Code Online (Sandbox Code Playgroud)
编辑:MSDN说这是关于SetPixelFormat()参数:
指向包含逻辑像素格式规范的PIXELFORMATDESCRIPTOR结构的指针.系统的元文件组件使用此结构来记录逻辑像素格式规范.该结构对SetPixelFormat函数的行为没有其他影响.
但我不知道这意味着什么,或者它与我的问题有什么关系.
我相信您不必使用 PIXELFORMATDESCRIPTOR 和 ChoosePixelFormat,只需使用 wglChoosePixelFormatARB 并将返回的 int 设置为 Pixelformat 即可。这些函数仅用于查询窗口以匹配像素格式,SetPixelFormat 函数不知道您使用哪个函数来获取所需的像素格式。
以下讨论的结论:
我研究过Wine的opengl实现,他们完全忽略了这个参数..(internal_SetPixelFormat),但是谁知道ms用它做什么,我看到的唯一安全的方法是使用wglChoosePixelFormatARB函数找到pixelformat,然后使用DescribePixelFormat来填写您传回 SetPixelFormat 的结构。
| 归档时间: |
|
| 查看次数: |
4264 次 |
| 最近记录: |