编写代码时出现如下错误:
“const wchar t*”类型的参数与“WCHAR *”类型的参数(又名“wchar_t *”)不兼容
代码:
m_compileshaderfromfile(L"shader.fx", "VS", "vs_4_0", &pVSBlob);
我使用Microsoft Visual Studio 2022,编码是Unicode。像这样尝试过:
代码:
const char* filenamestr = "shader.fx";
WCHAR filename[256];
MultiByteToWideChar(CP_UTF8, 0, filenamestr, -1, filename, sizeof(filename) / sizeof(WCHAR));
m_compileshaderfromfile(filename, "VS", "vs_4_0", &pVSBlob);
但随后shader.fx无法编译。它可能找不到该文件。一般情况下,它返回 0。shader.fx位于包含可执行文件的文件夹中。发布配置。函数声明:
HRESULT m_compileshaderfromfile(WCHAR* FileName, LPCSTR EntryPoint, LPCSTR ShaderModel, ID3DBlob** ppBlobOut);
屏幕:
