summaryrefslogtreecommitdiff
path: root/cogl/winsys/cogl-winsys-wgl.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-08-22 23:55:57 +0100
committerRobert Bragg <robert@linux.intel.com>2011-10-28 19:10:16 +0100
commit98e5a9c777af5d2ead09fcca856da0f346715100 (patch)
tree723531fe78999c8f0ce22d322416955e77d4932f /cogl/winsys/cogl-winsys-wgl.c
parent63461c0f8bffcf818e8d932dfb6cf260f0995470 (diff)
downloadcogl-98e5a9c777af5d2ead09fcca856da0f346715100.tar.gz
Rework how we search for winsys configs
When creating new onscreen framebuffers we need to take the configuration in cogl terms and translate that into a configuration applicable to any given winsys, e.g. an EGLConfig or a GLXFBConfig or a PIXELFORMATDESCRIPTOR. Also when we first create a context we typically have to do a very similar thing because most OpenGL winsys APIs also associate a framebuffer config with the context and all future configs need to be compatible with that. This patch introduces an internal CoglFramebufferConfig to wrap up some of the configuration parameters that are common to CoglOnscreenTemplate and to CoglFramebuffer so we aim to re-use code when dealing with the above two problems. This patch also aims to rework the winsys code so it can be more naturally extended as we start adding more configureability to how onscreen framebuffers are created. Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/winsys/cogl-winsys-wgl.c')
-rw-r--r--cogl/winsys/cogl-winsys-wgl.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c
index f3bc8ba6..8306f278 100644
--- a/cogl/winsys/cogl-winsys-wgl.c
+++ b/cogl/winsys/cogl-winsys-wgl.c
@@ -316,7 +316,8 @@ pixel_format_is_better (const PIXELFORMATDESCRIPTOR *pfa,
}
static int
-choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
+choose_pixel_format (CoglFramebufferConfig *config,
+ HDC dc, PIXELFORMATDESCRIPTOR *pfd)
{
int i, num_formats, best_pf = 0;
PIXELFORMATDESCRIPTOR best_pfd;
@@ -341,6 +342,11 @@ choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
already found */
(best_pf == 0 || pixel_format_is_better (&best_pfd, pfd)))
{
+ if (config->swap_chain->has_alpha && pfd->cAlphaBits == 0)
+ continue;
+ if (config->need_stencil && pfd->cStencilBits == 0)
+ continue;
+
best_pf = i;
best_pfd = *pfd;
}
@@ -445,7 +451,8 @@ create_context (CoglDisplay *display, GError **error)
wgl_display->dummy_dc = GetDC (wgl_display->dummy_hwnd);
- pf = choose_pixel_format (wgl_display->dummy_dc, &pfd);
+ pf = choose_pixel_format (&display->onscreen_template->config,
+ wgl_display->dummy_dc, &pfd);
if (pf == 0 || !SetPixelFormat (wgl_display->dummy_dc, pf, &pfd))
{
@@ -784,9 +791,10 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
wgl_onscreen->client_dc = GetDC (hwnd);
/* Use the same pixel format as the dummy DC from the renderer */
- pf = GetPixelFormat (wgl_display->dummy_dc);
- DescribePixelFormat (wgl_display->dummy_dc, pf, sizeof (pfd), &pfd);
- if (!SetPixelFormat (wgl_onscreen->client_dc, pf, &pfd))
+ pf = choose_pixel_format (&framebuffer->config,
+ wgl_onscreen->client_dc, &pfd);
+
+ if (pf == 0 || !SetPixelFormat (wgl_onscreen->client_dc, pf, &pfd))
{
g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_ONSCREEN,