|
下面的代码中,放开1,注释2
然后注释1,放开2
编译后的表现不一致.后者渲染有点问题,比如glider会透视,然后cow.osg也会有黑色的面
目前我只懂得要设置 setProjectionMatrixAsPerspective 和 setClearColor
int main(int argc, char **argv) {
double wnd_width = 960, wnd_height = 540;
osgViewer::Viewer vi;
osg::Camera *test_cam = vi.getCamera(); // 1
// osg::Camera *test_cam = new osg::Camera; // 2
test_cam->setProjectionMatrixAsPerspective(
30.0, wnd_width / wnd_height, 1, 10000
);
test_cam->setClearColor(osg::Vec4(0.2, 0.2, 0.4, 1.0f));
vi.setCamera(test_cam);
vi.setUpViewInWindow(0, 0, wnd_width, wnd_height);
vi.setSceneData(osgDB::readNodeFile("glider.osg"));
vi.realize();
return vi.run();
} |
|