请求失败的错误:GLXBadDrawable (C++ bgfx)

2024-04-27

我试图用 glfw 和 bgfx 创建一个紫色窗口作为我的游戏引擎的起点,但是在启动二进制文件时它会抛出一个错误。我正在尝试创建紫色窗口,如下图所示:

我正在使用 cmake ,错误是:

anuj@fedora ~/D/C/C/c/o/build> ./bgfx_test
 X Error of failed request:  GLXBadDrawable
 Major opcode of failed request:  152 (GLX)
 Minor opcode of failed request:  11 (X_GLXSwapBuffers)
 Serial number of failed request:  33
 Current serial number in output stream:  33

我想使用 opengl 我的 CMakeLists.txt 是:

cmake_minimum_required(VERSION 3.22.1)
project(bgfx_test)

set(CMAKE_CXX_STANDARD 14)

add_executable(bgfx_test main.cpp )

target_link_libraries(bgfx_test bgfx  glfw3 GL dl X11)

我的 main.cpp 文件是:

#include <GL/gl.h>
#include "submods/bgfx.cmake/bgfx/examples/common/common.h"
#include "submods/bgfx.cmake/bgfx/examples/common/bgfx_utils.h"
#include "submods/bgfx.cmake/bgfx/include/bgfx/bgfx.h"
#include <GLFW/glfw3.h>
#include <iostream>
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3native.h>

void exit(GLFWwindow *window)
{
    if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_TRUE)
    {
        /* code */
        glfwSetWindowShouldClose(window, true);
    }
}

int main()
{

    ``` glfwInit();

    GLFWwindow *window = glfwCreateWindow(900, 900, "learn_bgfx", NULL, NULL);
    if (window == NULL)
    {
        printf("no glfw");
        glfwTerminate();
        return -1;
    }
    bgfx::PlatformData pd;
    pd.ndt = glfwGetX11Display();
    pd.nwh = (void *)glfwGetX11Window(window);

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

    bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF, 1.0f, 0);
    bgfx::setViewRect(0, 0, 0, 900, 900);

    unsigned int counter = 0;
    while (true)
    {
        bgfx::frame();
        counter++;
    }

    glfwTerminate();
    return 0;
    ```
}

我的项目文件是:

main.cpp
test.cpp
CMakeLists.txt    
submods   
  bgfx.cmake
out
  build
    and here is the make file for main.cpp

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

请求失败的错误:GLXBadDrawable (C++ bgfx) 的相关文章

随机推荐