Hello,

I am trying a get quite a simple issue done using the SwitchPtr.

Instead of dumping the whole source-code here i think it would be better to
explain the thing that i want to do.

I want to load an object using one of the loader built-in within the system,
attach different shader to it and render it using the Switch by selecting
different
shader with keyboard event.

Sound quite simple though, things get complicated if i want to refer to the
same
geometry and render it with different shader and select the particular
shader to be
loaded on the screen using the Switch.

1. I am loading a teapot with the loader and attached a shader to it. STATUS
- SUCCESS.

2. I am creating a new node referring to the same geometry that i have
loaded in step 1 and attached another
    shader to that one.

3. Then i have created a Switch as follows:



    //crate a node with a switch core
    SwitchPtr sw = Switch::create();

    beginEditCP(sw, Switch::ChoiceFieldMask);
        /*the first choice is set to mode
          that will be changed with the
          key-press event
          mode is a static ineger value
          that gets updated with the key-press event
        */
        sw->setChoice(mode);
    endEditCP(sw, Switch::ChoiceFieldMask);

    /*
    Create a Node to hold the switch core
    */
    NodePtr switchNode = Node::create();

    beginEditCP(switchNode);
        switchNode->setCore(sw);
        switchNode->addChild(utah_teapot1);
        switchNode->addChild(utah_teapot2);
    endEditCP(switchNode);



4. And finally i am attaching the node created at step 3 to  the root node
as children.

5. In the keyboard event i have the following code:

       switch(k)
    {
        case 27:
        {
            OSG::osgExit();
            exit(0);
        }
        break;
        case 't': mode = 1; break;
        case 'p': mode = 2; break;

    }


The matter of fact is that i am loading all  the shaders initially while
creating the scene graph,
I just want switch between different shaders with keyboard event.

But i get a blank screen.!!!!!!, even with the keyboard event.


With single shader shader and without Switch i can load the shader and
render on the screen.



Please let me know if any one of you need more information to get around
that issue.


Cheers
Sajjad
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to