OSG中嵌入一个opengl代码(且opengl图形能动态更新)
(1)继承osg::Drawable::DrawCallback,在
drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* drawable)函数里添加opengl代码。
(2)Drawable设置绘制回调函数,并注意要把显示列表设置为false:
geometry->setUseDisplayList(false);
geometry->setDrawCallback(new DrawCallback);
――――――――――――
参考代码如下(改编自OSG的例子程序osgSpaceWarp):
#include "stdafx.h"
#include <osgViewer/Viewer>
#include <osg/Group>
#include <osg/Geometry>
#pragma comment( lib, "osgd.lib"); //.在Debug版本下的库名都加d,如"osgd.lib"
#pragma comment( lib, "osgDBd.lib")
#pragma comment( lib, "osgViewerd.lib");