a740g / raylib-64

QB64-PE bindings for raylib (a simple and easy-to-use library to learn videogames programming)
https://qb64phoenix.com/forum/showthread.php?tid=1776
MIT License
6 stars 2 forks source link

thanks #1

Closed RetroNick2020 closed 1 year ago

RetroNick2020 commented 1 year ago

No issues (yet) - just wanted to say thanks for doing this. I tested other bindings and they did not work beyond creating a simple screen.

I will test when i get some free time.

a740g commented 1 year ago

You are welcome! This binding took a lot of thinking and work because of the limitations of the QB64 language. Still, whatever I have tested so far seems to work. However, I had to fix a lot of things during my testing because my auto-gen code was really simple. A lot more remains to be tested. If you discover any issues / bugs, then please feel free to open a GitHub issue or a PR.

RetroNick2020 commented 1 year ago

I tried to do a binding myself for qb64 and discovered very quickly that my knowledge of qb64 and C were not good enough. So I'm glad you stepped up and did it. not related to raylib but is there a way to link/access external C variables in an OBJ file from QB64?

a740g commented 1 year ago

not related to raylib but is there a way to link/access external C variables in an OBJ file from QB64?

It is possible, but not directly. The object file needs to be GCC compatible because that is what QB64 uses. So, it must be a .o (object file) or a .a (library file). Once we have the files, we need to write a tiny C header file which will help us access the exported variable.

For example: my_lib.h

#if defined(__cplusplus)
extern "C" {               // prevents name mangling of functions
#endif

extern int my_lib_version; // this lives inside the object file

#if defined(__cplusplus)
}
#endif

inline int get_my_lib_version() {
    return my_lib_version;
}

On the QB64 side, this can be used as: my_lib.bi

Declare Static Library "my_lib"
    Function get_my_lib_version&
End Declare

Declare Static Library "my_object" ' this is the name of the object file
    Function some_fuction(ByVal v As Long)
    Sub some_sub(ByVal v As Long)
End Declare

This is all from memory. But I am quite sure this is the way. 😊