08-29-2022, 03:44 PM (This post was last modified: 08-29-2022, 04:43 PM by SpriggsySpriggs.
Edit Reason: revelation
)
I haven't read all of your code yet but I'd be willing to bet that some issues will arise from incorrect data types being used in your external function declarations. Every FUNCTION you've declared from the external libraries are set to use SINGLE as the return type. Also, according to the Wiki, C/C++ float is a SINGLE in QB64 so you will need to clean up a lot of TYPE and function declarations to use the proper data type. I see a lot of declarations using INTEGER. In C/C++, an int corresponds to a LONG in QB64. I'm not sure what the original declarations were but if they were int then they should be LONG. If they were int16 then you're fine. I haven't checked, but make sure any string passed to an external function is ended with a CHR$(0) so as to null-terminate the string. Before you move any further with the project, I'd check and fix the above to make sure these aren't hindering your progress.
Good luck!
P.S.
I just noticed that you're passing the value from RGBA32 to your fColor argument. The DrawTexture function expects a struct of Color but you're passing an UNSIGNED LONG value. https://www.raylib.com/cheatsheet/cheatsheet.html
P.P.S
If I have free time and I don't forget, I might download your BI file and try running it myself. If I get real ambitious, I'll make any change that would make your code be consistent with how I'd declare libraries and see if it resolves your issues. No promises, though.
P.P.P.S
"Option Explicit" is your friend. Make sure you explicitly declare each and every variable you use. This might seem inconvenient for a BASIC language but it prevents many hiccups. I don't write any code without it and I declare every variable even if it's a temp variable that will be disposed in the very next line.
P.P.P.P.S
I see that your fColor struct declaration is using UNSIGNED LONG as the data type for its members. You should instead be using UNSIGNED BYTE as the min value would be zero and the max value should not exceed 255. Your struct, as it currently stands, is 4 times as large as it should be.
Because I was tired and bored, I decided to take a dive into this. I think I'll have a new BI file to give to you by the end of the day. However, it will require you to rewrite any sample code you wrote to test what you have so far since the declarations will have drastically changed.
(08-29-2022, 07:13 PM)Spriggsy Wrote: Because I was tired and bored, I decided to take a dive into this. I think I'll have a new BI file to give to you by the end of the day. However, it will require you to rewrite any sample code you wrote to test what you have so far since the declarations will have drastically changed.
Thanks so much. I did my best to try and make a wrapper for Raylib. The variable convertion and structs were kinda getting at me, but I tried to get it as QB as compatible as I thought it could be.
08-30-2022, 02:43 AM (This post was last modified: 08-30-2022, 02:47 AM by SpriggsySpriggs.)
I'm still working on building this BI. Can't guarantee that all functions will work since some return structs. I've declared these as returning offsets with the hope that we can use MEM to retrieve the struct that way. That will require me helping you with some of the functions when it comes time. I've got about 200 more lines in this header file to recreate in my BI file. I'll upload it here as soon as I'm done.
By the way, I notice that Raylib uses UTF-8 encoding in some functions so you might need to use my UnicodeToAnsi library so you can convert to and from UTF-8 on the fly.
(08-30-2022, 02:43 AM)Spriggsy Wrote: I'm still working on building this BI. Can't guarantee that all functions will work since some return structs. I've declared these as returning offsets with the hope that we can use MEM to retrieve the struct that way. That will require me helping you with some of the functions when it comes time. I've got about 200 more lines in this header file to recreate in my BI file. I'll upload it here as soon as I'm done.
By the way, I notice that Raylib uses UTF-8 encoding in some functions so you might need to use my UnicodeToAnsi library so you can convert to and from UTF-8 on the fly.
Thanks again. Raylib is written in C99, so I didn't think it'd be super hard to wrap. I didn't have really any trouble when I made a wrapper for Sigil for QB64. Then again QB64 isn't my main programming language, but any programming is good for practice.
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.
DIM SHARED tex AS fTexture
tex.id = 0
tex.xwidth = 50
tex.height = 50
tex.mipmaps = 0
tex.format = 0
tex& = LoadTexture("dw2.png")
here I see 2 kind of variable with the same name...
it is not a good practice to do this...
1 please use _Option Explicit, it saves your time and concentration at the price to declare every variables
2 correct the correlate data type as Spriggs pointed out (I fall often in this kind of misunderstandment because I use too few C language)
3 Does the raylib work like OpenGL (you must redraw everytime the screen)? Otherwise I should prefer to put out of the loop DO the calling for initialization and deallocation of resources OR to put a _LIMIT to the loop.