Panda3D版本是1.8.1,VS版本2008,创建空的Panda3D程序并使用Release模式运行正常(Panda3D官方要求使用Release模式,使用Debug模式总是会莫名崩溃),当使用TextNode时会导致程序崩溃。完整程序代码如下:
#pragma comment(lib , "libp3framework.lib")
#pragma comment(lib , "libpanda.lib")
#pragma comment(lib , "libpandafx.lib")
#pragma comment(lib , "libpandaexpress.lib")
#pragma comment(lib , "libp3dtool.lib")
#pragma comment(lib , "libp3dtoolconfig.lib")
#pragma comment(lib , "libpandagl.lib")
#pragma comment(lib , "libp3direct.lib")
#include <pandaFramework.h>
#include <pandaSystem.h>
PandaFramework framework;
int main(int argc , char** argv)
{
framework.open_framework(argc , argv);
framework.set_window_title("Hello Panda3D");
WindowFramework* window = framework.open_window();
if((WindowFramework*)NULL == window)
{
nout<<"Open WindowFramework Failed!"<<endl;
}
else
{
//设置背景为黑色
window->set_background_type(WindowFramework::BT_black);
PT(TextNode) pText = new TextNode("text");
pText->set_text_color(1 , 1 , 0 , 1);
pText->set_text("Hello Panda3D");
NodePath npText = window->get_aspect_2d().attach_new_node(pText);
npText.set_pos(0 , 0 , 0);
npText.set_scale(0.1 , 0.1 ,0.1);
framework.main_loop();
}
framework.close_framework();
return 0;
}
崩溃显示
属性->配置属性->C/C++->预处理器->预处理器定义,删除NDEBUG(官方文档提到需要这么做),重新编译运行即可
解决后运行结果