Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HRESULT LoadEffect(LPCWSTR pFileName, ID3D10Effect **ppEffect) {
- UINT HLSLFlags = D3D10_SHADER_ENABLE_STRICTNESS;
- #if defined(DEBUG) | defined(_DEBUG)
- HLSLFlags |= D3D10_SHADER_DEBUG;
- HLSLFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
- #endif
- *ppEffect = NULL;
- ID3D10Blob *pErrors = NULL;
- HRESULT hr;
- D3DX10CreateEffectFromFile(pFileName,
- NULL, // pDefines
- NULL, // pInclude
- "fx_4_0",
- HLSLFlags,
- 0, // FXFlags
- DXUTGetD3D10Device(),
- NULL, // pEffectPool
- NULL, // pPump
- ppEffect,
- &pErrors,
- &hr);
- if (FAILED(hr)) {
- std::wstringstream wss;
- if (pErrors == NULL) {
- wss << L"Unknown error loading shader: \"" << pFileName << "\".";
- } else {
- wss << L"Errors loading shader: \"" << pFileName << "\":\n";
- wss << (CHAR *)pErrors->GetBufferPointer();
- }
- OutputDebugString(wss.str().c_str());
- MessageBox(NULL, wss.str().c_str(), L"Shader Load Error", MB_ICONERROR | MB_OK);
- } else if (pErrors != NULL) {
- std::wstringstream wss;
- wss << L"Warnings loading shader: \"" << pFileName << "\":\n";
- wss << (CHAR *)pErrors->GetBufferPointer();
- OutputDebugString(wss.str().c_str());
- MessageBox(NULL, wss.str().c_str(), L"Shader Load Warning", MB_ICONEXCLAMATION | MB_OK);
- }
- return hr;
- }
Add Comment
Please, Sign In to add comment