相关资料:
https://blog.csdn.net/forcsdn_tang/article/details/122273695
实例代码:
.pro
1 QT += core gui widgets 2 QT += opengl 3 TARGET = TestOsgQt 4 TEMPLATE = app 5 DEFINES += QT_DEPRECATED_WARNINGS 6 CONFIG += c++11 7 8 SOURCES += \ 9 main.cpp 10 11 HEADERS += 12 13 OsgDir = D:\\Gitee\\osg365R 14 CONFIG(release, debug|release) { 15 LIBS += -L$${OsgDir}/lib/ -losgDB -losgViewer -lOpenThreads -losgAnimation -losg \ 16 -losgEarth -losgEarthAnnotation -losgEarthFeatures -losgEarthSymbology -losgEarthUtil \ 17 -losgQOpenGL -losgUtil -losgText -losgTerrain -losgSim \ 18 -losgShadow -losgParticle -losgManipulator -losgGA -losgFX \ 19 -losgWidget 20 } else { 21 LIBS += -L$${OsgDir}/debug/lib/ -losgDBd -losgViewerd -lOpenThreadsd -losgAnimationd -losgd \ 22 -losgEarthd -losgEarthAnnotationd -losgEarthFeaturesd -losgEarthSymbologyd -losgEarthUtild \ 23 -losgQOpenGLd -losgUtild -losgTextd -losgTerraind -losgSimd \ 24 -losgShadowd -losgParticled -losgManipulatord -losgGAd -losgFXd \ 25 } 26 27 LIBS += -lOpenGL32 28 LIBS += -lGlU32 29 30 INCLUDEPATH += $${OsgDir}/include 31 DEPENDPATH += $${OsgDir}/includeView Code
main.cpp
1 #include <osgViewer/Viewer> 2 3 #include <osg/Node> 4 #include <osg/Geode> 5 #include <osg/Group> 6 #include <osg/NodeCallback> 7 #include <osg/MatrixTransform> 8 9 #include <osgDB/ReadFile> 10 #include <osgDB/WriteFile> 11 12 #include <osgUtil/Optimizer> 13 14 #include <osg/ShapeDrawable> 15 #include <osg/Texture2D> 16 #include <osgViewer/Viewer> 17 #include <osgDB/ReadFile> 18 19 #include <iostream> 20 21 int main() 22 { 23 std::cout << "Hello, osg!" << std::endl; 24 25 osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer; 26 viewer->setUpViewInWindow(50,50,500,400); 27 osg::ref_ptr<osg::Geode> geode = new osg::Geode; 28 geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(), 1.0f))); 29 osg::ref_ptr<osg::Texture> texture = new osg::Texture2D(osgDB::readRefImageFile("D:/Gitee/data/purpleFlowers.png")); 30 auto stateSet = geode->getOrCreateStateSet(); 31 stateSet->setTextureAttributeAndModes(0, texture); 32 viewer->setSceneData(geode); 33 return viewer->run(); 34 }View Code
搜索
复制
<iframe></iframe> 标签:贴图,OsgDir,geode,Osg,Texture2D,new,include,osg From: https://www.cnblogs.com/FKdelphi/p/16591624.html