当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_VideoData::vulkan_XGetXCBConnection方法代码示例

本文整理汇总了C++中SDL_VideoData::vulkan_XGetXCBConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoData::vulkan_XGetXCBConnection方法的具体用法?C++ SDL_VideoData::vulkan_XGetXCBConnection怎么用?C++ SDL_VideoData::vulkan_XGetXCBConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SDL_VideoData的用法示例。


在下文中一共展示了SDL_VideoData::vulkan_XGetXCBConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vkCreateXcbSurfaceKHR

SDL_bool X11_Vulkan_CreateSurface(_THIS,
                                  SDL_Window *window,
                                  VkInstance instance,
                                  VkSurfaceKHR *surface)
{
    SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
    SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
    PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
    if(!_this->vulkan_config.loader_handle)
    {
        SDL_SetError("Vulkan is not loaded");
        return SDL_FALSE;
    }
    vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
    if(videoData->vulkan_xlib_xcb_library)
    {
        PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR =
            (PFN_vkCreateXcbSurfaceKHR)vkGetInstanceProcAddr((VkInstance)instance,
                                                             "vkCreateXcbSurfaceKHR");
        VkXcbSurfaceCreateInfoKHR createInfo;
        VkResult result;
        if(!vkCreateXcbSurfaceKHR)
        {
            SDL_SetError(VK_KHR_XCB_SURFACE_EXTENSION_NAME
                         " extension is not enabled in the Vulkan instance.");
            return SDL_FALSE;
        }
        SDL_zero(createInfo);
        createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
        createInfo.connection = videoData->vulkan_XGetXCBConnection(videoData->display);
        if(!createInfo.connection)
        {
            SDL_SetError("XGetXCBConnection failed");
            return SDL_FALSE;
        }
        createInfo.window = (xcb_window_t)windowData->xwindow;
        result = vkCreateXcbSurfaceKHR(instance, &createInfo,
                                       NULL, surface);
        if(result != VK_SUCCESS)
        {
            SDL_SetError("vkCreateXcbSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
            return SDL_FALSE;
        }
        return SDL_TRUE;
    }
    else
    {
        PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR =
            (PFN_vkCreateXlibSurfaceKHR)vkGetInstanceProcAddr((VkInstance)instance,
                                                              "vkCreateXlibSurfaceKHR");
        VkXlibSurfaceCreateInfoKHR createInfo;
        VkResult result;
        if(!vkCreateXlibSurfaceKHR)
        {
            SDL_SetError(VK_KHR_XLIB_SURFACE_EXTENSION_NAME
                         " extension is not enabled in the Vulkan instance.");
            return SDL_FALSE;
        }
        SDL_zero(createInfo);
        createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
        createInfo.dpy = videoData->display;
        createInfo.window = (xcb_window_t)windowData->xwindow;
        result = vkCreateXlibSurfaceKHR(instance, &createInfo,
                                        NULL, surface);
        if(result != VK_SUCCESS)
        {
            SDL_SetError("vkCreateXlibSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
            return SDL_FALSE;
        }
        return SDL_TRUE;
    }
}
开发者ID:Evengard,项目名称:UniMod,代码行数:72,代码来源:SDL_x11vulkan.c


注:本文中的SDL_VideoData::vulkan_XGetXCBConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。