VISH  0.2
Classes
OpenGL Cacheing Mechanisms

Classes


Detailed Description

See also:
The OpenGL Interface of Vish

The GLCache interface is supposed to make display lists relative to some viewer context. Viewers may share their context (if on the same card and screen), or each have their own. Though, a certain VObject might of course well have more than one display list, so the GLCache interface allows to specify some parameters, that correspond to a certain rendering. For instance, imagine you have a "ScaleFactor" double parameter that determines the size of the stars. You switch the star size from 0.2 to 0.4 to 0.6 and then go back to 0.4 . Imagine that this is an algorithm that requires creating a new display list for each "ScaleFactor" value. So, you could indeed create a new one, each time the value is changed. But it were more efficient to re-use the display list for 0.4 when going back to it, as this is work that already has been done. This is what the GLCache interface is for. The interface for this looks like that:

class   SurfaceView
{
        TypedSlot<double> ScaleFactor;
        void render(VRenderContext&Context) const;
};

void SurfaceView::render(VRenderContext&Context) const
{
RefPtr<FieldState> myState = getState(Context); 
        if (!myState)
                return; 

RefPtr<DisplayList> DL = Context(*myState->CellField) ( ScaleFactor(Context) ); 
       if (DL)
       {
                DL->call();
                puts("calling list..."); 
                return;
       }
       if (DL) puts("CREATE DL"); 
       else    puts("NO DL Createable!?");

        if (DL) DL->begin_compile();

        glEnable(GL_LINE_SMOOTH); 

        ... DO OpenGL rendering ...

        if (DL) DL->end_compile();
}

Note that the usage of DisplayLists is deprecated in OpenGL and use of Vertex Buffer Objects (VBO) is encourage. The latter come with some memory management in Vish.