Commit 4647cbb6 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

wined3d: Better pixelformat selection code.

parent dee2fc09
......@@ -154,6 +154,9 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
} else {
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
short red, green, blue, alpha;
short colorBits;
short depthBits, stencilBits;
hdc = GetDC(win_handle);
if(hdc == NULL) {
......@@ -173,6 +176,16 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
pfd.cStencilBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
/* Try to match the colorBits of the d3d format */
if(getColorBits(target->resource.format, &red, &green, &blue, &alpha, &colorBits))
pfd.cColorBits = colorBits;
/* TODO: get the depth/stencil format from auto depth stencil format */
if(getDepthStencilBits(WINED3DFMT_D24S8, &depthBits, &stencilBits)) {
pfd.cDepthBits = depthBits;
pfd.cStencilBits = stencilBits;
}
iPixelFormat = ChoosePixelFormat(hdc, &pfd);
if(!iPixelFormat) {
/* If this happens something is very wrong as ChoosePixelFormat barely fails */
......
......@@ -1479,6 +1479,9 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords)
void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int width, unsigned int height);
GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain);
BOOL getColorBits(WINED3DFORMAT fmt, short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize);
BOOL getDepthStencilBits(WINED3DFORMAT fmt, short *depthSize, short *stencilSize);
/* Math utils */
void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2);
......@@ -2042,6 +2045,7 @@ typedef struct {
WINED3DFORMAT format;
DWORD alphaMask, redMask, greenMask, blueMask;
UINT bpp;
short depthSize, stencilSize;
BOOL isFourcc;
} StaticPixelFormatDesc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment