summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/wgl/stw_framebuffer.c
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-02-08 16:23:06 +0000
committerJosé Fonseca <[email protected]>2012-02-10 16:23:27 +0000
commit9646762261d976d34bee8c8b1dcda9656cec655c (patch)
tree7433473c28a262191b0e06b87753df2d61435025 /src/gallium/state_trackers/wgl/stw_framebuffer.c
parent90a95f4d2c50b63ffa4c114081a1cfa5cdfa05cb (diff)
st/wgl: Properly support non-displayble pixel formats, and implement float pixelformats as as one.
WGL_ARB_pixel_format establishes the existence of pixel formats which are invisible to GDI. However we still need to pass a valid pixelformat to GDI, so that context creation/binding works. The actual WGL_TYPE_RGBA_FLOAT_ARB implementation is from Brian Paul.
Diffstat (limited to 'src/gallium/state_trackers/wgl/stw_framebuffer.c')
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 71b92f0d8f6..d0d5e9e0fe6 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -262,6 +262,12 @@ stw_framebuffer_create(
fb->hWnd = hWnd;
fb->iPixelFormat = iPixelFormat;
+ /*
+ * We often need a displayable pixel format to make GDI happy. Set it here (always 1, i.e.,
+ * out first pixel format) where appropriat.
+ */
+ fb->iDisplayablePixelFormat = iPixelFormat <= stw_dev->pixelformat_count ? iPixelFormat : 1;
+
fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat );
fb->stfb = stw_st_create_framebuffer( fb );
if (!fb->stfb) {
@@ -445,15 +451,21 @@ DrvSetPixelFormat(
return FALSE;
index = (uint) iPixelFormat - 1;
- count = stw_pixelformat_get_extended_count();
+ count = stw_pixelformat_get_count();
if (index >= count)
return FALSE;
fb = stw_framebuffer_from_hdc_locked(hdc);
if(fb) {
- /* SetPixelFormat must be called only once */
+ /*
+ * SetPixelFormat must be called only once. However ignore
+ * pbuffers, for which the framebuffer object is created first.
+ */
+ boolean bPbuffer = fb->bPbuffer;
+
stw_framebuffer_release( fb );
- return FALSE;
+
+ return bPbuffer;
}
fb = stw_framebuffer_create(hdc, iPixelFormat);
@@ -467,7 +479,8 @@ DrvSetPixelFormat(
* function instead of SetPixelFormat, so we call SetPixelFormat here to
* avoid opengl32.dll's wglCreateContext to fail */
if (GetPixelFormat(hdc) == 0) {
- SetPixelFormat(hdc, iPixelFormat, NULL);
+ BOOL bRet = SetPixelFormat(hdc, iPixelFormat, NULL);
+ assert(bRet);
}
return TRUE;