Raylib Wrapper Help - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Works in Progress (https://staging.qb64phoenix.com/forumdisplay.php?fid=9) +---- Thread: Raylib Wrapper Help (/showthread.php?tid=820) |
RE: Raylib Wrapper Help - LeftyG - 08-30-2022 (08-30-2022, 05:00 AM)Spriggsy Wrote: Here is my version of the BI file. Took forever to make. Again, can't guarantee how much will actually work. There's just far too much to test. But you can revise your sample code and run it against my version and I do believe you'll get some better results. Thank you so much! I notice for strings you have them as BYVAL _title as _offset, shouldn't they be strings if they are strings? RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 I typically pass strings to external libraries as _OFFSET. This isn't something you necessarily have to do but I feel safer doing it. It kind of forces you to declare your string variable and then it makes you remember to also null-terminate it with a CHR$(0). Whether you do it as a BYVAL _OFFSET or just STRING, the result is the same, provided you still null-terminate. I only do it this way for consistency, since the reference code shows these strings as pointers to strings. Also, I have set the BI to use $CONSOLE:ONLY since you will have no need for a QB64 window in your binary. Also, Raylib outputs some handy-dandy information to the console for debugging. Will be quite helpful, I'm sure. I would offer more assistance with using the BI file and functions but, unfortunately, I'm not a graphics person so I'm not too familiar with this library. However, if you find some C code that you want to replicate using this library, I can probably get it to at least work a little bit. Maybe. No guarantees Also, regarding the strings being passed as _OFFSET.... Believe it or not, it makes it that much easier to deal with the strings with external libraries, especially when one has a mixture of UTF-8 and ANSI. Rather trivial to convert a pointer to a string in QB64 and I do it quite often. Below is some code I use but there are actually a few different ways to get the string content of an OFFSET Code: (Select All) $If PTRTOSTR = UNDEFINED Then In the above code, PointerToWideString is used to convert an OFFSET which references a unicode string. PointerToString is used to convert an OFFSET which references an ANSI string. RE: Raylib Wrapper Help - LeftyG - 08-30-2022 (08-30-2022, 05:37 AM)Spriggsy Wrote: I typically pass strings to external libraries as _OFFSET. This isn't something you necessarily have to do but I feel safer doing it. It kind of forces you to declare your string variable and then it makes you remember to also null-terminate it with a CHR$(0). Whether you do it as a BYVAL _OFFSET or just STRING, the result is the same, provided you still null-terminate. I only do it this way for consistency, since the reference code shows these strings as pointers to strings. Also, I have set the BI to use $CONSOLE:ONLY since you will have no need for a QB64 window in your binary. Also, Raylib outputs some handy-dandy information to the console for debugging. Will be quite helpful, I'm sure. I would offer more assistance with using the BI file and functions but, unfortunately, I'm not a graphics person so I'm not too familiar with this library. However, if you find some C code that you want to replicate using this library, I can probably get it to at least work a little bit. Maybe. No guarantees Thanks for all your help. I really appericate. As of right now I'm trying to convert this example into QB64 code. https://github.com/raysan5/raylib/blob/master/examples/textures/textures_logo_raylib.c Code: (Select All) REM $include: 'raylib.bi' RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 You're using myTex incorrectly. You can't use the return from LoadTexture directly as a Texture "object". myTex& is a different variable from myTex. The ampersand (&) means LONG. So the IDE thinks you have an undeclared variable called myTex, which is a long. I'm going to have to look at that example and see what can be done. Even if you could use the struct in such a way, you'd be overwriting anything you set in the myTex declaration when you assigned it to the value of LoadTexture. RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 Depending on how this goes, we might have to make a double wrapper. One that is a C header that takes these functions and makes them return a pointer to the struct object rather than return the struct directly. We'll see. Let me look at this today and I'll let you know. This might require you to spend a great deal of time on. RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 Quote:INFO: Initializing raylib 4.2So, for some reason, the texture refuses to load. You must use LoadTexture only after first initializing the window with InitWindow. I've done that. However, it still refuses to load. When I look up the error about the failure to open the file, I'm told it is because the texture either doesn't exist or I'm loading it before I've called InitWindow. They're wrong, of course. Perhaps the OpenGL side of QB64 is causing an issue with trying to use Raylib, which also uses OpenGL. I tried passing a Unicode string but the program crashed. So, I'll have to do some more digging to find compatible strings for this library. RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 I haven't had a chance to try it but I think these functions will assist us with the issue of the texture loading. I'll give it a try later if I have time. Code: (Select All) Function AsciiToUtf8byte$ (c As _Unsigned _Byte) RE: Raylib Wrapper Help - LeftyG - 08-30-2022 Thanks for all of your help. I did not think wrapping a C library would prove to be so difficult. RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 (08-30-2022, 06:38 PM)LeftyG Wrote: Thanks for all of your help. I did not think wrapping a C library would prove to be so difficult. You're welcome. It's not so much that wrapping a C library is difficult as it is that this library in particular just has so many parts and is extremely complex (in comparison to others I've dealt with). RE: Raylib Wrapper Help - SpriggsySpriggs - 08-30-2022 So, it turns out that the ASCII to UTF8 functions were a bust. They didn't help at all. I'm going to dive a bit deeper when I can and see if we can just use the source files from Raylib instead of the DLL. If we can, then I'm going to program as 64 bit because I abhor 32 bit and avoid it when possible. |