static void
_glitz_wgl_screen_destroy (glitz_wgl_screen_info_t *screen_info)
{
    int i;

    if (screen_info->root_context) {
	wglMakeCurrent (NULL, NULL);
    }

    for (i = 0; i < screen_info->n_contexts; i++)
	glitz_wgl_context_destroy (screen_info, screen_info->contexts[i]);

    if (screen_info->contexts)
	free (screen_info->contexts);

    if (screen_info->formats)
	free (screen_info->formats);

    if (screen_info->format_ids)
	free (screen_info->format_ids);

    if (screen_info->root_context) {
	wglDeleteContext (screen_info->root_context);
    }

    if (screen_info->root_dc) {
	DeleteDC (screen_info->root_dc);
    }

    if (screen_info->root_window) {
	DestroyWindow (screen_info->root_window);
    }

    free (screen_info);
}
예제 #2
0
static glitz_drawable_t *
_glitz_wgl_create_pbuffer_drawable (glitz_wgl_screen_info_t    *screen_info,
				    glitz_drawable_format_t    *format,
				    unsigned int                width,
				    unsigned int                height)
{
    glitz_wgl_drawable_t *drawable;
    glitz_wgl_context_t *context;
    glitz_int_drawable_format_t *iformat = &screen_info->formats[format->id];
    HPBUFFERARB pbuffer;
    HDC dc;

    if (!(iformat->types & GLITZ_DRAWABLE_TYPE_PBUFFER_MASK))
	return NULL;

    pbuffer = glitz_wgl_pbuffer_create (screen_info, screen_info->format_ids[format->id],
					width, height,
					&dc);
    if (!pbuffer)
	return NULL;

    context = glitz_wgl_context_get (screen_info, dc, format);
    if (!context) {
	glitz_wgl_pbuffer_destroy (screen_info, pbuffer, dc);
	return NULL;
    }

    drawable = _glitz_wgl_create_drawable (screen_info, context, format,
					   NULL, dc, pbuffer,
					   width, height);
    if (!drawable) {
	glitz_wgl_pbuffer_destroy (screen_info, pbuffer, dc);
	glitz_wgl_context_destroy (screen_info, context);
	return NULL;
    }

    return &drawable->base;
}