• OsgOsg利用Texture2D给球面贴图(Qt5.14.2+osgE3.6.5+win10)No28Texture2D


    相关资料:

    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
  • 相关阅读:
    软件测试经理工作职责
    测试经理的年终总结
    从0到1,如何快速搭建人才梯队?
    Centos 的常用命令总结
    Docker的常用命令总结
    Jenkins Android项目编译配置(完整版)
    linux CentOS 权限问题修复(chmod 777 -R 或者chmod 755 -R问题修复)
    基于gitlab的项目管理流程
    js 防抖动、重复提交、频繁点击
    GPUImage移植总结
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/16591624.html
Copyright © 2020-2023  润新知