root/OpenSceneGraph/trunk/examples/osgshadercomposition/osgshadercomposition.cpp @ 11664

Revision 11664, 1.6 kB (checked in by robert, 4 years ago)

Added basic ShaderComponent? class and beginnings osgshadercomposition example

Line 
1/* OpenSceneGraph example, osganimate.
2*
3*  Permission is hereby granted, free of charge, to any person obtaining a copy
4*  of this software and associated documentation files (the "Software"), to deal
5*  in the Software without restriction, including without limitation the rights
6*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*  copies of the Software, and to permit persons to whom the Software is
8*  furnished to do so, subject to the following conditions:
9*
10*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16*  THE SOFTWARE.
17*/
18
19#include <osgViewer/Viewer>
20#include <osgDB/ReadFile>
21#include <osg/ShaderAttribute>
22
23osg::Node* createSceneGraph(osg::ArgumentParser& arguments)
24{
25    osg::Node* node = osgDB::readNodeFiles(arguments);
26    if (!node) return 0;
27
28    osg::StateSet* stateset = node->getOrCreateStateSet();
29    osg::ShaderAttribute* sa = new osg::ShaderAttribute;
30    stateset->setAttribute(sa);
31
32    return node;
33}
34
35int main( int argc, char **argv )
36{
37    osg::ArgumentParser arguments(&argc,argv);
38
39    osgViewer::Viewer viewer(arguments);
40
41    osg::ref_ptr<osg::Node> scenegraph = createSceneGraph(arguments);
42    if (!scenegraph) return 1;
43
44    viewer.setSceneData(scenegraph.get());
45
46    return viewer.run();
47}
Note: See TracBrowser for help on using the browser.