Need Help to wrap Xors3d.dll

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
Bagamut
Posts: 7
Joined: Jul 29, 2010 21:28
Location: Russia, Murmansk
Contact:

Need Help to wrap Xors3d.dll

Post by Bagamut »

Hello Everybody!

A few days ago i start wrapping Xors3D engine. Cause i don't have much experience in programming in FreeBasic i have some problems with it. I have 2 versions of wrapper: 1st - with *.bas file (my old version, using DylibSymbol() functions); 2nd - with *.bi file (using declare).

First version of my wrapper working fine, but i think it's not good choice to wrap functions. With Second version i have some problems - the my_example.bas successfully compiled, but then window open i have a error.

If someone can help me plz reply.

Here a wrappers!
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

I noticed some things in your code:

1. Are you sure the DLL uses C Decl? From the aliases it seems that they use Stdcall (it has @n in the end), so you don't need them.

Code: Select all

' ...
Extern "c"
' ...
Declare Function xGraphics3D Alias "_xGraphics3D@20" (_
                             ByVal scr_width As Integer = 640,_
                             ByVal scr_height As Integer = 480,_
                             ByVal scr_depth As Integer = 16,_
                             ByVal scr_mode As Integer = 0,_ 
                             ByVal scr_vsync As Integer = 0) As Integer
' ...
End Extern
' ...
to:

Code: Select all

' ...
Declare Function xGraphics3D (_
                             ByVal scr_width As Integer = 640,_
                             ByVal scr_height As Integer = 480,_
                             ByVal scr_depth As Integer = 16,_
                             ByVal scr_mode As Integer = 0,_ 
                             ByVal scr_vsync As Integer = 0) As Integer
' ...
2. Where's libxors3d.dll.a/libxors3d.a ? You need this file when linking using #inclib's. If you don't have one, I'll tell you how.
Bagamut
Posts: 7
Joined: Jul 29, 2010 21:28
Location: Russia, Murmansk
Contact:

Post by Bagamut »

Galeon wrote:I noticed some things in your code:

1. Are you sure the DLL uses C Decl? From the aliases it seems that they use Stdcall (it has @n in the end), so you don't need them.

Code: Select all

' ...
Extern "c"
' ...
Declare Function xGraphics3D Alias "_xGraphics3D@20" (_
                             ByVal scr_width As Integer = 640,_
                             ByVal scr_height As Integer = 480,_
                             ByVal scr_depth As Integer = 16,_
                             ByVal scr_mode As Integer = 0,_ 
                             ByVal scr_vsync As Integer = 0) As Integer
' ...
End Extern
' ...
to:

Code: Select all

' ...
Declare Function xGraphics3D (_
                             ByVal scr_width As Integer = 640,_
                             ByVal scr_height As Integer = 480,_
                             ByVal scr_depth As Integer = 16,_
                             ByVal scr_mode As Integer = 0,_ 
                             ByVal scr_vsync As Integer = 0) As Integer
' ...
No I'm not sure, but when i delete "Extern "c" / End Extern" debuger output:

Code: Select all

D:\Program Files\FreeBASIC\fbc -s gui "test_xors_bi.bas"
test_xors_bi.o:fake:(.text+0x28): undefined reference to `_xAppTitle@4@4'
test_xors_bi.o:fake:(.text+0x3d): undefined reference to `_xGraphics3D@20@20'
test_xors_bi.o:fake:(.text+0x42): undefined reference to `_xBackBuffer@0@0'
test_xors_bi.o:fake:(.text+0x48): undefined reference to `_xSetBuffer@4@4'
test_xors_bi.o:fake:(.text+0x4f): undefined reference to `_xCreateCube@4@4'
test_xors_bi.o:fake:(.text+0x6e): undefined reference to `_xScaleEntity@20@20'
test_xors_bi.o:fake:(.text+0x8a): undefined reference to `_xPositionEntity@20@20'
test_xors_bi.o:fake:(.text+0x9b): undefined reference to `_xEntityColor@16@16'
test_xors_bi.o:fake:(.text+0xa5): undefined reference to `_xEntityFX@8@8'
test_xors_bi.o:fake:(.text+0xac): undefined reference to `_xCreateCamera@4@4'
test_xors_bi.o:fake:(.text+0xc5): undefined reference to `_xCameraViewport@20@20'
test_xors_bi.o:fake:(.text+0xdc): undefined reference to `_xCameraClsColor@16@16'
test_xors_bi.o:fake:(.text+0xe8): undefined reference to `_xCameraClsMode@12@12'
test_xors_bi.o:fake:(.text+0x104): undefined reference to `_xPositionEntity@20@20'
test_xors_bi.o:fake:(.text+0x10b): undefined reference to `_xCreateLight@4@4'
test_xors_bi.o:fake:(.text+0x12a): undefined reference to `_xPositionEntity@20@20'
test_xors_bi.o:fake:(.text+0x131): undefined reference to `_xKeyHit@4@4'
test_xors_bi.o:fake:(.text+0x151): undefined reference to `_xTurnEntity@20@20'
test_xors_bi.o:fake:(.text+0x15c): undefined reference to `_xUpdateWorld@4@4'
test_xors_bi.o:fake:(.text+0x169): undefined reference to `_xRenderWorld@8@8'
test_xors_bi.o:fake:(.text+0x16e): undefined reference to `_xFlip@0@0'
Galeon wrote:2. Where's libxors3d.dll.a/libxors3d.a ? You need this file when linking using #inclib's. If you don't have one, I'll tell you how.
No, I don't have "libxors3d.dll.a / libxors3d.a" libs and i don't know how to create it.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

Wait, trying to help you... :)
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

I was able to compile it, but my computer asks for d3dx9_36.dll because it can't be found. I think I have an older DirectX. I already have the *.a file and no errors showed up after compiling it.
Bagamut
Posts: 7
Joined: Jul 29, 2010 21:28
Location: Russia, Murmansk
Contact:

Post by Bagamut »

Galeon wrote:I was able to compile it, but my computer asks for d3dx9_36.dll because it can't be found. I think I have an older DirectX. I already have the *.a file and no errors showed up after compiling it.
Could you upload a libs (*.a) files?
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

Wait, I'm uploading it now

Edit: Here it is with all the files. I edited the *.bi file.
http://wargaleon.users.sourceforge.net/ ... xors3d.zip

I got connection problems while uploading it.

Tell me if it works.

Edit: I removed some files because I can't upload it.

Edit: I upgraded my DirectX and it seems not to work.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

Wah! Already fixed it! Still uploading new files...
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

Creating a *.dll.a file:

Code: Select all

pexports xors3d.dll > xors3d.def
dlltool.exe -U -l libxors3d.dll.a -D xors3d.dll -d xors3d.def
pexports is from MinGW.
dlltool is included with FreeBASIC

pexports will spit a def file which contains the exported symbols.

As you have noticed, it exported its functions with @n in the end, so it is using stdcall. You should use 'Extern "Windows"' instead of 'Extern "C"'. The included headers already have them fixed. It also adds underscores, which is uncommon, that's what -U in dlltool for. Because you're using Extern blocks, you don't need the Alias'es.

dlltool will create an import library (*.a) for you.

http://wargaleon.users.sourceforge.net/ ... xors3d.zip
Same URL, I just replaced the *.dll.a file.
Bagamut
Posts: 7
Joined: Jul 29, 2010 21:28
Location: Russia, Murmansk
Contact:

Post by Bagamut »

Galeon wrote:Creating a *.dll.a file:

Code: Select all

pexports xors3d.dll > xors3d.def
dlltool.exe -U -l libxors3d.dll.a -D xors3d.dll -d xors3d.def
pexports is from MinGW.
dlltool is included with FreeBASIC

pexports will spit a def file which contains the exported symbols.

As you have noticed, it exported its functions with @n in the end, so it is using stdcall. You should use 'Extern "Windows"' instead of 'Extern "C"'. The included headers already have them fixed. It also adds underscores, which is uncommon, that's what -U in dlltool for. Because you're using Extern blocks, you don't need the Alias'es.

dlltool will create an import library (*.a) for you.

http://wargaleon.users.sourceforge.net/ ... xors3d.zip
Same URL, I just replaced the *.dll.a file.
I tested and all working good with no bugs. Thanks!!! Tonight, I can continue to develop the Xors3D wrapper.
JaDogg
Posts: 345
Joined: Apr 13, 2008 12:11
Location: Sri Lanka - Negombo
Contact:

Post by JaDogg »

wow this lib is amazing and the functions called similar to FB
(like 'ScreenRes' and 'xGraphics3D' ....)
JohnK
Posts: 279
Joined: Sep 01, 2005 5:20
Location: Earth, usually
Contact:

Post by JohnK »

Isn't this a commercial library. That is with the wrapper the user still has to pay the cost of the DLL?

-JK
Prime Productions
Posts: 147
Joined: May 24, 2009 23:13
Location: Texas, United States, Planet Earth
Contact:

Post by Prime Productions »

JohnK wrote:Isn't this a commercial library. That is with the wrapper the user still has to pay the cost of the DLL?

-JK
Correct. They do have a 30 minute timer trial version, however.

Still, it is nice to see more and more libraries wrapped into FB. For those who want to buy it, it is nice to know they can use it in FB.

David
lass
Posts: 2
Joined: Apr 05, 2017 0:52

Re: Need Help to wrap Xors3d.dll

Post by lass »

Hi

This is th latest wrapper of Xors3D (latest DLL build of august 2012)
it adds many functions and subs especially the xcolor with alpha value (now you can draw transparent rectangles and text)
I added a helpfile for all the functions.

NB : for some reason to get this to work , you must remove the xphysics.dll file from the running folder! i dont know why the program hungs if you keep it.
you shall remove also any previous version (libxors3d.dll.a and xors3d.bi)


Test it and please feedback

for the keys => https://www.blitzbasic.com/Community/po ... pic=106322

Download Wrapper:http://www.megafileupload.com/3sb9j/xors3dN.rar

Enjoy
Post Reply