Original Post
Greetings all, I'm a long time reader yet first time poster on the forums so thought I'd best start with a hello. :)
Alas, my first post does however come aside a question with regards to the HLSL. I have managed to get the HLSL working should I explicitly specify which techniques are to be loaded and when; the aim of my program however is based around strict component based design, allowing the users (other programmers) to modify and add to the engine thus, explicit specifications are a currently unwanted biproduct of my problem.
I currently have my effects stored as part of a vector of structs:
I am then attempting to load a new effect via an 'add' method for the vector...the beginning code is as follows:
Following this, I have attempted to iterate through each effect technique in two different ways:
1:
2:
Both of the above attempts respond by returning a bad pointer...the first with the description will find two techniques and iterate correctly yet return a bad pointer for each, the second will get stuck in an infinite loop as the HRESULT is always S_OK.
Does anyone happen to have any ideas of where I'm potentially going wrong or for alternative workthroughs for the problem?
Thanks for your time...
Alas, my first post does however come aside a question with regards to the HLSL. I have managed to get the HLSL working should I explicitly specify which techniques are to be loaded and when; the aim of my program however is based around strict component based design, allowing the users (other programmers) to modify and add to the engine thus, explicit specifications are a currently unwanted biproduct of my problem.
I currently have my effects stored as part of a vector of structs:
//Loaded effects objects and their associated parts.struct D3EFFECT_BUFFER{ LPD3DXEFFECT effect; //Main effects object. string fileNameID; //Effects file location. vector<D3DXHANDLE> *techniques; //Techniques present for the effect object. //Constructor for the struct. D3EFFECT_BUFFER(){ effect = NULL; //Default the effect object to NULL; techniques = new vector<D3DXHANDLE>; //Default, create the vector for use. }}; vector<D3EFFECT_BUFFER> *vpv_dbEffects;I am then attempting to load a new effect via an 'add' method for the vector...the beginning code is as follows:
//Adds a new effect object to the 'vpv_dbEffects' vector.HRESULT DeviceGfx::dbEffectAdd(const string &fileName){ //Check to see if the vector is valid. If not, create it. if(vpv_dbEffects == NULL) vpv_dbEffects = new vector<D3EFFECT_BUFFER>; //Create the effect from file in accordance with the fileName. D3EFFECT_BUFFER* newEffect = new D3EFFECT_BUFFER(); if(FAILED(D3DXCreateEffectFromFile(v_d3dDevice, fileName.c_str(), NULL, NULL, NULL, NULL, &newEffect->effect, NULL))) return DDIS_ERR; newEffect->fileNameID = fileName;Following this, I have attempted to iterate through each effect technique in two different ways:
1:
D3DXEFFECT_DESC desc;newEffect->effect->GetDesc(&desc);for(int x = 0; x < desc.Techniques; x(plusplus...code tags don't like the symbol here :()) newEffect->techniques->insert(newEffect->techniques->end(), newEffect->effect->GetTechnique(x));2:
HRESULT hr = D3D_OK;D3DXHANDLE tech;hr = newEffect->effect->FindNextValidTechnique(NULL, &tech);while(hr == D3D_OK){ newEffect->techniques->insert(newEffect->techniques->end(), tech); hr = newEffect->effect->FindNextValidTechnique(NULL, &tech);}vpv_dbEffects->insert(vpv_dbEffects->end(), *newEffect);Both of the above attempts respond by returning a bad pointer...the first with the description will find two techniques and iterate correctly yet return a bad pointer for each, the second will get stuck in an infinite loop as the HRESULT is always S_OK.
Does anyone happen to have any ideas of where I'm potentially going wrong or for alternative workthroughs for the problem?
Thanks for your time...