|
源代码:#include <osg/Billboard>
#include <osg/Texture2D>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#define RAND(min, max) ((min) + (double)rand()/(RAND_MAX+1)*((max)-(min)))
void createTrees( osg::Billboard& root )
{
root.getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
root.getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D( osgDB::readImageFile("tree.rgba") );
for ( unsigned int i=0; i<200; ++i )
{
osg::ref_ptr<osg:rawable> tree =
osg::createTexturedQuadGeometry( osg::Vec3(0,0,0), osg::Vec3(RAND(0.5,1.5),0,0), osg::Vec3(0,0,RAND(1.0,2.0)) );
tree->getOrCreateStateSet()->setTextureAttributeAndModes( 0, texture.get() );
root.addDrawable( tree.get(), osg::Vec3(RAND(-10,10), RAND(-10,10), 0.0) );
}
}
int main( int argc, char** argv )
{
osg::ref_ptr<osg::Billboard> treeGeode = new osg::Billboard;
treeGeode->setMode( osg::Billboard:OINT_ROT_EYE );
createTrees( *treeGeode );
osgViewer::Viewer viewer;
viewer.setSceneData( treeGeode.get() );
return viewer.run();
}
报错的内容为:1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall osg::StateSet::setTextureAttributeAndModes(unsigned int,class osg::StateAttribute *,unsigned int)" (__imp_?setTextureAttributeAndModes@StateSet@osg@@QAEXIPAVStateAttribute@2@I@Z),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class osg::StateSet * __thiscall osg::Drawable::getOrCreateStateSet(void)" (__imp_?getOrCreateStateSet@Drawable@osg@@QAEPAVStateSet@2@XZ),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall osg::Texture2D::Texture2D(class osg::Image *)" (__imp_??0Texture2D@osg@@QAE@PAVImage@1@@Z),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall osg::StateSet::setMode(unsigned int,unsigned int)" (__imp_?setMode@StateSet@osg@@QAEXII@Z),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall osg::StateSet::setRenderingHint(int)" (__imp_?setRenderingHint@StateSet@osg@@QAEXH@Z),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class osg::StateSet * __thiscall osg::Node::getOrCreateStateSet(void)" (__imp_?getOrCreateStateSet@Node@osg@@QAEPAVStateSet@2@XZ),该符号在函数 "void __cdecl createTrees(class osg::Billboard &)" (?createTrees@@YAXAAVBillboard@osg@@@Z) 中被引用
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Object::setThreadSafeRefUnref(bool)" (?setThreadSafeRefUnref@Object@osg@@UAEX_N@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osg::Texture2D::cloneType(void)const " (?cloneType@Texture2D@osg@@UBEPAVObject@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osg::Texture2D::clone(class osg::CopyOp const &)const " (?clone@Texture2D@osg@@UBEPAVObject@2@ABVCopyOp@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Texture2D::isSameKindAs(class osg::Object const *)const " (?isSameKindAs@Texture2D@osg@@UBE_NPBVObject@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osg::Texture2D::libraryName(void)const " (?libraryName@Texture2D@osg@@UBEPBDXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osg::Texture2D::className(void)const " (?className@Texture2D@osg@@UBEPBDXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Object::setName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setName@Object@osg@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Object::computeDataVariance(void)" (?computeDataVariance@Object@osg@@UAEXXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Object::setUserData(class osg::Referenced *)" (?setUserData@Object@osg@@UAEXPAVReferenced@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Referenced const * __thiscall osg::Object::getUserData(void)const " (?getUserData@Object@osg@@UBEPBVReferenced@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Referenced * __thiscall osg::Object::getUserData(void)" (?getUserData@Object@osg@@UAEPAVReferenced@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Texture::resizeGLObjectBuffers(unsigned int)" (?resizeGLObjectBuffers@Texture@osg@@UAEXI@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Texture::releaseGLObjects(class osg::State *)const " (?releaseGLObjects@Texture@osg@@UBEXPAVState@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Texture const * __thiscall osg::Texture::asTexture(void)const " (?asTexture@Texture@osg@@UBEPBV12@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Texture * __thiscall osg::Texture::asTexture(void)" (?asTexture@Texture@osg@@UAEPAV12@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual enum osg::StateAttribute::Type __thiscall osg::Texture2D::getType(void)const " (?getType@Texture2D@osg@@UBE?AW4Type@StateAttribute@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual unsigned int __thiscall osg::StateAttribute::getMember(void)const " (?getMember@StateAttribute@osg@@UBEIXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Texture::isTextureAttribute(void)const " (?isTextureAttribute@Texture@osg@@UBE_NXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall osg::Texture2D::compare(class osg::StateAttribute const &)const " (?compare@Texture2D@osg@@UBEHABVStateAttribute@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Texture::getModeUsage(struct osg::StateAttribute::ModeUsage &)const " (?getModeUsage@Texture@osg@@UBE_NAAUModeUsage@StateAttribute@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::StateAttribute::checkValidityOfAssociatedModes(class osg::State &)const " (?checkValidityOfAssociatedModes@StateAttribute@osg@@UBE_NAAVState@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Texture2D::apply(class osg::State &)const " (?apply@Texture2D@osg@@UBEXAAVState@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Texture::compileGLObjects(class osg::State &)const " (?compileGLObjects@Texture@osg@@UBEXAAVState@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual unsigned int __thiscall osg::Texture2D::getTextureTarget(void)const " (?getTextureTarget@Texture2D@osg@@UBEIXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall osg::Texture2D::getTextureWidth(void)const " (?getTextureWidth@Texture2D@osg@@UBEHXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall osg::Texture2D::getTextureHeight(void)const " (?getTextureHeight@Texture2D@osg@@UBEHXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall osg::Texture2D::getTextureDepth(void)const " (?getTextureDepth@Texture2D@osg@@UBEHXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Texture2D::setImage(unsigned int,class osg::Image *)" (?setImage@Texture2D@osg@@UAEXIPAVImage@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Image const * __thiscall osg::Texture2D::getImage(unsigned int)const " (?getImage@Texture2D@osg@@UBEPBVImage@2@I@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Image * __thiscall osg::Texture2D::getImage(unsigned int)" (?getImage@Texture2D@osg@@UAEPAVImage@2@I@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual unsigned int __thiscall osg::Texture2D::getNumImages(void)const " (?getNumImages@Texture2D@osg@@UBEIXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall osg::Texture2D::computeInternalFormat(void)const " (?computeInternalFormat@Texture2D@osg@@MBEXXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall osg::Texture2D::allocateMipmap(class osg::State &)const " (?allocateMipmap@Texture2D@osg@@MBEXAAVState@2@@Z)
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: virtual __thiscall osg::Texture2D::~Texture2D(void)" (__imp_??1Texture2D@osg@@MAE@XZ),该符号在函数 "protected: virtual void * __thiscall osg::Texture2D::`scalar deleting destructor'(unsigned int)" (??_GTexture2D@osg@@MAEPAXI@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) class osg::Geometry * __cdecl osg::createTexturedQuadGeometry(class osg::Vec3f const &,class osg::Vec3f const &,class osg::Vec3f const &,float,float,float,float)" (__imp_?createTexturedQuadGeometry@osg@@YAPAVGeometry@1@ABVVec3f@1@00MMMM@Z),该符号在函数 "class osg::Geometry * __cdecl osg::createTexturedQuadGeometry(class osg::Vec3f const &,class osg::Vec3f const &,class osg::Vec3f const &,float,float)" (?createTexturedQuadGeometry@osg@@YAPAVGeometry@1@ABVVec3f@1@00MM@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall osg::Billboard::setMode(enum osg::Billboard::Mode)" (__imp_?setMode@Billboard@osg@@QAEXW4Mode@12@@Z),该符号在函数 _main 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall osg::Billboard::Billboard(void)" (__imp_??0Billboard@osg@@QAE@XZ),该符号在函数 _main 中被引用
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Geode::setThreadSafeRefUnref(bool)" (?setThreadSafeRefUnref@Geode@osg@@UAEX_N@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osg::Billboard::cloneType(void)const " (?cloneType@Billboard@osg@@UBEPAVObject@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Object * __thiscall osg::Billboard::clone(class osg::CopyOp const &)const " (?clone@Billboard@osg@@UBEPAVObject@2@ABVCopyOp@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Billboard::isSameKindAs(class osg::Object const *)const " (?isSameKindAs@Billboard@osg@@UBE_NPBVObject@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osg::Billboard::libraryName(void)const " (?libraryName@Billboard@osg@@UBEPBDXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall osg::Billboard::className(void)const " (?className@Billboard@osg@@UBEPBDXZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Geode::resizeGLObjectBuffers(unsigned int)" (?resizeGLObjectBuffers@Geode@osg@@UAEXI@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Geode::releaseGLObjects(class osg::State *)const " (?releaseGLObjects@Geode@osg@@UBEXPAVState@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Group const * __thiscall osg::Node::asGroup(void)const " (?asGroup@Node@osg@@UBEPBVGroup@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Group * __thiscall osg::Node::asGroup(void)" (?asGroup@Node@osg@@UAEPAVGroup@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Transform const * __thiscall osg::Node::asTransform(void)const " (?asTransform@Node@osg@@UBEPBVTransform@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Transform * __thiscall osg::Node::asTransform(void)" (?asTransform@Node@osg@@UAEPAVTransform@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Switch const * __thiscall osg::Node::asSwitch(void)const " (?asSwitch@Node@osg@@UBEPBVSwitch@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Switch * __thiscall osg::Node::asSwitch(void)" (?asSwitch@Node@osg@@UAEPAVSwitch@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Geode const * __thiscall osg::Geode::asGeode(void)const " (?asGeode@Geode@osg@@UBEPBV12@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::Geode * __thiscall osg::Geode::asGeode(void)" (?asGeode@Geode@osg@@UAEPAV12@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osgTerrain::Terrain const * __thiscall osg::Node::asTerrain(void)const " (?asTerrain@Node@osg@@UBEPBVTerrain@osgTerrain@@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osgTerrain::Terrain * __thiscall osg::Node::asTerrain(void)" (?asTerrain@Node@osg@@UAEPAVTerrain@osgTerrain@@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Billboard::accept(class osg::NodeVisitor &)" (?accept@Billboard@osg@@UAEXAAVNodeVisitor@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Node::ascend(class osg::NodeVisitor &)" (?ascend@Node@osg@@UAEXAAVNodeVisitor@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall osg::Node::traverse(class osg::NodeVisitor &)" (?traverse@Node@osg@@UAEXAAVNodeVisitor@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual class osg::BoundingSphereImpl<class osg::Vec3f> __thiscall osg::Billboard::computeBound(void)const " (?computeBound@Billboard@osg@@UBE?AV?$BoundingSphereImpl@VVec3f@osg@@@2@XZ)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Billboard::addDrawable(class osg::Drawable *)" (?addDrawable@Billboard@osg@@UAE_NPAVDrawable@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Billboard::removeDrawable(class osg::Drawable *)" (?removeDrawable@Billboard@osg@@UAE_NPAVDrawable@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Geode::removeDrawables(unsigned int,unsigned int)" (?removeDrawables@Geode@osg@@UAE_NII@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Geode::replaceDrawable(class osg::Drawable *,class osg::Drawable *)" (?replaceDrawable@Geode@osg@@UAE_NPAVDrawable@2@0@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Geode::setDrawable(unsigned int,class osg::Drawable *)" (?setDrawable@Geode@osg@@UAE_NIPAVDrawable@2@@Z)
1>billboard.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall osg::Billboard::addDrawable(class osg::Drawable *,class osg::Vec3f const &)" (?addDrawable@Billboard@osg@@UAE_NPAVDrawable@2@ABVVec3f@2@@Z)
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) protected: virtual __thiscall osg::Billboard::~Billboard(void)" (__imp_??1Billboard@osg@@MAE@XZ),该符号在函数 "protected: virtual void * __thiscall osg::Billboard::`scalar deleting destructor'(unsigned int)" (??_GBillboard@osg@@MAEPAXI@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: int __thiscall osg::Referenced::ref(void)const " (__imp_?ref@Referenced@osg@@QBEHXZ),该符号在函数 "public: __thiscall osg::ref_ptr<class osg::Drawable>::ref_ptr<class osg::Drawable>(class osg::Drawable *)" (??0?$ref_ptr@VDrawable@osg@@@osg@@QAE@PAVDrawable@1@@Z) 中被引用
1>billboard.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: int __thiscall osg::Referenced::unref(void)const " (__imp_?unref@Referenced@osg@@QBEHXZ),该符号在函数 "public: __thiscall osg::ref_ptr<class osg::Drawable>::~ref_ptr<class osg::Drawable>(void)" (??1?$ref_ptr@VDrawable@osg@@@osg@@QAE@XZ) 中被引用
1>D:\我的文档\Visual Studio 2010\Projects\firstproject\Debug\billboard.exe : fatal error LNK1120: 74 个无法解析的外部命令
1> |
|