本文介绍了当 SDL_WINDOW_VULKAN 标志设置时 SDL_CreateWindow 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行此代码时

if(SDL_Init(SDL_INIT_VIDEO) < 0)
    printf("%s\n", SDL_GetError());
if(!SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_VULKAN))
    printf("%s\n", SDL_GetError());

在安装工作 gpu 驱动程序并链接 vulkan 之后,我得到这个输出:

after installing working gpu drivers and having linked vulkan,I get this output:

Vulkan 支持要么未在 SDL 中配置,要么在视频驱动程序中不可用

我在 ubuntu 上运行 Geforce GTX 660M + 官方驱动程序和 SDL2 版本 2.0.8.看起来像是 SDL 中的一个错误,但我想确认一下.

I'm running on ubuntu with a Geforce GTX 660M + official drivers and SDL2 version 2.0.8. Seems like a bug in SDL, but I wanted to ask to make sure.

推荐答案

与 vulkan 库链接并不意味着 SDL 实际上在使用 vulkan 函数.您可以将任何内容与您不使用的库相关联,并且不会触发任何警告或问题.

Linking with the vulkan lib doesn't mean that SDL is actually using the vulkan functions. You can link anything with a library that you don't use and it wont trigger any warning or problems.

尝试编译

int main() { return 0; }

并添加您想要的所有链接标志.

And add all the link flags you want.

该错误告诉您未在启用 vulkan 支持的情况下编译的 SDL 二进制文件.您需要手动编译 SDL.如果没有设置编译标志,Vulkan 可能会被宏删除.

The error is telling you the SDL binaries you have arent compiled with vulkan support enabled. You'll need to compile SDL by hand. Vulkan is probably macroe'd away if no compile flag is set.

顺便说一下,我在 ubuntu 包中查看了 libsdl2 的规则(我猜你有 ubunt 18.04 >),实际上 vulkan 已禁用

By the way I went to the rules of libsdl2 in ubuntu packages (I'm guessign you have ubunt 18.04 >) and in fact vulkan is disabled

# the SDL module for Vulkan not compiling even in Linux at the moment
confflags += --disable-video-vulkan

这篇关于当 SDL_WINDOW_VULKAN 标志设置时 SDL_CreateWindow 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:52