GoaLitiuM / bindbc-bgfx

Dynamic and static D bindings for bgfx
Boost Software License 1.0
21 stars 1 forks source link

GLXBadContext on trying to use with bindbc-sdl #3

Closed kyle-vasilia closed 4 years ago

kyle-vasilia commented 4 years ago

Hello!

Excuse me if I don't format this issue with enough information or it seems like a simple problem.

Using this with bindbc-sdl and as a dynamic library gives off the runtime error: libGL error: failed to create drawable libGL error: failed to create drawable X Error of failed request: GLXBadContext Major opcode of failed request: 150 (GLX) Minor opcode of failed request: 26 (X_GLXMakeContextCurrent) Serial number of failed request: 219 Current serial number in output stream: 219 I am certain it isn't an issue with the bgfx library I built - as I was able to run the examples just fine. glxinfo brings up

OpenGL core profile version string: 4.6 (Core Profile) Mesa 20.1.2 so it cannot be an issue with my drivers and being incompatible with bgfx.

I am not sure what I'm doing wrong, if it's an issue with how I compile bgfx that doesn't match with D or if this is a bug, any tips would be great!

I'll go ahead and include the full source of how I do it.


import bindbc.sdl;
import bindbc.bgfx;
import std.stdio;

void main() {
    loadSDL();
    loadBgfx();

    SDL_Init(SDL_VIDEO);
    SDL_Window *window = SDL_CreateWindow("bgfx", 
    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
    900, 600,  SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);

    SDL_SysWMinfo wmi;
    SDL_VERSION(&wmi.version_);
    SDL_GetWindowWMInfo(window, &wmi);
    bgfx_platform_data_t pd;
    pd.ndt = wmi.info.x11.display;
    pd.nwh = &wmi.info.x11.window;

    pd.context = null;
    pd.backBuffer = null;
    pd.backBufferDS = null;

    bgfx_init_t t;
    t.type = bgfx_renderer_type_t.BGFX_RENDERER_TYPE_OPENGL;
    t.vendorId = BGFX_PCI_ID_NONE;
    t.deviceId = 0;
    t.platformData = pd;
    t.resolution.format = bgfx_texture_format_t.BGFX_TEXTURE_FORMAT_RGBA8;
    t.resolution.width = 900;
    t.resolution.height = 600;
    bgfx_init(&t);
}

Using bgfx as a static library won't work either - it'll throw tons of errors of undefined references and all around the bgfx/bx/bimg api - I suspected it being a compiler mismatch and I added "dflags-dmd": ["-m64"] but it didn't work either. Cheers!

GoaLitiuM commented 4 years ago

I don't have a Linux system available to test this, but is pd.nwh = &wmi.info.x11.window; actually correct? You probably need to correct it to this: pd.nwh = wmi.info.x11.window;

GoaLitiuM commented 4 years ago

Actually, which API version of bgfx are you using? The latest bgfx master is 108 and the 0.3.1 of the bindings targets 106, and there was some changes in 108 to the initialization structures, which might explain the error if the structs are not in sync.

GoaLitiuM commented 4 years ago

I updated the bindings to target version 108 in case that was the problem.

kyle-vasilia commented 4 years ago

That fixed it for me and allowed for bgfw_init to work and log everything it was able to load! I'm having trouble getting it to bind to the SDL2 window and I suspect the error is close to what you discussed with & not being needed so I will see where I can go with this. - But for now init works fine now without throwing tons of errors. (PS: If anyone has been able to get bindbc bgfx and sdl to work on linux let me know how you did it!)

kyle-vasilia commented 4 years ago

I’m not sure if this is the appropriate way to re-open but has anyone been able to get it to work with bindbc-sdl with anything that uses the x11 win handle passing to platformdata?

kyle-vasilia commented 4 years ago

Got it working - if anyone else wants to see how I did it for reference: https://github.com/kyle-vasilia/DLang-SDL-BGFX