goalitium / bindbc-bgfx Goto Github PK
View Code? Open in Web Editor NEWDynamic and static D bindings for bgfx
License: Boost Software License 1.0
Dynamic and static D bindings for bgfx
License: Boost Software License 1.0
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!
Since D is C-like language, generating D bindings via IDL would be fairly trivial. See example of generating C# bindings:
https://github.com/bkaradzic/bgfx/blob/master/scripts/bindings-cs.lua
By providing IDL script generator for D language, maintenance of your D language package would be drastically simplified.
I am new to bgfx and am trying the D bindings for it. I am just trying to get the sample app given in the readme.md for the bindings to run to verify a good install. I am running bgfx on Ubuntu Linux.
I am using the instructions from https://github.com/GoaLitiuM/bindbc-bgfx/blob/master/readme.md
I added the subconfigurations in my dub.json because I am trying to do static linking
"subConfigurations": {
"bindbc-bgfx": "static"
}
"libs": {
"bgfxRelease", "bxRelease", "bimgRelease"
}
I added the lflag so it could find the .a files :
"lflags": [
"-L/home/user1/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin"
],
and the source code (as supplied by the readme):
import bindbc.bgfx;
// commented out because trying to do static link
// loadBgfx(); // required with dynamically linked bgfx
bgfx_init_t init;
bgfx_init_ctor(&init);
bgfx_init(&init);
bgfx_reset(1280, 720, BGFX_RESET_NONE, init.resolution.format);
bgfx_shutdown();
// commented out because trying to do static link
// unloadBgfx(); // optional, only with dynamically linked bgfx
When I try to do a dub, I get (on linking)...
Performing "debug" build using dmd for x86_64.
bindbc-bgfx 0.4.0+108: target for configuration "static" is up to date.
bindbc-loader 0.3.1: target for configuration "noBC" is up to date.
hellobgfx ~master: building configuration "application"...
Linking...
/usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin/libbgfxRelease.a(renderer_vk.o): in function bgfx::vk::RendererContextVK::submit(bgfx::Frame*, bgfx::ClearQuad&, bgfx::TextVideoMemBlitter&)': /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:5914: undefined reference to
__cxa_guard_acquire'
/usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:5914: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6609: undefined reference to
__cxa_guard_acquire'
/usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6609: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6608: undefined reference to
__cxa_guard_acquire'
/usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6608: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6658: undefined reference to
__cxa_guard_acquire'
/usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6658: undefined reference to `__cxa_guard_release'
and loads and loads of undefineds
Any idea what might be going wrong?
Would you be interested in making bindbc-bgfx an official BindBC package? The only thing is that I would need to transfer the repository to BindBC/bindbc-bgfx, and then you would need to transfer ownership of the dub package to me.
If you think that's not for you, then perhaps we'd still be able to negotiate some way for me to publish an official BindBC bgfx package using the "bindbc-bgfx" name in the dub registry.
I compile bgfx to dll and copy-paste example and get:
Program exited with code -1073741819
The terminal process terminated with exit code: 2
on bgfx_init_ctor(&init);
-
Exception has occurred: W32/0xc0000005
Unhandled exception at 0x0000000000000000 in project_d6.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
and how compile with static lib? I try, but get errors:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
and
bgfx.lib(renderer_d3d9.obj) : error LNK2019: unresolved external symbol __imp_SetWindowPos referenced in function "public: virtual void __cdecl bgfx::d3d9::RendererContextD3D9::requestScreenShot(struct bgfx::FrameBufferHandle,char const *)" (?requestScreenShot@RendererContextD3D9@d3d9@bgfx@@UEAAXUFrameBufferHandle@3@PEBD@Z)
and LINK : warning LNK4217, LINK : warning LNK4286
loadBgfx - not load... loadSDL working
I'm bgfx beginner and may I do something wrong. I tried to copy code from examples and paste it to the my mashine.
By dynamic linking I get:
Program
received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
Program terminated with signal
SIGSEGV, Segmentation fault.
The program no longer exists.
Not implemented stop reason (assuming exception): exited-signalled
By static linking:
Linking...
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o):/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: далее есть ещё неопределённые ссылки на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
collect2: ошибка: выполнение ld завершилось с кодом возврата 1
Error: linker exited with status 1
Error message in Russian means undefined reference in most cases.
In both cases the app terminates on the line:
bgfx_init_ctor(&init);
dub.json (static):
{
"authors": [
"WJ"
],
"copyright": "Copyright © 2020, ME",
"dependencies": {
"bindbc-bgfx": "~>0.5.0",
"bindbc-glfw": "~>0.10.1",
"bindbc-loader": "~>0.3.2"
},
"description": "The test app",
"lflags-linux": [
"-L/home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin"
],
"libs": [
"bgfxRelease",
"bxRelease",
"bimgRelease"
],
"libs-linux": [
"stdc++",
"GL",
"X11"
],
"license": "proprietary",
"name": "app",
"subConfigurations": {
"bindbc-bgfx": "static"
},
"targetPath": "./bin/$PLATFORM",
"targetType": "executable"
}
What's wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.