DirectX 9 着色器未显示错误
DirectX 9 Shader not displaying errors
我正在研究DirectX9和着色器,我正在使用以下代码:
D3DXCreateEffectFromFile(DirectX::device, "shader.fx", 0, 0, D3DXSHADER_DEBUG, 0, &effect, &errors);
if(errors){
MessageBox(0, (char*)errors->GetBufferPointer(), 0, 0);
}
问题是,我知道我的着色器中存在错误/错误,但它没有弹出一个错误框来说明错误是什么......有人可以告诉我我做错了什么吗?
我最近升级到 DirectX 11,这就是我现在正在做的事情。 它应该在DX9中成立。
char *compileErrors;
unsigned long bufferSize, i;
std::ofstream fout;
//get a pointer to the error message text buffer
compileErrors = (char*)(errorMessage->GetBufferPointer());
//get the length of the message
bufferSize = errorMessage->GetBufferSize();
//open a file to write the error message to
fout.open("shader-error.txt");
//write out the error message
for(i=0; i<bufferSize; i++)
{
fout << compileErrors[i];
}
//close the file
fout.close();
//release the error message
errorMessage->Release();
errorMessage = nullptr; //or NULL, depending on your compiler
//pop a message up on the screen to notify the user to check the text file for compile errors
MessageBox(hwnd, "Error compiling shader. Check shader-error.txt for message.", (LPCSTR)shaderFilename, MB_OK);
//shaderFilename and hwnd not defined in this code. pass as a function parameter or something
此外,如果您已经删除了创建的第一个窗口(例如,在完成所有初始化后删除的初始窗口),则不会显示第一个参数为 NULL
的MessageBox
。 无需在运行时调用DestroyWindow
,只需隐藏窗口并在程序退出时释放它。 隐藏窗口的代码:ShowWindow(splashWnd, WS_HIDE);
相关文章:
- 显示错误输出的简单数组排序程序
- 我是 c++ 的新手.学习基本知识后,我想做井字游戏.对于印刷板,我在下面写代码,但它显示错误
- Clion显示错误,但可以使用Cmake成功构建代码
- 代码使用向量成功运行,但使用数组显示错误
- SDL 映像:无法打开映像,仅显示错误消息
- 为什么将指针重新分配给 1D 数组的 char 时显示错误,但 2D 数组工作正常?
- 与clang++一起使用的VS代码在构建良好的C++文件中显示错误
- 编译器没有显示错误,但我没有得到任何输出.怎么了?
- PPM 颜色显示错误
- 当我选择大于 720 的矩阵大小时,程序退出并显示错误代码.可能是什么原因?
- is_permutation方法从 #include<algorithm> 显示错误的输出
- 为什么使用与父级声明的 std::function 在与子级一起使用时会显示错误?
- 我的代码厨师提交显示错误的结果
- 显示错误"std_lib_facilities.h"
- 为什么C++显示错误的数字?
- Android (ART) 崩溃并显示错误 JNI 在应用程序中检测到错误:jstring 是无效的本地引用
- 这是我的 .h 文件的一些错误,当我在其中包含我的类模板时,它显示 [错误] 未终止 #ifndef
- c++ IF 语句执行,但添加 ELSE 会显示错误
- 内核.cpp在制作 kernel.o 时显示错误和 Makefile 错误
- C++代码编译,但在 Zorin OS 上运行时显示错误