Open RetroNick2020 opened 2 years ago
QB64 isn't my primary programming language. I made the wrapper as an exercise. However I will try to help.
The code could be something like this:
Type fImage data as _offset width as integer height as integer mipmaps as integer format as integer End Type
Function LoadTextureFromImage(byval fImage as _offset)
The above code would be in the .bi file
Then in your actual program file you could do something like
dim shared myImage as fImage
myImage.data = "" myImage.width=120 myImage.height = 120 myImage.mipmaps=1 myImage.format=1
Call LoadTextureFromImage(myImage)
I'm currently working on a wrapper for Raylib 4.2, it has a much better codebase. Hopefully I helped.
I tried but can't get this to work.
in c/pascal LoadTexture and LoadTextureFromImage return Texture2D structure in QB64 it looks like functions cannot return structure so they return pointer to structure p& = LoadTexture("test.png"+chr$(0)) but passing this to DrawTexture(p&,10,10,_RGBA32(255,255,255,255)) doesn't do anything
I don't know if something else needs to be done here
I'm not sure where you're getting the P& variable. A pointer variable? I just updated the wrapper to Raylib 4.2 yesterday. It has a much cleaner code base.
functions have return values. p& is the return value for the Texture2d
Can you do a simple example showing DrawTexture use?
I am not seeing how you are keeping track of the return values in your bindings.
Ok after playing around with it a bit. It seems when using LoadTexture, it crashes the program at least in my case. I'll see if I can fix this bug. In the meantime try using QB64 built in graphics commands like:
_loadImage() _putImage()
etc.
the qb64 commands work well. I was hoping to take advantage of the camera2d system in raylib to create some demos for rpg and side scrollers.
the camera2d would allow easy upscaling and scrolling. The bulletin graphics commands make this much more work in freebasic and qb64.
On Sat, 27 Aug 2022 at 18:17, Andy @.***> wrote:
Ok after playing around with it a bit. It seems when using LoadTexture, it crashes the program at least in my case. I'll see if I can fix this bug. In the meantime try using QB64 built in graphics commands like:
_loadImage() _putImage()
etc.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
The camera2d should work per se. Raylib passes its structs by value and not pointer. So I wonder if that's the issue. I'm still working on it. I didn't expect the library would be this difficult to make a wrapper it. It works on a basic level to a degree. I also have the sigil library in QB64 and that one works just fine, though not as many features as Raylib has. I'm hoping to fix this issue ASAP.
I did some more reading on QB64 and what you may need to do.
The functions that return an address/pointer to a structure may require some additional steps.
if the function returns the address you may need to take the address and copy the memory+size of structure to a global variable of that type. Then you can pass that variable using _OFFSET(globalvariable) to all the subs/func that require that structure
eg. syntax probably not correct but i think you need something like this
Dim MyTexture As fTexture myt& = LoadTexture("e:\temp\test.png" + Chr$(0)) 'use qb64 memory functions to copy data from myt& address to MyTexture _MEMCOPY(myt&,_OFFSET(MyTexture), size of MyTexture) ' i don't know what exactly this line should be we should be able to display with DrawTexture afterwards Call DrawTexture(_OFFSET(MyTexture), 50, 50, _RGBA32(255, 255, 255, 255))
Sorry for the late reply. After getting some help on the QB64 forums. It seems calling functions from the DLL isn't going to work super well. Due to the way Raylib uses structs. However a new approach is being used by using the source files. Hopefully something more usable will be available soon. Sorry again. In the meantime, my Sigil library works fine.
oh thanks for the update. Take your time. I have other things that i am working on.
On Tue, 30 Aug 2022 at 17:09, Andy @.***> wrote:
Sorry for the late reply. After getting some help on the QB64 forums. It seems calling functions from the DLL isn't going to work super well. Due to the way Raylib uses structs. However a new approach is being used by using the source files. Hopefully something more usable will be available soon. Sorry again. In the meantime, my Sigil library works fine.
— Reply to this email directly, view it on GitHub https://github.com/gAndy50/Qb64Wrappers/issues/2#issuecomment-1232171576, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSAEFOHONTOFU562MIL5QTV3Z2CNANCNFSM57TGLWZA . You are receiving this because you authored the thread.Message ID: @.***>
hi Andy,
now that i have a sort of working raylib in qb64 i want to use LoadTextureFromImage&(myImage) function. myImage is a raylib Image structure/type
This is easy to do in c/pascal with the provided examples.
From QB64 I am not sure what's involved here. it doesn't look like QB64 returns types/ So how do i get Texture2D from this function?