Example #1
0
bool PolygonChunk::operator ==(const StateChunk &other) const
{
    PolygonChunk const *tother = dynamic_cast<PolygonChunk const*>(&other);

    if(!tother)
        return false;

    if(tother == this)
        return true;

    if(getCullFace()          != tother->getCullFace()      ||
       getFrontFace()         != tother->getFrontFace()     ||
       getSmooth()            != tother->getSmooth()        ||
       getFrontMode()         != tother->getFrontMode()     ||
       getBackMode()          != tother->getBackMode()      ||
       getOffsetPoint()       != tother->getOffsetPoint()   ||
       getOffsetLine()        != tother->getOffsetLine()    ||
       getOffsetFill()        != tother->getOffsetFill()    ||
       getOffsetFactor()      != tother->getOffsetFactor()  ||
       getOffsetBias()        != tother->getOffsetBias()    ||
       getMFStipple()->size() != tother->getMFStipple()->size()
      )
        return false;

    // would need to compare the whole stipple data
    // cheap trick: if != 0 take as different
    
    if(        getMFStipple()->size() != 0 ||
       tother->getMFStipple()->size() != 0 
      )
        return false;

    return true;
}
bool PointChunk::operator == (const StateChunk &other) const
{
    PointChunk const *tother = dynamic_cast<PointChunk const*>(&other);

    if(!tother)
        return false;

    if(tother == this)
        return true;

    if(getSize()                    != tother->getSize()                    ||
       getSmooth()                  != tother->getSmooth()                  ||
       getMinSize()                 != tother->getMinSize()                 ||
       getMaxSize()                 != tother->getMaxSize()                 ||
       getConstantAttenuation()     != tother->getConstantAttenuation()     ||
       getLinearAttenuation()       != tother->getLinearAttenuation()       ||
       getQuadraticAttenuation()    != tother->getQuadraticAttenuation()    ||
       getFadeThreshold()           != tother->getFadeThreshold()           ||
       getSprite()                  != tother->getSprite()                  ||
       getRMode()                   != tother->getRMode()                    )
    {
        return false;
    }

    return true;
}
void PointChunk::deactivate(DrawEnv *pEnv, UInt32)
{
#ifndef OSG_OGL_ES2
    if(getSize() != 1.f)
        glPointSize(1.f);
#endif

    Window *pWin = pEnv->getWindow();

    osgSinkUnusedWarning(pWin);

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
    if(getSmooth())
        glDisable(GL_POINT_SMOOTH);
#endif

#if GL_ARB_point_parameters
    if(getMinSize() >= 0.f)
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointParameters, 0x0104))
        {
            OSGGETGLFUNCBYID_GL3( glPointParameterf,
                                  osgGlPointParameterf,
                                 _funcIdPointParameterf,
                                  pWin);
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            OSGGETGLFUNCBYID_GL3( glPointParameterfv,
                                  osgGlPointParameterfv,
                                 _funcIdPointParameterfv,
                                  pWin);
 
            osgGlPointParameterf(GL_POINT_SIZE_MIN_ARB, 0);
            osgGlPointParameterf(GL_POINT_SIZE_MAX_ARB, 1e10);
#endif
            osgGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1);
            
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            GLfloat att[3] = { 1, 0, 0 };
            
            osgGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
#endif
        }
        
    }
#endif

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
#if GL_ARB_point_sprite
    if(getSprite())
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointSpriteARB, 0x0200))
        {
            glDisable(GL_POINT_SPRITE_ARB);
        }
        
    }
#endif
#endif

#if ! defined(GL_ARB_point_parameters) && ! defined(GL_ARB_point_sprite)
    pEnv;
#endif
}
void PointChunk::changeFrom(DrawEnv    *pEnv, 
                            StateChunk *old_chunk, 
                            UInt32               )
{
    PointChunk *old = dynamic_cast<PointChunk *>(old_chunk);

#ifndef OSG_OGL_ES2
    if(getSize() != old->getSize())
        glPointSize(getSize());
#endif

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
    if(getSmooth() && !old->getSmooth())
    {
        glEnable(GL_POINT_SMOOTH);
    }
    else if(!getSmooth() && old->getSmooth())
    {
        glDisable(GL_POINT_SMOOTH);
    }
#endif

    Window *pWin = pEnv->getWindow();

    osgSinkUnusedWarning(pWin);

#if GL_ARB_point_parameters
    if(getMinSize() >= 0.f)
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointParameters, 0x0104))
        {
            OSGGETGLFUNCBYID_GL3( glPointParameterf,
                                  osgGlPointParameterf,
                                 _funcIdPointParameterf,
                                  pWin);
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            OSGGETGLFUNCBYID_GL3( glPointParameterfv,
                                  osgGlPointParameterfv,
                                 _funcIdPointParameterfv,
                                  pWin);

            osgGlPointParameterf(GL_POINT_SIZE_MIN_ARB, getMinSize());
            osgGlPointParameterf(GL_POINT_SIZE_MAX_ARB, getMaxSize());
#endif
            osgGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 
                                 getFadeThreshold());
            
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            GLfloat att[3] = { getConstantAttenuation (),
                               getLinearAttenuation   (),
                               getQuadraticAttenuation() };
            
            osgGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
#endif
        }
        
    }
    else if(old->getMinSize() >= 0.f)
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointParameters, 0x0104))
        {
            OSGGETGLFUNCBYID_GL3( glPointParameterf,
                                  osgGlPointParameterf,
                                 _funcIdPointParameterf,
                                  pWin);
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            OSGGETGLFUNCBYID_GL3( glPointParameterfv,
                                  osgGlPointParameterfv,
                                 _funcIdPointParameterfv,
                                  pWin);

            osgGlPointParameterf(GL_POINT_SIZE_MIN_ARB, 0);
            osgGlPointParameterf(GL_POINT_SIZE_MAX_ARB, 1e10);
#endif
            osgGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1);
            
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
            GLfloat att[3] = { 1, 0, 0 };
            
            osgGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
#endif
        }
    }
#endif

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
#if GL_ARB_point_sprite
    if(getSprite() && !old->getSprite())
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointSpriteARB, 0x0200))
        {
#if GL_NV_point_sprite
            if(pEnv->getWindow()->hasExtension(_extPointSpriteNV))
            {
                OSGGETGLFUNCBYID_GL3( glPointParameterf,
                                      osgGlPointParameterf,
                                     _funcIdPointParameterf,
                                      pWin);

                osgGlPointParameterf(GL_POINT_SPRITE_R_MODE_NV, 
                                     Real32(getRMode()));
            }
#endif
            
            glEnable(GL_POINT_SPRITE_ARB);
        }
        
    }
    else if(!getSprite() && old->getSprite())
    {
        if(pEnv->getWindow()->hasExtOrVersion(_extPointSpriteARB, 0x0200))
        {
           glDisable(GL_POINT_SPRITE_ARB);
        }
        
    }
#endif
#endif

#if ! defined(GL_ARB_point_parameters) && ! defined(GL_ARB_point_sprite)
    pEnv;
#endif
}