VISH  0.2
MouseBackground.cpp

A background which reacts on the mouse movement.

#include <ocean/GLvish/VGLRenderObject.hpp>
#include <ocean/shrimp/VInteractionEvent.hpp>
#include <ocean/plankton/VCreator.hpp>
#include <ocean/plankton/VTime.hpp>

using namespace Wizt;

namespace
{

class   MouseBackground : public VGLRenderObject
{
        TypedSlot<VInteractionEvent>    Interaction;
        TypedSlot<int>                  Blue;

        override void render(VGLRenderContext&Context) const
        {
        GLclampf blue=1, alpha=1; 

                // Blue is an integer input parameter
        int     b=100; 
                Blue << Context >> b;
                blue  = b/100.; 

                // Get the value of the mouse parameter
        VInteractionEvent mp; 
                Interaction << Context >> mp; 

        VRenderContext::Geometry VP = Context.viewport();

                glClearColor( float(mp.x)/(1+VP.width()),
                              float(mp.y)/(1+VP.height()),
                              blue,
                              alpha );

                glClear(GL_COLOR_BUFFER_BIT); 
        }

public:
        const std::type_info&getType() const 
        {
                return typeid( MouseBackground );
        }

        MouseBackground(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
        : VGLRenderObject(name, BACKGROUND_OBJECT+p, VP)
        , Interaction(this, "mouse", VInteractionEvent(), 0 )
        , Blue(this, "blue", 53,  new VCreationPreferences("local") )
        {}

};

static Ref<VCreator<MouseBackground> > myBackground("Backgrounds/MouseBackground", ObjectQuality::DEMO);

}

VISH_DEFAULT_INIT