Beispiel #1
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);
    
    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        // Create the SimpleSceneManager helper
        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));
        TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);


        // Make Torus Node (creates Torus in background of scene)
        NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

        // Make Main Scene Node and add the Torus
        NodeRefPtr scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
        scene->addChild(TorusGeometryNode);

        // Create the Graphics
        GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

        /******************************************************

          Create an Button Component and
          a simple Font.
          See 17Label_Font for more
          information about Fonts.

         ******************************************************/
        ButtonRefPtr ExampleButton = OSG::Button::create();

        UIFontRefPtr ExampleFont = OSG::UIFont::create();
        ExampleFont->setSize(16);

        /******************************************************

          Edit the Button's characteristics.
            Note: the first 4 functions can
            be used with any Component and 
            are not specific to Button.

            -setMinSize(Vec2f): Determine the 
            Minimum Size of the Component.
            Some Layouts will automatically
            resize Components; this prevents
            the Size from going below a
            certain value.
            -setMaxSize(Vec2f): Determine the 
            Maximum Size of the Component.
            -setPreferredSize(Vec2f): Determine
            the Preferred Size of the Component.
            This is what the Component will
            be displayed at unless changed by
            another Component (such as a 
            Layout).
            -setToolTipText("Text"): Determine
            what text is displayed while
            Mouse is hovering above Component.
            The word Text will be displayed
            in this case.

            Functions specfic to Button:
            -setText("DesiredText"): Determine 
            the Button's text.  It will read
            DesiredText in this case.
            -setFont(FontName): Determine the 
            Font to be used on the Button.
            -setTextColor(Color4f): Determine the
            Color for the text.
            -setRolloverTextColor(Color4f): Determine
            what the text Color will be when
            the Mouse Cursor is above the 
            Button.
            -setActiveTextColor(Color4f): Determine
            what the text Color will be when
            the Button is pressed (denoted by
            Active).
            -setAlignment(Vec2f):
            Determine the Vertical Alignment
            of the text.  The value is 
            in [0.0, 1.0].

         ******************************************************/
        ExampleButton->setMinSize(Vec2f(50, 25));
        ExampleButton->setMaxSize(Vec2f(200, 100));
        ExampleButton->setPreferredSize(Vec2f(100, 50));
        ExampleButton->setToolTipText("Button 1 ToolTip");

        ExampleButton->setText("Button 1");
        ExampleButton->setFont(ExampleFont);
        ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
        ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
        ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
        ExampleButton->setAlignment(Vec2f(1.0,0.0));

        // Create an Action and assign it to ExampleButton
        // This Class is defined above, and will cause the output
        // window to display "Button 1 Action" when pressed
        ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1));

        /******************************************************

          Create a ToggleButton and determine its 
          characteristics.  ToggleButton inherits
          off of Button, so all characteristsics
          used above can be used with ToggleButtons
          as well.

          The only difference is that when pressed,
          ToggleButton remains pressed until pressed 
          again.

          -setSelected(bool): Determine whether the 
          ToggleButton is Selected (true) or
          deselected (false).  

         ******************************************************/
        ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();

        ExampleToggleButton->setSelected(false);
        ExampleToggleButton->setText("ToggleMe");
        ExampleToggleButton->setToolTipText("Toggle Button ToolTip");

        //Button with Image
        ButtonRefPtr ExampleDrawObjectButton = OSG::Button::create();
        ExampleDrawObjectButton->setDrawObjectToTextAlignment(Button::ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT);
        ExampleDrawObjectButton->setText("Icon");

        ExampleDrawObjectButton->setImage(std::string("./Data/Icon.png"));
        ExampleDrawObjectButton->setActiveImage(std::string("./Data/Icon.png"));
        ExampleDrawObjectButton->setFocusedImage(std::string("./Data/Icon.png"));
        ExampleDrawObjectButton->setRolloverImage(std::string("./Data/Icon.png"));
        ExampleDrawObjectButton->setDisabledImage(std::string("./Data/Icon.png"));

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
        InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
        LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
        MainInternalWindow->pushToChildren(ExampleButton);
        MainInternalWindow->pushToChildren(ExampleToggleButton);
        MainInternalWindow->pushToChildren(ExampleDrawObjectButton);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setDrawTitlebar(false);
        MainInternalWindow->setResizable(false);

        // Create the Drawing Surface
        UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

        // Create the UI Foreground Object
        UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

        sceneManager.setRoot(scene);

        // Add the UI Foreground Object to the Scene
        ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);


        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // Show the whole Scene
        sceneManager.showAll();

        //Attach key controls

        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "01Button");

        commitChanges();

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();

    /******************************************************

      Create an Button Component and
      a simple Font.
      See 17Label_Font for more
      information about Fonts.

     ******************************************************/
    ButtonRefPtr ExampleButton = OSG::Button::create();

    UIFontRefPtr ExampleFont = OSG::UIFont::create();
    ExampleFont->setSize(16);

    ExampleButton->setMinSize(Vec2f(50, 25));
    ExampleButton->setMaxSize(Vec2f(200, 100));
    ExampleButton->setPreferredSize(Vec2f(100, 50));
    ExampleButton->setToolTipText("Button 1 ToolTip");

    ExampleButton->setText("Button 1");
    ExampleButton->setFont(ExampleFont);
    ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
    ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
    ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
    ExampleButton->setAlignment(Vec2f(1.0,0.0));


    /******************************************************

      Create a ToggleButton and determine its
      characteristics.  ToggleButton inherits
      off of Button, so all characteristsics
      used above can be used with ToggleButtons
      as well.

      The only difference is that when pressed,
      ToggleButton remains pressed until pressed
      again.

      -setSelected(bool): Determine whether the
      ToggleButton is Selected (true) or
      deselected (false).

     ******************************************************/
    ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();

    ExampleToggleButton->setSelected(false);
    ExampleToggleButton->setText("ToggleMe");
    ExampleToggleButton->setToolTipText("Toggle Button ToolTip");


    // Create Background to be used with the MainInternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    // Create The Internal Window
    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
    // Assign the Button to the MainInternalWindow so it will be displayed
    // when the view is rendered.
    MainInternalWindow->pushToChildren(ExampleButton);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setPosition(Pnt2f(50,50));
    MainInternalWindow->setPreferredSize(Vec2f(300,300));
    MainInternalWindow->setTitle(std::string("Internal Window 1"));

    // Create The Internal Window
    InternalWindowRefPtr MainInternalWindow2 = OSG::InternalWindow::create();
    LayoutRefPtr MainInternalWindowLayout2 = OSG::FlowLayout::create();
    // Assign the Button to the MainInternalWindow so it will be displayed
    // when the view is rendered.
    MainInternalWindow2->pushToChildren(ExampleToggleButton);
    MainInternalWindow2->setLayout(MainInternalWindowLayout2);
    MainInternalWindow2->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow2->setPosition(Pnt2f(150,150));
    MainInternalWindow2->setPreferredSize(Vec2f(300,300));
    MainInternalWindow2->setTitle(std::string("Internal Window 2"));
    MainInternalWindow2->setIconable(false);
    MainInternalWindow2->setAllwaysOnTop(true);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
    TutorialDrawingSurface->setGraphics(TutorialGraphics);
    TutorialDrawingSurface->setEventProducer(TutorialWindow);

    TutorialDrawingSurface->openWindow(MainInternalWindow);
    TutorialDrawingSurface->openWindow(MainInternalWindow2);
    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
    TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
    TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "37InternalWindow");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        // Create the SimpleSceneManager helper
        SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create();
        TutorialWindow->setDisplayCallback(boost::bind(display, sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, sceneManager));

        // Tell the Manager what to manage
        sceneManager->setWindow(TutorialWindow);

        TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));

        // Make Torus Node (creates Torus in background of scene)
        NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
       
        // Make Main Scene Node and add the Torus
        NodeRefPtr scene = OSG::Node::create();
            scene->setCore(OSG::Group::create());
            scene->addChild(TorusGeometryNode);

        // Create the Graphics
        GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

        /******************************************************

                Create the Layers.

        ******************************************************/

        ColorLayerRefPtr ExampleColorLayer = OSG::ColorLayer::create();
        CompoundLayerRefPtr ExampleCompoundLayer = OSG::CompoundLayer::create();
        EmptyLayerRefPtr ExampleEmptyLayer = OSG::EmptyLayer::create();
        GradientLayerRefPtr ExampleGradientLayer = OSG::GradientLayer::create();
        MaterialLayerRefPtr ExampleMaterialLayer = OSG::MaterialLayer::create();
        TextureLayerRefPtr ExampleTextureLayer = OSG::TextureLayer::create();
        PatternLayerRefPtr ExamplePatternLayer = OSG::PatternLayer::create();
        GlassLayerRefPtr ExampleGlassLayer = OSG::GlassLayer::create();
        CompoundLayerRefPtr ExampleGlassCompoundLayer = OSG::CompoundLayer::create();

        /******************************************************

            The ColorLayer is a simple Layer
            having just a Color to it.

            -setColor(Color4f): Determine the Color of
                the Layer.

        ******************************************************/

            ExampleColorLayer->setColor(Color4f(1.0,0.0,0.0,1.0));
        
        /******************************************************

                The CompoundLayer allows you to 
                combine multiple Backgrounds into one.

                The Backgrounds are added sequentially;
                so in this example the 
                ExampleTextureLayer would be added 
                first, and the ExampleGradientLayer
                rendered on top of it.  

                -getBackgrounds().push_back(BackgroundName):
                    Adds a Background to the 
                    CompoundBackground.

        ******************************************************/

            ExampleCompoundLayer->pushToBackgrounds(ExampleTextureLayer);
            ExampleCompoundLayer->pushToBackgrounds(ExampleGradientLayer);
        
        /******************************************************

                The EmptyLayer is a Background
                with no attributes.

        ******************************************************/

            // Nothing!
            
        /******************************************************

                The GradientLayer is a Background
                which displays a gradient of Color.

                -getColors().push_back(Color4f): Determines the 
                    starting Color for the gradient.
                -getColors().push_back(Color4f): Determines the
                    ending Color for the gradient.
                -setOrientation(ENUM): Determines the
                    gradient alignment.  Takes 
                    HORIZONTAL_ORIENTATION or 
                    VERTICAL_ORIENTATION arguments.

        ******************************************************/


            ExampleGradientLayer->editMFColors()->push_back(Color4f(1.0, 0.0, 0.0, 1.0));
            ExampleGradientLayer->editMFStops()->push_back(0.0);
            ExampleGradientLayer->editMFColors()->push_back(Color4f(0.0, 1.0, 0.0, 0.75));
            ExampleGradientLayer->editMFStops()->push_back(0.5);
            ExampleGradientLayer->editMFColors()->push_back(Color4f(0.0, 0.0, 1.0, 0.5));
            ExampleGradientLayer->editMFStops()->push_back(1.0);
            ExampleGradientLayer->setStartPosition(Vec2f(0.2f,0.2f));
            ExampleGradientLayer->setEndPosition(Vec2f(.6f,0.6f));
            ExampleGradientLayer->setSpreadMethod(GradientLayer::SPREAD_REFLECT);
            
        /******************************************************

                The MaterialLayer is a Background
                which is created using a Material (also
                created here).

                -setMaterial(MaterialName): Determine
                    which Material will be used to 
                    create the Background.

        ******************************************************/    
        // Creates Material
        ChunkMaterialRefPtr LayerMaterial = ChunkMaterial::create();
        MaterialChunkRefPtr LayerMaterialChunk = MaterialChunk::create();
          LayerMaterialChunk->setAmbient(Color4f(1.0,0.0,0.0,1.0));
          LayerMaterialChunk->setDiffuse(Color4f(0.0,1.0,0.0,1.0));
          LayerMaterialChunk->setSpecular(Color4f(0.0,0.0,1.0,1.0));

            LayerMaterial->addChunk(LayerMaterialChunk);

        // Edit MaterialLayer
            ExampleMaterialLayer->setMaterial(LayerMaterial);
            
        /******************************************************

                The TextureLayer is a Background
                which is created using a Texture (also
                created here).

                -setTexture(TextureName): Determine
                    which Texture will be used to 
                    create the Background.

        ******************************************************/   
        // Creates Texture from Image
        TextureObjChunkRefPtr LayerTextureObjChunk = TextureObjChunk::create();
        ImageRefPtr LoadedImage = ImageFileHandler::the()->read("Data/Checker.jpg");    
            LayerTextureObjChunk->setImage(LoadedImage);

        // Edit TextureLayer
            ExampleTextureLayer->setTexture(LayerTextureObjChunk);

        /******************************************************

                The PatternLayer is a Background
                which is created using a Texture (also
                created here).

                -setTexture(TextureName): Determine
                    which Texture will be used to 
                    create the Background.
                -setPatternSize(Vec2f):
                -setVerticalAlignment():
                -setHorizontalAlignment():
                -setHorizontalRepeat():
                -setVerticalRepeat():
                -setHorizontalRepeatValue():
                -setVerticalRepeatValue():

        ******************************************************/  
        
       TextureObjChunkRefPtr LayerPatternChunk = TextureObjChunk::create();
       //ImageRefPtr LoadedImage = ImageFileHandler::the()->read("Data/Checker.jpg");    
            LayerPatternChunk->setImage(LoadedImage);
            LayerPatternChunk->setWrapS(GL_REPEAT);
            LayerPatternChunk->setWrapT(GL_CLAMP_TO_EDGE);

            ExamplePatternLayer->setTexture(LayerPatternChunk);
            ExamplePatternLayer->setPatternSize(Vec2f(50.0f,50.0f));
            ExamplePatternLayer->setVerticalAlignment(0.5);
            ExamplePatternLayer->setHorizontalAlignment(0.0);
            ExamplePatternLayer->setHorizontalRepeat(PatternLayer::PATTERN_REPEAT_BY_POINT);
            ExamplePatternLayer->setVerticalRepeat(PatternLayer::PATTERN_REPEAT_ABSOLUTE);
            ExamplePatternLayer->setHorizontalRepeatValue(1.0);
            ExamplePatternLayer->setVerticalRepeatValue(2.0);
        /******************************************************

        ******************************************************/
        ExampleGlassLayer->setCenterColor(Color4f(1.0f,1.0f,1.0f,0.0f));
        ExampleGlassLayer->setEdgeColor(Color4f(1.0f,1.0f,1.0f,0.7f));

        /******************************************************

        ******************************************************/
        ExampleGlassCompoundLayer->pushToBackgrounds(ExampleColorLayer);
        ExampleGlassCompoundLayer->pushToBackgrounds(ExampleGlassLayer);
        
        /******************************************************

                Create and edit Button Components to
                display the Layers.

        ******************************************************/

        ButtonRefPtr ExampleColorLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleCompoundLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleEmptyLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleGradientLayerButton = OSG::Button::create();    
        ButtonRefPtr ExampleMaterialLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleTextureLayerButton = OSG::Button::create();
        ButtonRefPtr ExamplePatternLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleGlassLayerButton = OSG::Button::create();
        ButtonRefPtr ExampleGlassCompoundLayerButton = OSG::Button::create();
        

            ExampleColorLayerButton->setText("Color Layer");
            ExampleColorLayerButton->setBackground(ExampleColorLayer);
            ExampleColorLayerButton->setActiveBackground(ExampleColorLayer);
            ExampleColorLayerButton->setRolloverBackground(ExampleColorLayer);
            ExampleColorLayerButton->setPreferredSize(Vec2f(150,50));

            ExampleCompoundLayerButton->setText("Compound Layer");
            ExampleCompoundLayerButton->setBackground(ExampleCompoundLayer);
            ExampleCompoundLayerButton->setActiveBackground(ExampleCompoundLayer);
            ExampleCompoundLayerButton->setRolloverBackground(ExampleCompoundLayer);
            ExampleCompoundLayerButton->setPreferredSize(Vec2f(150,50));

            ExampleEmptyLayerButton->setText("Empty Layer");
            ExampleEmptyLayerButton->setBackground(ExampleEmptyLayer);
            ExampleEmptyLayerButton->setActiveBackground(ExampleEmptyLayer);
            ExampleEmptyLayerButton->setRolloverBackground(ExampleEmptyLayer);
            ExampleEmptyLayerButton->setPreferredSize(Vec2f(150,50));

            ExampleGradientLayerButton->setText("Gradient Layer");
            ExampleGradientLayerButton->setBackground(ExampleGradientLayer);
            ExampleGradientLayerButton->setActiveBackground(ExampleGradientLayer);
            ExampleGradientLayerButton->setRolloverBackground(ExampleGradientLayer);
            ExampleGradientLayerButton->setPreferredSize(Vec2f(150,50));
        
            ExampleMaterialLayerButton->setText("Material Layer");
            ExampleMaterialLayerButton->setBackground(ExampleMaterialLayer);
            ExampleMaterialLayerButton->setActiveBackground(ExampleMaterialLayer);
            ExampleMaterialLayerButton->setRolloverBackground(ExampleMaterialLayer);
            ExampleMaterialLayerButton->setPreferredSize(Vec2f(150,50));
            ExampleMaterialLayerButton->setTextColor(Color4f(1.0,1.0,1.0,1.0));
            ExampleMaterialLayerButton->setRolloverTextColor(Color4f(1.0,1.0,1.0,1.0));
            ExampleMaterialLayerButton->setActiveTextColor(Color4f(1.0,1.0,1.0,1.0));

            ExampleTextureLayerButton->setText("Texture Layer");
            ExampleTextureLayerButton->setBackground(ExampleTextureLayer);
            ExampleTextureLayerButton->setActiveBackground(ExampleTextureLayer);
            ExampleTextureLayerButton->setRolloverBackground(ExampleTextureLayer);
            ExampleTextureLayerButton->setPreferredSize(Vec2f(150,50));
            ExampleTextureLayerButton->setTextColor(Color4f(0.0,1.0,0.0,1.0));
            ExampleTextureLayerButton->setRolloverTextColor(Color4f(0.0,1.0,0.0,1.0));
            ExampleTextureLayerButton->setActiveTextColor(Color4f(0.0,1.0,0.0,1.0));
        
            ExamplePatternLayerButton->setText("Pattern Layer");
            ExamplePatternLayerButton->setBackground(ExamplePatternLayer);
            ExamplePatternLayerButton->setActiveBackground(ExamplePatternLayer);
            ExamplePatternLayerButton->setRolloverBackground(ExamplePatternLayer);
            ExamplePatternLayerButton->setPreferredSize(Vec2f(150,50));
            ExamplePatternLayerButton->setTextColor(Color4f(0.0,1.0,0.0,1.0));
            ExamplePatternLayerButton->setRolloverTextColor(Color4f(0.0,1.0,0.0,1.0));
            ExamplePatternLayerButton->setActiveTextColor(Color4f(0.0,1.0,0.0,1.0));
        
            ExampleGlassLayerButton->setText("Glass Layer");
            ExampleGlassLayerButton->setBackground(ExampleGlassLayer);
            ExampleGlassLayerButton->setActiveBackground(ExampleGlassLayer);
            ExampleGlassLayerButton->setRolloverBackground(ExampleGlassLayer);
            ExampleGlassLayerButton->setPreferredSize(Vec2f(150,50));
            ExampleGlassLayerButton->setTextColor(Color4f(0.0,0.0,0.0,1.0));
            ExampleGlassLayerButton->setRolloverTextColor(Color4f(0.0,0.0,0.0,1.0));
            ExampleGlassLayerButton->setActiveTextColor(Color4f(0.0,0.0,0.0,1.0));
        
            ExampleGlassCompoundLayerButton->setText("GlassCompound Layer");
            ExampleGlassCompoundLayerButton->setBackground(ExampleGlassCompoundLayer);
            ExampleGlassCompoundLayerButton->setActiveBackground(ExampleGlassCompoundLayer);
            ExampleGlassCompoundLayerButton->setRolloverBackground(ExampleGlassCompoundLayer);
            ExampleGlassCompoundLayerButton->setPreferredSize(Vec2f(150,50));
            ExampleGlassCompoundLayerButton->setTextColor(Color4f(0.0,0.0,0.0,1.0));
            ExampleGlassCompoundLayerButton->setRolloverTextColor(Color4f(0.0,0.0,0.0,1.0));
            ExampleGlassCompoundLayerButton->setActiveTextColor(Color4f(0.0,0.0,0.0,1.0));


        
        /******************************************************

                Create a MainFrameBackground.  For almost
                all Tutorials, this is simply a 
                ColorLayer with a semi-transparent
                white Background.

        ******************************************************/

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
            MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        //InternalWindow Layout
        LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

        InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();

           MainInternalWindow->pushToChildren(ExampleColorLayerButton);
           MainInternalWindow->pushToChildren(ExampleCompoundLayerButton);
           MainInternalWindow->pushToChildren(ExampleEmptyLayerButton);
           MainInternalWindow->pushToChildren(ExampleGradientLayerButton);
           MainInternalWindow->pushToChildren(ExampleMaterialLayerButton);
           MainInternalWindow->pushToChildren(ExampleTextureLayerButton);
           MainInternalWindow->pushToChildren(ExamplePatternLayerButton);
           MainInternalWindow->pushToChildren(ExampleGlassLayerButton);
           MainInternalWindow->pushToChildren(ExampleGlassCompoundLayerButton);
           MainInternalWindow->setLayout(MainInternalWindowLayout);
           MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
           MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
           MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
           MainInternalWindow->setDrawTitlebar(false);
           MainInternalWindow->setResizable(false);
        
        // Create the Drawing Surface
        UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
            TutorialDrawingSurface->setGraphics(TutorialGraphics);
            TutorialDrawingSurface->setEventProducer(TutorialWindow);
        
        TutorialDrawingSurface->openWindow(MainInternalWindow);

        // Create the UI Foreground Object
        UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

            TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Create the SimpleSceneManager helper
        sceneManager->setRoot(scene);

        // Add the UI Foreground Object to the Scene
        ViewportRefPtr TutorialViewport = sceneManager->getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);

        //Create the Documentation Foreground and add it to the viewport
        SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow);

        // Show the whole Scene
        sceneManager->showAll();

        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                WinSize,
                "04Background");

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}