I also have to say that I already fixed it, so I'll post this to help anyone that's getting that error.
The symptom: Complied a test app perfectly, run it outside the debugger and, guess what, everything was over painted with a color!. It was supposed to be shaded grey, with the build-in lights of DirectX 9, but it was shaded, but in red, blue, green, what the computer wanted.
In the debugger, everything ok.
The solution: Afther months of tests and failures, I end up locating the error in the materials. When i loaded a model from a .x and used the materials it worked fine, when I used a shader it worked fine, so it has to be a problem in the materials.
Checked the code, and it was ok.
Afther a while, I check the Start function, and I found out the error
status Start(const Device *dispositivo,DeviceParams Parameters)
{
if(FAILED(DXUTInit( true, true )))
{
::MessageBox(nullptr,L"Error iniciando la aplicación/Error starting the app",L"Error Critico/Critical Error",MB_OK | MB_IConerror);
return Failed;
}
if(FAILED(DXUTCreateWindow(Parameters.WindowName,Parameters.Instance,Parameters.Icon,Parameters.Menu,Parameters.x,Parameters.y)))
{
::MessageBox(nullptr,L"Error iniciando la aplicación/Error starting the app",L"Error Critico/Critical Error",MB_OK | MB_IConerror);
return Failed;
}
if(FAILED(DXUTCreateDevice(Parameters.Windowed,Parameters.Width,Parameters.Heigt)))
{
::MessageBox(nullptr,L"Error iniciando la aplicación/Error starting the app",L"Error Critico/Critical Error",MB_OK | MB_IConerror);
return Failed;
}
dispositivo->InitFlash();
dispositivo->HUD.Init(&dispositivo->g_DialogResourceManager);
dispositivo->HUD.SetCallback(OnGUIEvent);
dispositivo->g_DialogResourceManager.AddFont(Parameters.Font,Parameters.FontHeight,Parameters.FontWeight);
dispositivo->HUD.SetFont( 1,Parameters.Font,Parameters.FontHeight,Parameters.FontWeight);
D3DXVECTOR3 vEyePt( 0.0f, 0.0f,0.0f );
WPARAM keys[8];
keys[0] = Parameters.Camerakeys[0];
keys[1] = Parameters.Camerakeys[0];
keys[2] = Parameters.Camerakeys[0];
keys[3] = Parameters.Camerakeys[0];
keys[4] = Parameters.Camerakeys[0];
keys[5] = Parameters.Camerakeys[0];
keys[6] = Parameters.Camerakeys[0];
keys[7] = Parameters.Camerakeys[0];
float speed,MaxJump,MaxCrouch,NormalHeight;
speed = 0.5;
MaxJump = 0;
MaxCrouch = -1;
NormalHeight = 2;
dispositivo->makeFreeCamera(0,speed,Parameters.InvertY);
dispositivo->SetCurrentCamera(0);
dispositivo->initXACT();
D3DMATERIAL9 temp;
temp.Diffuse = D3DXCOLOR(0.5f,0.5f,0.5f,0.0f);
temp.Ambient = D3DXCOLOR(0.15f,0.15f,0.15f,0.0f);
dispositivo->MakeMaterial(0,temp);
dispositivo->SetResX(Parameters.Width);
dispositivo->SetResY(Parameters.Heigt);
return Completed;
}
Anyone can see something wrong?
I didnt see it at the start.
Then I checked my DirectX reference book.
I looked at the par of materials, and when I saw a picture of the emissive component, I had a revelation.
It looked the same, I wasn't defining the emissive component!
So, I added the emisive, like this:
D3DMATERIAL9 temp;
temp.Diffuse = D3DXCOLOR(0.5f,0.5f,0.5f,0.0f);
temp.Ambient = D3DXCOLOR(0.15f,0.15f,0.15f,0.0f);
temp.Emissive = D3DXCOLOR(0,0,0,0);
and it worked!!
So I learned that DirectX is really a bi**h whit the uninitialized values.
So the moral is, initialize everything, because DirectX will not initialize anything for you!
By guys, till next time.
PS: BTW, as you guys can see I'm working in C++ and DXUT

New Topic/Question
Reply




MultiQuote


|