问题描述
通常,在设置OpenGL上下文时,我只是简单地用必要的信息填充了PIXELFORMATDESCRIPTOR结构,并将其命名为ChoosePixelFormat(),然后使用从ChoosePixelFormat()返回的匹配像素格式调用SetPixelFormat().然后,我只是简单地通过了初始描述符,而没有过多考虑为什么.
Usually when setting up OpenGL contexts, I've simply filled out a PIXELFORMATDESCRIPTOR structure with the necessary information and called ChoosePixelFormat(), followed by a call to SetPixelFormat() with the returned matching pixelformat from ChoosePixelFormat(). Then I've simply passed the initial descriptor without giving much thought of why.
但是现在我使用wglChoosePixelFormatARB()而不是ChoosePixelFormat(),因为我需要一些扩展的特征,例如sRGB和多重采样.它采用整数的属性列表,就像Linux上的XLib/GLX一样,而不是PIXELFORMATDESCRIPTOR结构.那么,我真的必须填写描述符以供SetPixelFormat()使用吗?当SetPixelFormat()已经具有pixelformat描述符索引时,该描述符使用什么?为什么必须在两个不同的地方指定相同的pixelformat属性?哪一个优先?将属性列表传递给wglChoosePixelFormatARB()或传递给SetPixelFormat()的PIXELFORMATDESCRIPTOR属性?
But now I use wglChoosePixelFormatARB() instead of ChoosePixelFormat(), because I need some extended traits like sRGB and multisampling. It takes an attribute list of integers, just like XLib/GLX on Linux, not a PIXELFORMATDESCRIPTOR structure. So, do I really have to fill in a descriptor for SetPixelFormat() to use? What does SetPixelFormat() use the descriptor for when it already has the pixelformat descriptor index? Why do I have to specify the same pixelformat attributes in two different places? And which one takes precedence; the attribute list to wglChoosePixelFormatARB(), or the PIXELFORMATDESCRIPTOR attributes passed to SetPixelFormat()?
下面是函数原型,以使问题更清楚:
Here are the function prototypes, to make the question more clear:
/* 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()参数:
MSDN says this about the SetPixelFormat() parameter:
但是我不知道这意味着什么,或者它与我的问题有什么关系.
But I have no idea what this means, or how it relates to my question(s).
推荐答案
我相信您不必使用PIXELFORMATDESCRIPTOR和ChoosePixelFormat,只需使用wglChoosePixelFormatARB并将返回的int设置为pixelformat.这些函数仅用于查询窗口以匹配像素格式,SetPixelFormat函数不知道您使用哪个函数来获取所需的像素格式.
I believe you won't have to use PIXELFORMATDESCRIPTOR and ChoosePixelFormat, just use wglChoosePixelFormatARB and set the returned int as pixelformat. Those functions are used just to query windows for matching pixel format, the SetPixelFormat function has no idea which function you used to obtain the desired pixel format.
以下讨论的结论:
我研究了Wine的opengl实现,他们完全忽略了该参数..( internal_SetPixelFormat ),但谁知道ms会做什么,我看到的唯一安全的方法是使用wglARhoBoseBixBel查找像素格式函数,然后使用DescribePixelFormat填写传递回SetPixelFormat的结构.
I have looked into Wine's opengl implementation, they completly ignore that parameter.. (internal_SetPixelFormat), but who knows what ms does with it, the only safe way I see is to find pixelformat with wglChoosePixelFormatARB function, and then use DescribePixelFormat to fill in the structure which you pass back to SetPixelFormat.
这篇关于SetPixelFormat()中的PIXELFORMATDESCRIPTOR参数是用来做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!