Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ent_setmesh and LPD3DXMEHS #209749
06/05/08 13:01
06/05/08 13:01
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
hello jcl,

i've got a question: i want to use the sdk to create a dll which replaces a mesh of a given entity. the dll is to be used with a7. the mesh is created with D3DXCreateMeshFVF, the flags are set to D3DXMESH_MANAGED | D3DXMESH_32BIT and the vertex format is the one described in the manual (D3DFVF_TLSHADED). the mesh is then set to the entity via ent_setmesh(entity, mesh, 0, 0). this process works properly.

now, when i delete the mesh, i call mesh->Release() and ent_setmesh(entity, NULL, 0, 0). now, when i have multiple entities sharing the same mesh, i have to call that only for the last entity, obviously. but now, for the last entity, the dll crashes. i took out mesh->Release() and it didn't crash - one time. the next time i tried it crashed again. it also crashed when i just closed the engine window, even though i'm calling Release() for all meshes i created in DLL_PROCESS_DETACH. here again, it worked once by taking out ent_setmesh, crashed again, i took out the Release-stuff and it worked one time but then crashed.

could it be that the error comes from the mesh format, a different dx sdk version (i'm using april 08), or... well, i'm somehow stuck here because sometimes the crash happens in the engine (ent_setmesh) and sometimes in the dll (Release).

i'd be very grateful for any hint you might have.

Re: ent_setmesh and LPD3DXMEHS [Re: Joey] #209760
06/05/08 15:48
06/05/08 15:48
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Call ent_setmesh(entity, NULL, 0, 0) _before_ releasing the mesh - otherwise a crash on release is likely.

Apart from that, I'd also first look for possible reasons in the different mesh format and the different DirectX version. Omit the D3DXMESH_32BIT flag - that will cause crashes on old video cards when the mesh is animated. And try the SDK that A7 is using, that's April 2006.

Re: ent_setmesh and LPD3DXMEHS [Re: jcl] #209773
06/05/08 17:05
06/05/08 17:05
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i've installed the old sdk which made the whole stuff work one time but then crashed again when removing the mesh.

but now i could track down the error, the crashes weren't that random anymore. if i call mesh->Release() after ent_setmesh(entity, NULL, 0, 0) the thing crashes. i tend to think that ent_setmesh already released the mesh. how i can know that? well, if i release the mesh before calling ent_setmesh the latter one crashes, so at least it tries to do something with the old mesh.

i'm not sure, but since the crashes don't occur any more... but i don't want to bloat my memory consumption, neither!

thanks for the hint with the sdk, it helped a lot! the D3DXMESH_32BIT changed nothing, though, and anyway, how are you supposed to create meshes with more than 2^16 vertices without 32 bit indices?

joey.

Re: ent_setmesh and LPD3DXMEHS [Re: Joey] #209779
06/05/08 18:06
06/05/08 18:06
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
and another question, can it be that the engine already deletes meshes when quitting, because when i try to release meshes - which haven't been released before - on DLL_PROCESS_DETACH, the whole stuff crashes again.

Re: ent_setmesh and LPD3DXMEHS [Re: Joey] #209852
06/06/08 08:35
06/06/08 08:35
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
Yes to both. The engine releases all its DirectX objects when it exits, and it also releases its previous mesh when you set a new mesh, or set it to NULL. That's the reason for your release crashes - I should have thought about that.

Re: ent_setmesh and LPD3DXMEHS [Re: jcl] #209894
06/06/08 13:26
06/06/08 13:26
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
ok then i'd like to suggest that you remove the hint in the manual which tells you to release the meshes by yourself.

thanks jcl!

Re: ent_setmesh and LPD3DXMEHS [Re: Joey] #209906
06/06/08 14:26
06/06/08 14:26
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
I rather leave the hint and disable releasing the mesh on ent_setmesh(entity, NULL, 0, 0). The mesh should not be released by that call, but just set to NULL for preventing a release on exit.

Re: ent_setmesh and LPD3DXMEHS [Re: jcl] #209907
06/06/08 14:33
06/06/08 14:33
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline OP
Expert
Joey  Offline OP
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
that's probably better, yes, then we can also use newer directx sdk versions and release our stuff ourselves.


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1