bgfx.nim icon indicating copy to clipboard operation
bgfx.nim copied to clipboard

{.cdecl.} for bgfx_release_fn_t

Open danieloff opened this issue 5 years ago • 2 comments

Howdy! Great work! Thanks! I got a little rotating cube demo working at home, but for it to work I just had to tweak a couple things:

  • the bgfx_release_fn_t proc callback needed a "{.cdecl.}" on it
  • for compiling with --threads:on I got a conflict with the "small" parameter name that is used a couple times, I just changed the spelling to smallr and it worked fine. Not sure if others would encounter that.

This was on windows with a recent bgfx shared dll built with visual studio 2017 and using the vcc compiler option with nim. Also just curious how you generate the wrapper? Thanks again.

danieloff avatar Jun 03 '19 22:06 danieloff

Hi @danieloff - sorry for the late reply. I just moved across the world and was getting settled into my new place. Thank you for pointing that out about bgfx_release_fn_t. I've actually never used that function to my recollection - I've just always gotten away with using Nim's createShared freeShared. I also haven't tried using threads before with bgfx, but if you'd like to create a PR for these fixes, I'd happily accept it. Otherwise I will do so myself later this week.

As far as generating the wrapper goes - quite a bit was done manually. I basically ran the c99 bgfx header file through the gcc preprocessor and then ran that file through c2nim, commenting out whatever sections of code game me problems. Then it was manual fixes moving forward.

If you don't mind me asking / sharing what you're working on with bgfx - I'd love to see!

zacharycarter avatar Jun 24 '19 03:06 zacharycarter

no worries @zacharycarter ! I want to make some games for fun and profit. The world needs more good racing games :). I work in c++ for my day job so I wanted to do my free time code in a different language. I like nim but I'm still fairly beginner at it. Just noticed that cdecl as I was trying to duplicate the bgfx cpp example structure I think. I got the grid of rotating cubes working using your wrapper, but drawing a textured quad I still have no luck. Just a black square. I had modified the csfml repo/nim-csfml wrapper to allow the new context-less mode of sfml window construction. I was going to see if bgfx+csfml would be a fun combo. Like I said I got the colored cubes rotating but textures still elude me. Recently I've been poking around trying to find what I did wrong, but I haven't figured it out yet. I know the texture is getting into memory correctly because I can fiddle with the bits and save it out -> works, but it is not showing on my quad. I also got a working textured cube up using the nim vulkan wrapper, so I may go further with that and get some better bearings on how this graphics stuff works. When I have something worthwhile to put up I'll be sure to make it public :).

Thanks! Good luck in your new digs!

danieloff avatar Jun 24 '19 23:06 danieloff