glxBadDrawable when using bgfx



使用以下BGFX代码时:

#include "GLFW/glfw3.h"
#include <bgfx/bgfx.h>
int main() {
glfwInit();
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello, bgfx!", NULL, NULL);


bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::Count; // Automatically choose a renderer.
bgfxInit.resolution.width = 800;
bgfxInit.resolution.height = 600;
bgfxInit.resolution.reset = BGFX_RESET_VSYNC;
bgfx::init(bgfxInit);
}

一个黑色的openGL窗口弹出并在一秒钟内看起来很好,然而,一个GLXBadDrawable错误然后弹出。我不知道这个错误的原因是什么,另一个问题没有答案,已经有一段时间没有激活了。

我相信这不是代码的问题,而是我的机器的问题,然而,我可能错了。

我目前有一台联想T400笔记本电脑,配有酷睿2双核P9500。我有2个内置gpu,一个移动4系列芯片组集成图形芯片,以及ATI移动Radeon HD 3450/3470。我还运行了6.0.7-artix1-1内核的Artix Linux。如果有帮助的话,我还使用了glfw-x11和glfw包,以及i3-gaps窗口管理器。

我也尝试使用SDL2而不是GLFW,出现了同样的问题。然而,对于GLFW一个黑色窗口显示,而在SDL2,一个透明(?)窗口反而显示。搜索github问题页面也没有结果。

添加platformData为我解决了这个问题

bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::Count; // Automatically choose a renderer.
bgfxInit.resolution.width = 800;
bgfxInit.resolution.height = 600;
bgfxInit.resolution.reset = BGFX_RESET_VSYNC;
#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
bgfxInit.platformData.ndt = glfwGetX11Display();
bgfxInit.platformData.nwh = (void*)(uintptr_t)glfwGetX11Window(window);
#elif BX_PLATFORM_OSX
bgfxInit.platformData.nwh = glfwGetCocoaWindow(window);
#elif BX_PLATFORM_WINDOWS
bgfxInit.platformData.nwh = glfwGetWin32Window(window);
#endif
bgfx::init(bgfxInit);

最新更新