root/OpenSceneGraph/trunk/examples/osgpdf/osgpdf.cpp @ 9323

Revision 9323, 1.3 kB (checked in by robert, 5 years ago)

Added support for setting background colour of Pdf document.

Line 
1#include <osg/Image>
2#include <osg/Geometry>
3#include <osg/Texture2D>
4#include <osg/io_utils>
5
6#include <osgViewer/Viewer>
7#include <osgViewer/ViewerEventHandlers>
8
9#include <osgDB/FileUtils>
10#include <osgDB/FileNameUtils>
11#include <osgDB/ReadFile>
12
13#include <osgWidget/PdfReader>
14
15int main(int argc,char** argv)
16{
17    osg::ArgumentParser arguments(&argc, argv);
18    osgViewer::Viewer viewer(arguments);
19
20    osgWidget::GeometryHints hints(osg::Vec3(1.0f,0.0f,0.0f),
21                                   osg::Vec3(1.0f,0.0f,0.0f),
22                                   osg::Vec3(0.0f,0.0f,1.0f),
23                                   osg::Vec4(1.0f,1.0f,1.0f,1.0f),
24                                   osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);
25
26    osg::ref_ptr<osg::Group> group = new osg::Group;
27
28    for(int i=1; i<arguments.argc(); ++i)
29    {
30        if (!arguments.isOption(i))
31        {
32            osg::ref_ptr<osgWidget::PdfReader> pdfReader = new osgWidget::PdfReader;
33            if (pdfReader->open(arguments[i], hints))
34            {           
35                group->addChild(pdfReader.get());
36               
37                hints.position.x() += 1.1f;
38            }
39        }
40    }
41
42    viewer.setSceneData(group.get());
43
44    viewer.addEventHandler(new osgViewer::StatsHandler);
45
46    return viewer.run();
47}
Note: See TracBrowser for help on using the browser.