Skip to main content
GameDev.net gamedev.net
🔒 Locked

ID3DXEffect::CloneEffect

Started by fagiano Jul 11, 2004 at 4:38 AM 3 replies 1.2k views
Original Post
fagiano
fagiano
Hi all, I'm trying to integrate effects files in my engine. What I'm doing is: a)every time a effect is loaded I compile it and store the ID3DXEffect generated as template in my resource map. b)every time a new object requires the same effect, I clone the template and store into the engine object instance. The problem is that every time I try to call ID3DXEffect::Begin() in the cloned object, I have a crash in the D3DX runtime dll. If I use the original effect returned by D3DXCreateEffect() everything works properly. Is there anything special I have to do to have a working cloned effect? right now I'm not trying to share any parameter. basically I do:

D3DXCreateEffect(...,&pTemplate)
//store the pointer in my resource map

...when I want a new instance
pTemplate->CloneEffect(pEffect);
//pass the template to the obejct instance

... in the rendering loop
pEffect->Begin(&passes,0); //crash here !!!!

pEffect->Pass(n);

pEffect->End();
ciao Alberto
-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org
Muhammad Haggag
Muhammad Haggag
Quote:
Original post by fagiano
...when I want a new instancepTemplate->CloneEffect(pEffect);

I'm not sure if this is a typo or what, but this should be:
pTemplate->CloneEffect(&pEffect);


CloneEffect takes the address of an interface pointer.

Muhammad Haggag
Muhammad Haggag
By the way, linking to the debug D3DX library will probably tell you what's going wrong. The library is d3dx9d.lib (or d3dx9dt.lib, don't remember. Check the FAQ)

fagiano
fagiano
Quote:
Original post by Coder
Quote:
Original post by fagiano
...when I want a new instancepTemplate->CloneEffect(pEffect);

I'm not sure if this is a typo or what, but this should be:
pTemplate->CloneEffect(&pEffect);


CloneEffect takes the address of an interface pointer.


sorry... my snippet was some kind of pseudo code is not the actual code I'm using.
-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org
EverIce
EverIce
"b)every time a new object requires the same effect, I clone the template and store into the engine object instance. " - hmm, why are you doing this? I've already implementated dx effects in my engine. I'm sorting graphical units by effects.

effect->begin();

n render

effect->end();

switch to another effect, etc.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.