Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
318f6068
Commit
318f6068
authored
Aug 25, 2007
by
Roderick Colenbrander
Committed by
Alexandre Julliard
Aug 27, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Improve pixelformat selection code.
parent
30840815
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
29 deletions
+49
-29
context.c
dlls/wined3d/context.c
+49
-29
No files found.
dlls/wined3d/context.c
View file @
318f6068
...
@@ -131,6 +131,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -131,6 +131,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
TRACE
(
"(%p): Creating a %s context for render target %p
\n
"
,
This
,
create_pbuffer
?
"offscreen"
:
"onscreen"
,
target
);
TRACE
(
"(%p): Creating a %s context for render target %p
\n
"
,
This
,
create_pbuffer
?
"offscreen"
:
"onscreen"
,
target
);
#define PUSH1(att) attribs[nAttribs++] = (att);
#define PUSH2(att,value) attribs[nAttribs++] = (att); attribs[nAttribs++] = (value);
if
(
create_pbuffer
)
{
if
(
create_pbuffer
)
{
HDC
hdc_parent
=
GetDC
(
win_handle
);
HDC
hdc_parent
=
GetDC
(
win_handle
);
int
iPixelFormat
=
0
;
int
iPixelFormat
=
0
;
...
@@ -144,9 +146,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -144,9 +146,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
int
nAttribs
=
0
;
int
nAttribs
=
0
;
unsigned
int
nFormats
;
unsigned
int
nFormats
;
#define PUSH1(att) attribs[nAttribs++] = (att);
#define PUSH2(att,value) attribs[nAttribs++] = (att); attribs[nAttribs++] = (value);
/* Retrieve the specifications for the pixelformat from the backbuffer / stencilbuffer */
/* Retrieve the specifications for the pixelformat from the backbuffer / stencilbuffer */
getColorBits
(
target
->
resource
.
format
,
&
red
,
&
green
,
&
blue
,
&
alphaBits
,
&
colorBits
);
getColorBits
(
target
->
resource
.
format
,
&
red
,
&
green
,
&
blue
,
&
alphaBits
,
&
colorBits
);
getDepthStencilBits
(
StencilBufferFormat
,
&
depthBits
,
&
stencilBits
);
getDepthStencilBits
(
StencilBufferFormat
,
&
depthBits
,
&
stencilBits
);
...
@@ -158,9 +157,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -158,9 +157,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
PUSH2
(
WGL_STENCIL_BITS_ARB
,
stencilBits
);
PUSH2
(
WGL_STENCIL_BITS_ARB
,
stencilBits
);
PUSH1
(
0
);
/* end the list */
PUSH1
(
0
);
/* end the list */
#undef PUSH1
#undef PUSH2
/* Try to find a pixelformat that matches exactly. If that fails let ChoosePixelFormat try to find a close match */
/* Try to find a pixelformat that matches exactly. If that fails let ChoosePixelFormat try to find a close match */
if
(
!
GL_EXTCALL
(
wglChoosePixelFormatARB
(
hdc_parent
,
(
const
int
*
)
&
attribs
,
NULL
,
1
,
&
iPixelFormat
,
&
nFormats
)))
if
(
!
GL_EXTCALL
(
wglChoosePixelFormatARB
(
hdc_parent
,
(
const
int
*
)
&
attribs
,
NULL
,
1
,
&
iPixelFormat
,
&
nFormats
)))
{
{
...
@@ -205,10 +201,12 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -205,10 +201,12 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
else
{
}
else
{
PIXELFORMATDESCRIPTOR
pfd
;
PIXELFORMATDESCRIPTOR
pfd
;
int
iPixelFormat
;
int
iPixelFormat
;
short
red
,
green
,
blue
,
alpha
;
short
redBits
,
greenBits
,
blueBits
,
alphaBits
,
colorBits
;
short
colorBits
;
short
depthBits
=
0
,
stencilBits
=
0
;
short
depthBits
,
stencilBits
;
int
res
;
int
res
;
int
attribs
[
256
];
int
nAttribs
=
0
;
unsigned
int
nFormats
;
hdc
=
GetDC
(
win_handle
);
hdc
=
GetDC
(
win_handle
);
if
(
hdc
==
NULL
)
{
if
(
hdc
==
NULL
)
{
...
@@ -217,36 +215,56 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -217,36 +215,56 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
}
/* PixelFormat selection */
/* PixelFormat selection */
/* TODO: fill cColorBits/cDepthBits with target->resource.format */
PUSH2
(
WGL_DRAW_TO_WINDOW_ARB
,
GL_TRUE
);
/* We want to draw to a window */
ZeroMemory
(
&
pfd
,
sizeof
(
pfd
));
PUSH2
(
WGL_DOUBLE_BUFFER_ARB
,
GL_TRUE
);
pfd
.
nSize
=
sizeof
(
pfd
);
PUSH2
(
WGL_PIXEL_TYPE_ARB
,
WGL_TYPE_RGBA_ARB
);
/* Make sure we don't get a float or color index format */
pfd
.
nVersion
=
1
;
pfd
.
dwFlags
=
PFD_SUPPORT_OPENGL
|
PFD_DOUBLEBUFFER
|
PFD_DRAW_TO_WINDOW
;
/*PFD_GENERIC_ACCELERATED*/
if
(
!
getColorBits
(
target
->
resource
.
format
,
&
redBits
,
&
greenBits
,
&
blueBits
,
&
alphaBits
,
&
colorBits
))
{
pfd
.
iPixelType
=
PFD_TYPE_RGBA
;
ERR
(
"Unable to get color bits for format %#x!
\n
"
,
target
->
resource
.
format
);
pfd
.
cColorBits
=
32
;
return
FALSE
;
pfd
.
cDepthBits
=
0
;
}
pfd
.
cStencilBits
=
0
;
PUSH2
(
WGL_COLOR_BITS_ARB
,
colorBits
);
pfd
.
iLayerType
=
PFD_MAIN_PLANE
;
PUSH2
(
WGL_RED_BITS_ARB
,
redBits
);
PUSH2
(
WGL_GREEN_BITS_ARB
,
greenBits
);
/* Try to match the colorBits of the d3d format */
PUSH2
(
WGL_BLUE_BITS_ARB
,
blueBits
);
if
(
getColorBits
(
target
->
resource
.
format
,
&
red
,
&
green
,
&
blue
,
&
alpha
,
&
colorBits
))
PUSH2
(
WGL_ALPHA_BITS_ARB
,
alphaBits
);
pfd
.
cColorBits
=
colorBits
;
/* Retrieve the depth stencil format from the present parameters.
/* Retrieve the depth stencil format from the present parameters.
* The choice of the proper format can give a nice performance boost
* The choice of the proper format can give a nice performance boost
* in case of GPU limited programs. */
* in case of GPU limited programs. */
if
(
pPresentParms
->
EnableAutoDepthStencil
)
{
if
(
pPresentParms
->
EnableAutoDepthStencil
)
{
TRACE
(
"pPresentParms->EnableAutoDepthStencil=enabled; using AutoDepthStencilFormat=%s
\n
"
,
debug_d3dformat
(
pPresentParms
->
AutoDepthStencilFormat
));
TRACE
(
"pPresentParms->EnableAutoDepthStencil=enabled; using AutoDepthStencilFormat=%s
\n
"
,
debug_d3dformat
(
pPresentParms
->
AutoDepthStencilFormat
));
if
(
getDepthStencilBits
(
pPresentParms
->
AutoDepthStencilFormat
,
&
depthBits
,
&
stencilBits
))
{
if
(
!
getDepthStencilBits
(
pPresentParms
->
AutoDepthStencilFormat
,
&
depthBits
,
&
stencilBits
))
{
pfd
.
cDepthBits
=
depthBits
;
ERR
(
"Unable to get depth / stencil bits for AutoDepthStencilFormat %#x!
\n
"
,
pPresentParms
->
AutoDepthStencilFormat
)
;
pfd
.
cStencilBits
=
stencilBits
;
return
FALSE
;
}
}
PUSH2
(
WGL_DEPTH_BITS_ARB
,
depthBits
);
PUSH2
(
WGL_STENCIL_BITS_ARB
,
stencilBits
);
}
}
PUSH1
(
0
);
/* end the list */
iPixelFormat
=
ChoosePixelFormat
(
hdc
,
&
pfd
);
iPixelFormat
=
ChoosePixelFormat
(
hdc
,
&
pfd
);
if
(
!
iPixelFormat
)
{
/* If this happens something is very wrong as ChoosePixelFormat barely fails */
/* In case of failure hope that standard ChooosePixelFormat will find something suitable */
ERR
(
"Can't find a suitable iPixelFormat
\n
"
);
if
(
!
GL_EXTCALL
(
wglChoosePixelFormatARB
(
hdc
,
(
const
int
*
)
&
attribs
,
NULL
,
1
,
&
iPixelFormat
,
&
nFormats
)))
{
/* PixelFormat selection */
ZeroMemory
(
&
pfd
,
sizeof
(
pfd
));
pfd
.
nSize
=
sizeof
(
pfd
);
pfd
.
nVersion
=
1
;
pfd
.
dwFlags
=
PFD_SUPPORT_OPENGL
|
PFD_DOUBLEBUFFER
|
PFD_DRAW_TO_WINDOW
;
/*PFD_GENERIC_ACCELERATED*/
pfd
.
iPixelType
=
PFD_TYPE_RGBA
;
pfd
.
cAlphaBits
=
alphaBits
;
pfd
.
cColorBits
=
colorBits
;
pfd
.
cDepthBits
=
depthBits
;
pfd
.
cStencilBits
=
stencilBits
;
pfd
.
iLayerType
=
PFD_MAIN_PLANE
;
iPixelFormat
=
ChoosePixelFormat
(
hdc
,
&
pfd
);
if
(
!
iPixelFormat
)
{
/* If this happens something is very wrong as ChoosePixelFormat barely fails */
ERR
(
"Can't find a suitable iPixelFormat
\n
"
);
}
}
}
DescribePixelFormat
(
hdc
,
iPixelFormat
,
sizeof
(
pfd
),
&
pfd
);
DescribePixelFormat
(
hdc
,
iPixelFormat
,
sizeof
(
pfd
),
&
pfd
);
...
@@ -265,6 +283,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
...
@@ -265,6 +283,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
}
}
}
}
}
#undef PUSH1
#undef PUSH2
ctx
=
pwglCreateContext
(
hdc
);
ctx
=
pwglCreateContext
(
hdc
);
if
(
This
->
numContexts
)
pwglShareLists
(
This
->
contexts
[
0
]
->
glCtx
,
ctx
);
if
(
This
->
numContexts
)
pwglShareLists
(
This
->
contexts
[
0
]
->
glCtx
,
ctx
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment