Tomas Carnecky wrote:
This partial rewrite aims at cleaning up the pixelformat code. Windows sometimes advertises one or more almost identical and completely compatible pixelformats. These pixelformats differ in attributes like color-bits, but I suspect the driver developers do that only to work around buggy applications that don't follow the spec. This rewrite will also simplify the pixelformat code by removing redundant blocks and moving the core functionality to a few main functions.
This is the first patch that simplifies ChoosePixelFormat() by converting the PFD structure to a list of WGL attributes and then using a function to choose the pixelformat. This function doesn't do anything as we support only one pixelformat, but this function will be shared with wglChoosePixelFormat() once the infrastructure for that is in place.
I also have a second patch that converts DescribePixelFormat() to use the same approach, eg. querying the pixelformat attributes using a WGL attribute list and then copying the values back the the PFD structure.
Few notes: You constructed the array of some attributes which you never use. You don't check if those attributes match anything - the part you removed. When app will ask for something that can't be supported your code will return it to the app - which is plain wrong.
And being picky - you using tabs for indentation, please use 4 spaces instead, and no tabs.
Vitaliy
Vitaliy Margolen wrote:
Few notes: You constructed the array of some attributes which you never use. You don't check if those attributes match anything - the part you removed. When app will ask for something that can't be supported your code will return it to the app - which is plain wrong.
We simply have nothing to choose from, wine supports only a single pixelformat. And as described in the comment, once the infrastructure is in place the helper function will do the real job.
MSDN: If the function succeeds, the return value is a pixel format index (one-based) that is the closest match to the given pixel format descriptor. You must ensure that the pixel format matched by the ChoosePixelFormat function satisfies your requirements. For example, if you request a pixel format with a 24-bit RGB color buffer but the device context offers only 8-bit RGB color buffers, the function returns a pixel format with an 8-bit RGB color buffer.
There's also a _lot_ code that goes like this:
GLXFBConfig *pCfgs = glXGetFBConfigs(...); ConvertPixelFormatWGLtoGLX(.., &index, ..); glXGetFBConfigAttrib(.., *pCfgs[index], ..); XFree(pCfgs);
This malloc()/free() can be removed by keeping a copy of the GLXFBConfig the the pixelformat registry (instead of the index to the GLXFBConfig list).
tom