osgViewer::Viewer::Windows

osg自带窗口去掉边框

#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32
#include<iostream>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers> 
#include <osgViewer/CompositeViewer> 
#include <osgDB/ReadFile>
#include <osg/Geode>
#include <osg/Node>
#include <osg/Geometry>
#include <osgGA/TrackballManipulator>
#include <osg/GraphicsContext>
#include <osg/ShapeDrawable>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/TexEnv>
#include <osg/TexGen>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/AnimationPath>
#include <osg/Matrixd>

#include <osgGA/GUIEventHandler>
#include <osgGA/CameraManipulator>
#include <osgGA/StandardManipulator>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator>
#include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector>

int main()
{
    osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
    osg::ref_ptr<osg::Node> node1;
    osg::GraphicsContext::WindowingSystemInterface *ws = osg::GraphicsContext::getWindowingSystemInterface();
    
    unsigned int height=0, width=0;
    osg::GraphicsContext::Traits traits;
    osg::GraphicsContext::ScreenIdentifier screenIdentifier1;
    
    if (ws)
    {
        ws->getScreenResolution(screenIdentifier1, width, height);
        std::cout << "ws is not null" << std::endl;
        std::cout << "resolution:  w:"<<width<<"  h:"<<height<<"  " << std::endl;
        std::cout << "border:"<<screenIdentifier1.displayNum << std::endl;

    }
    else
    {
        std::cout << "ws is null" << std::endl;
    }

    node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build1.OSGB");
    viewer->setSceneData(node1.get());
    viewer->setUpViewInWindow(200, 200, 800, 500, 0);
    
    osgViewer::Viewer::Windows win1;
    osgViewer::Viewer::Windows::iterator iter1;

    viewer->getWindows(win1);
    if (!win1.empty())
    {
        for (iter1=win1.begin();iter1 != win1.end(); ++iter1)
        {
            (*iter1)->setWindowDecoration(false);
        }
    }

    return viewer->run();
}

 

posted @ 2019-06-27 09:27  西北逍遥  阅读(1925)  评论(0编辑  收藏  举报