【问题标题】:Using Vulkan with SFML?将 Vulkan 与 SFML 一起使用?
【发布时间】:2019-03-28 12:58:11
【问题描述】:

我目前使用 GLFW 来创建窗口和用户输入。 GLFW 只是让我们说:

glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);

告诉 GLFW 没有使用 OpenGL。它甚至提供了类似

的功能
glfwCreateWindowSurface(...)

为不同平台自动创建窗口表面。

有什么方法可以用 SFML 做类似的事情吗?我在他们的网站上找不到任何关于它的信息,所以我认为答案是否定的。但也许有某种黑客行为,还是不建议这样做?

【问题讨论】:

    标签: c++ sfml vulkan


    【解决方案1】:

    这还没有集成到 SFML,但是there's an open pull request adding/discussing this feature

    【讨论】:

      【解决方案2】:

      下一个次要版本支持 Vulkan; SFML 2.6.0.

      新的sf::WindowBase 类用作所有Windows 的基类。它为操作窗口提供了一个简单的界面:移动、调整大小、显示/隐藏、控制鼠标光标等。它还通过其 pollEvent() 和 waitEvent() 函数提供事件处理。

      sf::Window 仍然作为 OpenGL 渲染的目标,但它现在从 sf::WindowBase 继承了上述功能。此设计选择已完成,以免破坏现有代码:see the full discussion for info

      默认情况下,新的sf::WindowBase 不会创建 OpenGL 上下文。相反,它提供了一个公共成员函数createVulkanSurface,其定义如下。

      ////////////////////////////////////////////////////////////
      /// \brief Create a Vulkan rendering surface
      ///
      /// \param instance  Vulkan instance
      /// \param surface   Created surface
      /// \param allocator Allocator to use
      ///
      /// \return True if surface creation was successful, false otherwise
      ///
      ////////////////////////////////////////////////////////////
      bool createVulkanSurface(const VkInstance& instance, VkSurfaceKHR& surface, const VkAllocationCallbacks* allocator = 0);
      

      使用演示(大约 2.600 行代码),可以在examples in the SFML respiratory 下找到。

      【讨论】:

        猜你喜欢
        • 2014-08-10
        • 2021-12-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多