首页 > 其他分享 >Osg-Osg利用Texture2D给球面贴图(Qt5.14.2+osgE3.6.5+win10)-No28-Texture2D

Osg-Osg利用Texture2D给球面贴图(Qt5.14.2+osgE3.6.5+win10)-No28-Texture2D

时间:2022-08-16 15:12:24浏览次数:72  
标签:贴图 OsgDir geode Osg Texture2D new include osg

相关资料:

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}/include
View 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

相关文章

  • 数据转换3-osgb转成3dtile格式
     选择的是包含所有osgb文件夹的Data文件文件添加成功之后,空间参考,零点坐标等会根据文件自动生成,需要更改点击设置选择即可存储类型:选择“散列”,如果没有注意到,Ce......
  • 基于C++的OpenGL 10 之光照贴图
    1.引言本文基于C++语言,描述OpenGL的光照贴图前置知识可参考:基于C++的OpenGL09之材质-当时明月在曾照彩云归-博客园(cnblogs.com)笔者这里不过多描述每个名词......
  • cesium教程-无人机航拍倾斜摄影素材用ContextCapture转换成OSGB格式
    首先软件的下载和安装参考下面链接http://www.xue51.com/soft/53013.html 0、首先打开软件,要打开2个哦。打数据处理开后台ContextCaptureEngine打开处理工具Contex......