1 year ago
#108482
anuj
Error of failed request: GLXBadDrawable (C++ bgfx)
I am trying to make a purple window with glfw and bgfx as just a starting point for my game engine but when launching the binary it throws me an error. I am trying to create the purple window as shown in the image down below:
I am using cmake for it and the error is:
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
I want to use opengl for it my CMakeLists.txt is:
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)
and my main.cpp file is:
#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;
```
}
and my projects files are:
main.cpp
test.cpp
CMakeLists.txt
submods
bgfx.cmake
out
build
and here is the make file for main.cpp
c++
linux
bgfx
0 Answers
Your Answer