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

Problem loading an effects file

Started by discodowney Mar 22, 2011 at 3:50 PM 3 replies 1.1k views
Original Post
discodowney
discodowney
Im trying to make a particle system. It uses shaders. Its the one from the book "Introduction to 3D Game Programming with Directx9.0c  a Shader Approach" by Frank Luna.
I load in the effects file with the following



ID3DXBuffer* errors = 0;
hr = D3DXCreateEffectFromFile(Device, fxName.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &mFX, &errors);
if( errors )
MessageBox(0, (char*)errors->GetBufferPointer(), 0, 0);


When i debug i get an error on the errors attribute that says "Error: expression cannot be evaluated". the hr thing there is a problem for me as well. I made a post about that here:[color=#1C2837][size=2]http://www.gamedev.net/topic/597696-hrtrace-directx-11/page__p__4786036#entry4786036. I dont really understand what Erik meant in his replay. But making having hr = meant i could compile and run the code (i know how stupid it is to do that, but i was going to quick for my own good at the time). Could this be causing a problem? though mFX doesnt have the Error: expression cannot be evaulated. That seems to have a value alrigh

Next in my code i try to do the Gets for the effects file:


mhTech= mFX->GetTechniqueByName(techName.c_str());
mhWVP = mFX->GetParameterByName(0, "gWVP");


But while debugging after each one i see each mh (mhTech, mhWVP, etc) has Error: expression cannot be evaluated. I assume this means that the efffects file didnt load properly and so anything using mFX is gonna mess up. So anyone know what is causing this. Or if it is my use of hr does anyone know how to fix this?

EDIT: I get the Error: expression cannot be evaluated before the code even executes on them "mhxxxx" variables. Thats not normal is it? I have them defined as D3DXHANDLE mhTech; Or are they a bad pointer cos Handles just are like that until they are given a value?

Cheers.
Aqua Costa
Aqua Costa
Check if hr == S_OK; or E_FAIL...

Also are you writing & and ->? or it was an error when you posted your code?
discodowney
discodowney

Check if hr == S_OK; or E_FAIL...

Also are you writing & and ->? or it was an error when you posted your code?


nah that & and > was an error with the editor.

Its returning S_OK. Thats strange. So any idea why the mhxxx are returning an error?
discodowney
discodowney
Bump - anyone any ideas?
Buckeye
Buckeye
I get the Error: expression cannot be evaluated before the code even executes on them "mhxxxx" variables. Thats not normal is it? I have them defined as D3DXHANDLE mhTech; Or are they a bad pointer cos Handles just are like that until they are given a value?[/quote]
To get a clear idea of what's going on, rather than describing your code sequence, post the code and indicate where you get what errors.

Do you mean that the messagebox pops up with the "Error" message you describe? If so, do you continue execution, trying to get handles? If that's the sequence, you shouldn't just continue execution when you get an error. You should handle the error - something like returning from whatever function that code is in and quit the application.

Also, use the FAILED macro with the HRESULT returned from the D3DXCreateEffect function in addition to checking the error buffer. Give yourself as much information as possible. For instance, you can use DXGetErrorDescription(...) to provide more info.

Does the Debug Runtime provide any additional information?

EDIT: If the message box is giving you that message, then it's likely the effect file can't be compiled. There's an expression in the fx file it can't evaluate (like the message says).

EDIT2: What version of DirectX are you using?
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly. You don't forget how to play when you grow old; you grow old when you forget how to play.

Topic Locked

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

Sign in to reply to this topic.