【发布时间】:2010-03-29 18:51:16
【问题描述】:
通常在设置 OpenGL 上下文时,我只需使用必要的信息填写 PIXELFORMATDESCRIPTOR 结构并调用 ChoosePixelFormat(),然后使用从 ChoosePixelFormat() 返回的匹配像素格式调用 SetPixelFormat()。然后我只是简单地传递了初始描述符,而没有考虑太多原因。
但现在我使用 wglChoosePixelFormatARB() 而不是 ChoosePixelFormat(),因为我需要一些扩展特性,例如 sRGB 和多重采样。它采用整数的属性列表,就像 Linux 上的 XLib/GLX 一样,而不是 PIXELFORMATDESCRIPTOR 结构。那么,我真的必须填写一个描述符供 SetPixelFormat() 使用吗?当 SetPixelFormat() 已经具有像素格式描述符索引时,它使用描述符做什么?为什么我必须在两个不同的地方指定相同的 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);
编辑:MSDN 谈到了 SetPixelFormat() 参数:
指向包含逻辑像素格式规范的 PIXELFORMATDESCRIPTOR 结构的指针。系统的元文件组件使用这种结构来记录逻辑像素格式规范。该结构对 SetPixelFormat 函数的行为没有其他影响。
但我不知道这意味着什么,也不知道它与我的问题有何关系。
【问题讨论】: