danyalzia / DIrrlicht

D Bindings of Irrlicht Engine
Other
7 stars 1 forks source link

Linking to CIrrlicht. irr_IrrlichtDevice_setEventReceiver #9

Open NCrashed opened 10 years ago

NCrashed commented 10 years ago

After https://github.com/Artistic-Games/CIrrlicht/issues/5 there is problem with linking examples:

Building helloworld configuration "application", build type debug.
Compiling...
Linking...
.dub/build/application-debug-linux.posix-x86_64-dmd-C607A04C1FE7239A28C3E1AB907B3EE6/HelloWorld.o: In function `_D9dirrlicht14irrlichtdevice14IrrlichtDevice16setEventReceiverMFC9dirrlicht13eventreceiver14IEventReceiverZv':
/home/ncrashed/dev/d/dirrlicht/examples/01.HelloWorld/../../src/dirrlicht/irrlichtdevice.d:335: undefined reference to `irr_IrrlichtDevice_setEventReceiver'
collect2: error: ld returned 1 exit status
--- errorlevel 1
FAIL .dub/build/application-debug-linux.posix-x86_64-dmd-C607A04C1FE7239A28C3E1AB907B3EE6 HelloWorld executable
Error executing command run: Link command failed with exit code 1
danyalzia commented 10 years ago

Yes, it needs to be updated. Stay there.

danyalzia commented 10 years ago

Actually when I was trying to implement events, I made an attempt to directly interface with C++ IEventReceiver (Dlang can interface with C++ virtual classes), but failed to do so (of course), so I reverted irr_IrrlichtDevice_setEventReceiver to receive C-opaque ptr instead of C++ class ptr in my last commit.

NCrashed commented 10 years ago

I also failed to link directly to C++ classes. Irrlicht has good separation into interfaces and implementations, but there are not pure interfaces. I'll try latest commit (as soon as fix appears).

danyalzia commented 10 years ago

Try with latest commit.

danyalzia commented 10 years ago

Not related to this issue, but tests are failing now.

NCrashed commented 10 years ago

Now examples are compiled normally. But the examples are failing. 01: No model is displayed, empty blue screen, also no gui "Hello World" element. 02: Crashing with:

Irrlicht Engine version 1.9.0
Linux 3.15.7-200.fc20.x86_64 #1 SMP Mon Jul 28 18:50:26 UTC 2014 x86_64
Creating X window...
Visual chosen: : 41
Using renderer: OpenGL 4.4.12967
AMD Radeon HD 7900 Series : ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
Free texture memory (kB): 2620326
Free VBO memory (kB): 2620326
Free render buffer memory (kB): 2620326
GLSL version: 4.4
Could not create archive for: ../../media/map-20kdm2.pk3
Could not load mesh, because file could not be opened: : 20kdm2.bsp
core.exception.AssertError@../../src/dirrlicht/scene/animatedmesh.d(177): Assertion failure
----------------
./Quake3Map() [0x4c974c]
./Quake3Map(dirrlicht.scene.animatedmesh.CAnimatedMesh dirrlicht.scene.animatedmesh.CAnimatedMesh.__ctor(dirrlicht.scene.animatedmesh.irr_IAnimatedMesh*)+0x21) [0x4c9591]
./Quake3Map(dirrlicht.scene.animatedmesh.AnimatedMesh dirrlicht.scene.scenemanager.SceneManager.getMesh(immutable(char)[])+0xa1) [0x4d6061]
./Quake3Map(_Dmain+0x165) [0x4e0065]
./Quake3Map(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+0x1f) [0x4e48a7]
./Quake3Map(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x2a) [0x4e47fa]
./Quake3Map(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()+0x30) [0x4e4860]
./Quake3Map(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x2a) [0x4e47fa]
./Quake3Map(_d_run_main+0x193) [0x4e477b]
./Quake3Map(main+0x25) [0x4e03e5]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x39e9021d65]

Media folder is accessible from current folder (running at examples/bin and media in DIrrlicht root folder).

danyalzia commented 10 years ago

01: What errors/warnings does it give? 02: It is expected, as it also needs the implementation of MAKE_IRR_ID.

NCrashed commented 10 years ago

No errors, the log:

Irrlicht Engine version 1.9.0
Linux 3.15.7-200.fc20.x86_64 #1 SMP Mon Jul 28 18:50:26 UTC 2014 x86_64
Creating X window...
Visual chosen: : 41
Using renderer: OpenGL 4.4.12967
AMD Radeon HD 7900 Series : ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
Free texture memory (kB): 2566118
Free VBO memory (kB): 2566118
Free render buffer memory (kB): 2566118
GLSL version: 4.4
Loaded mesh: ../../media/sydney.md2
Loaded texture: /home/ncrashed/dev/d/dirrlicht/media/sydney.bmp
Quit message received.
danyalzia commented 10 years ago

Hmm, this shouldn't happen, considering the log. Try different driver like BurningsVideo.

danyalzia commented 10 years ago

And what about example 03?

NCrashed commented 10 years ago

There is no example 03, only 04 and it also crashes:

[ncrashed@localhost 04.Movement]$ dub
movement: ["movement"]
Building movement configuration "application", build type debug.
Compiling...
Linking...
Running ./Movement 
Irrlicht Engine version 1.9.0
Linux 3.15.7-200.fc20.x86_64 #1 SMP Mon Jul 28 18:50:26 UTC 2014 x86_64
Creating X window...
Visual chosen: : 41
Using renderer: OpenGL 4.4.12967
AMD Radeon HD 7900 Series : ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
Free texture memory (kB): 2553638
Free VBO memory (kB): 2553638
Free render buffer memory (kB): 2553638
GLSL version: 4.4
Loaded texture: /home/ncrashed/dev/d/dirrlicht/media/wall.bmp
Loaded texture: /home/ncrashed/dev/d/dirrlicht/media/t351sml.jpg
-read ChunkTEXS
read Texture: C:/work/ninja/enemyninja/nskinbl.jpg
Flags: 1
Blend: 2
read Texture: C:/work/ninja/enemyninja/nskinbr.jpg
Flags: 1
Blend: 2
read Texture: C:/work/ninja/enemyninja/nskingr.jpg
Flags: 1
Blend: 2
read Texture: C:/work/ninja/enemyninja/nskinwh.jpg
Flags: 1
Blend: 2
read Texture: C:/work/ninja/enemyninja/nskinrd.jpg
Flags: 1
Blend: 2
-read ChunkBRUS
read Material: Material0
Blend: 1
FX: 0
Layer: 0
using texture: C:/work/ninja/enemyninja/nskinbl.jpg
read Material: Material1
Blend: 1
FX: 0
Layer: 0
using texture: C:/work/ninja/enemyninja/nskinbr.jpg
read Material: Material2
Blend: 1
FX: 0
Layer: 0
using texture: C:/work/ninja/enemyninja/nskingr.jpg
read Material: Material3
Blend: 1
FX: 0
Layer: 0
using texture: C:/work/ninja/enemyninja/nskinwh.jpg
read Material: Material4
Blend: 1
FX: 0
Layer: 0
using texture: C:/work/ninja/enemyninja/nskinrd.jpg
-read ChunkNODE: ROOT
--read ChunkMESH
---ChunkVRTS
---ChunkTRIS
Loaded texture: /home/ncrashed/dev/d/dirrlicht/media/nskinbl.jpg
---ChunkTRIS
--read ChunkANIM
FPS: 0.000000
--read ChunkNODE: Joint1
---read ChunkBONE
---read ChunkKEYS
---read ChunkNODE: Joint2
----read ChunkBONE
----read ChunkKEYS
----read ChunkNODE: Joint3
-----read ChunkBONE
-----read ChunkKEYS
-----read ChunkNODE: Joint4
------read ChunkBONE
------read ChunkKEYS
------read ChunkNODE: Joint5
-------read ChunkBONE
-------read ChunkKEYS
-------read ChunkNODE: Joint6
--------read ChunkBONE
--------read ChunkKEYS
--------read ChunkNODE: Joint7
---------read ChunkBONE
---------read ChunkKEYS
---------read ChunkNODE: Joint8
----------read ChunkBONE
----------read ChunkKEYS
--------read ChunkNODE: Joint9
---------read ChunkBONE
---------read ChunkKEYS
---------read ChunkNODE: Joint10
----------read ChunkBONE
----------read ChunkKEYS
----------read ChunkNODE: Joint11
-----------read ChunkBONE
-----------read ChunkKEYS
-----------read ChunkNODE: Joint12
------------read ChunkBONE
------------read ChunkKEYS
------------read ChunkNODE: Joint13
-------------read ChunkBONE
-------------read ChunkKEYS
-------------read ChunkNODE: Joint29
--------------read ChunkBONE
--------------read ChunkKEYS
--------read ChunkNODE: Joint14
---------read ChunkBONE
---------read ChunkKEYS
---------read ChunkNODE: Joint15
----------read ChunkBONE
----------read ChunkKEYS
----------read ChunkNODE: Joint16
-----------read ChunkBONE
-----------read ChunkKEYS
-----------read ChunkNODE: Joint17
------------read ChunkBONE
------------read ChunkKEYS
----read ChunkNODE: Joint18
-----read ChunkBONE
-----read ChunkKEYS
-----read ChunkNODE: Joint19
------read ChunkBONE
------read ChunkKEYS
------read ChunkNODE: Joint20
-------read ChunkBONE
-------read ChunkKEYS
-------read ChunkNODE: Joint21
--------read ChunkBONE
--------read ChunkKEYS
--------read ChunkNODE: Joint22
---------read ChunkBONE
---------read ChunkKEYS
----read ChunkNODE: Joint23
-----read ChunkBONE
-----read ChunkKEYS
-----read ChunkNODE: Joint24
------read ChunkBONE
------read ChunkKEYS
------read ChunkNODE: Joint25
-------read ChunkBONE
-------read ChunkKEYS
-------read ChunkNODE: Joint26
--------read ChunkBONE
--------read ChunkKEYS
--------read ChunkNODE: Joint27
---------read ChunkBONE
---------read ChunkKEYS
Skinned Mesh - finalize
Loaded mesh: ../../media/ninja.b3d
Loaded texture: /home/ncrashed/dev/d/dirrlicht/media/irrlichtlogoalpha2.tga
Error executing command run: Program exited with code -11

Looks like hided memory corruption, something wrong was passed from D side to backend.

NCrashed commented 10 years ago

Btw, how to change driver in the examples? The original examples wait until you choose driver, the DIrrlicht examples automatically fallback to OpenGL.

danyalzia commented 10 years ago

Yes, I meant example 04. Looks like the inevitable has come. You mentioned that you are on x86_x64, apparently the struct bug isn't really fixed. Did you try compiling with GDC or LDC?

Original Irrlicht use driverChoice.h to get input from user. This can be easily reimplemented in both CIrrlicht and DIrrlicht. I just didn't feel the need to implement it, because I'm focusing on more important things. But if you want to implement, then feel free. You need to change the enum that is being passed to createDevice, DriverType.BurningsVideo would suffice.

danyalzia commented 10 years ago

I've reopened #3 because I'm getting segmentation fault in tests.

NCrashed commented 10 years ago

Yes, I meant example 04. Looks like the inevitable has come. You mentioned that you are on x86_x64, apparently the [struct bug][https://issues.dlang.org/show_bug.cgi?id=5570] isn't really fixed. Did you try compiling with GDC or LDC?

Nasty bug, I'll compile master gdc and try with it.

Original Irrlicht use driverconsole.h to get input from user. This can be easy reimplemented in both CIrrlicht and DIrrlicht. I just didn't feel enough motivated to implement it, because I'm focusing on more important things. But if you want to implement, then feel free. You need to change the enum that is being passed to createDevice, DriverType.BurningsVideo would suffice.

Trying another driver is not so critical now, the CIrrlicht examples operate normally, the problem might be on the D side.

NCrashed commented 10 years ago

With gdc first example operates close to original: model is rendering fine, but no "Hello World" label. The 04 operates as expected.

Problems with DMD could be related to unfound bugs in 2.066-rc2.

danyalzia commented 10 years ago

Problems with DMD could be related to unfound bugs in 2.066-rc2.

That's the unfortunate fact in D language. The language itself is very fun and appealing to create libraries, but the moment you test your library, you realize how buggy the implementation is. GDB doesn't help for internal compiler bugs. I don't see any potential code breaker. Any suggestion/findings?

NCrashed commented 10 years ago

No results. Seems to be a complex bug, I will try again later and if I fail then will ignore and continue with IEventReceiver problem.

danyalzia commented 10 years ago

Now "Hello World" label renders fine. That was a real bug which I fixed in last commit.

danyalzia commented 10 years ago

Example 02 should be fixed now, as I implemented MAKE_DIRR_ID.

danyalzia commented 10 years ago

@NCrashed Any progress yet on events problem? By the way, D has finally got namespace support, so IEventReceiver can potentially be connected directly through extern(C++, irr) because the class is pure virtual.

NCrashed commented 10 years ago

I was releasing daemonize library, so no progress at the moment, but I have a plenty time to dive into the problem now.

IEventReceiver can potentially be connected directly through extern(C++, irr) because the class is pure virtual.

Finally! We need to try this, last time I was stopped by linking errors and some ICE blockers in dmd.

danyalzia commented 10 years ago

Ok. I've started an experimental project from scratch to test it connecting directly with C++ classes, later we can merge the work into main repository if the results turn out to be good. Later we would need to pragmatically use C and C++ interfaces interchangeably wherever it make sense.

danyalzia commented 10 years ago

Just a heads up: I'm using the interfaces from the port for quickly experimenting. The results are quite good sofar; a basic black window can be created now, all have been done without any C code at all.