osgEarth 2.1.1
Public Member Functions | Private Member Functions | Private Attributes | Friends

osgEarth::Capabilities Class Reference

Inheritance diagram for osgEarth::Capabilities:
Collaboration diagram for osgEarth::Capabilities:

List of all members.

Public Member Functions

int getMaxFFPTextureUnits () const
int getMaxGPUTextureUnits () const
int getMaxGPUTextureCoordSets () const
int getMaxTextureSize () const
int getMaxFastTextureSize () const
int getMaxLights () const
bool supportsGLSL (float minimumVersion=1.0f) const
float getGLSLVersion () const
bool supportsTextureArrays () const
bool supportsTexture3D () const
bool supportsMultiTexture () const
bool supportsStencilWrap () const
bool supportsTwoSidedStencil () const
bool supportsTexture2DLod () const
bool supportsMipmappedTextureUpdates () const

Private Member Functions

 Capabilities ()

Private Attributes

int _maxFFPTextureUnits
int _maxGPUTextureUnits
int _maxGPUTextureCoordSets
int _maxTextureSize
int _maxFastTextureSize
int _maxLights
bool _supportsGLSL
float _GLSLversion
bool _supportsTextureArrays
bool _supportsTexture3D
bool _supportsMultiTexture
bool _supportsStencilWrap
bool _supportsTwoSidedStencil
bool _supportsTexture2DLod
bool _supportsMipmappedTextureUpdates
std::string _vendor
std::string _renderer
std::string _version

Friends

class Registry

Detailed Description

Stores information about the hardware and graphics system capbilities. The osgEarth::Registry stores a singleton Capabilities object that you can use to determine what your system supports.

Definition at line 32 of file Capabilities.


Constructor & Destructor Documentation

Capabilities::Capabilities ( ) [private]

Definition at line 98 of file Capabilities.cpp.

                           :
_maxFFPTextureUnits     ( 1 ),
_maxGPUTextureUnits     ( 1 ),
_maxGPUTextureCoordSets ( 1 ),
_maxTextureSize         ( 256 ),
_maxFastTextureSize     ( 256 ),
_maxLights              ( 1 ),
_supportsGLSL           ( false ),
_GLSLversion            ( 1.0f ),
_supportsTextureArrays  ( false ),
_supportsMultiTexture   ( false ),
_supportsStencilWrap    ( true ),
_supportsTwoSidedStencil( false ),
_supportsTexture2DLod   ( false ),
_supportsMipmappedTextureUpdates( false )
{
    // little hack to force the osgViewer library to link so we can create a graphics context
    osgViewerGetVersion();

    // check the environment in order to disable ATI workarounds
    bool enableATIworkarounds = true;
    if ( ::getenv( "OSGEARTH_DISABLE_ATI_WORKAROUNDS" ) != 0L )
        enableATIworkarounds = false;

    // create a graphics context so we can query OpenGL support:
    MyGraphicsContext mgc;

    if ( mgc.valid() )
    {
        osg::GraphicsContext* gc = mgc._gc.get();
        unsigned int id = gc->getState()->getContextID();
        const osg::GL2Extensions* GL2 = osg::GL2Extensions::Get( id, true );

        OE_INFO << LC << "Detected hardware capabilities:" << std::endl;

        _vendor = std::string( reinterpret_cast<const char*>(glGetString(GL_VENDOR)) );
        OE_INFO << LC << "  Vendor = " << _vendor << std::endl;

        _renderer = std::string( reinterpret_cast<const char*>(glGetString(GL_RENDERER)) );
        OE_INFO << LC << "  Renderer = " << _renderer << std::endl;

        _version = std::string( reinterpret_cast<const char*>(glGetString(GL_VERSION)) );
        OE_INFO << LC << "  Version = " << _version << std::endl;

        glGetIntegerv( GL_MAX_TEXTURE_UNITS, &_maxFFPTextureUnits );
        OE_INFO << LC << "  Max FFP texture units = " << _maxFFPTextureUnits << std::endl;

        glGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &_maxGPUTextureUnits );
        OE_INFO << LC << "  Max GPU texture units = " << _maxGPUTextureUnits << std::endl;

        glGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &_maxGPUTextureCoordSets );
        OE_INFO << LC << "  Max GPU texture coordinate sets = " << _maxGPUTextureCoordSets << std::endl;

        // Use the texture-proxy method to determine the maximum texture size 
        glGetIntegerv( GL_MAX_TEXTURE_SIZE, &_maxTextureSize );
        for( int s = _maxTextureSize; s > 2; s >>= 1 )
        {
            glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, s, s, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0L );
            GLint width = 0;
            glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width );
            if ( width == s )
            {
                _maxTextureSize = s;
                break;
            }
        }
        OE_INFO << LC << "  Max texture size = " << _maxTextureSize << std::endl;

        glGetIntegerv( GL_MAX_LIGHTS, &_maxLights );
        OE_INFO << LC << "  Max lights = " << _maxLights << std::endl;

        _supportsGLSL = GL2->isGlslSupported();
        OE_INFO << LC << "  GLSL = " << SAYBOOL(_supportsGLSL) << std::endl;

        if ( _supportsGLSL )
        {
            _GLSLversion = GL2->getLanguageVersion();
            OE_INFO << LC << "  GLSL Version = " << _GLSLversion << std::endl;
        }

        _supportsTextureArrays = 
            _supportsGLSL &&
            osg::getGLVersionNumber() >= 2.0 && // hopefully this will detect Intel cards
            osg::isGLExtensionSupported( id, "GL_EXT_texture_array" );
        OE_INFO << LC << "  Texture arrays = " << SAYBOOL(_supportsTextureArrays) << std::endl;

        _supportsTexture3D = osg::isGLExtensionSupported( id, "GL_EXT_texture3D" );
        OE_INFO << LC << "  3D textures = " << SAYBOOL(_supportsTexture3D) << std::endl;

        _supportsMultiTexture = 
            osg::getGLVersionNumber() >= 1.3 ||
            osg::isGLExtensionSupported( id, "GL_ARB_multitexture") ||
            osg::isGLExtensionSupported( id, "GL_EXT_multitexture" );
        OE_INFO << LC << "  Multitexturing = " << SAYBOOL(_supportsMultiTexture) << std::endl;

        _supportsStencilWrap = osg::isGLExtensionSupported( id, "GL_EXT_stencil_wrap" );
        OE_INFO << LC << "  Stencil wrapping = " << SAYBOOL(_supportsStencilWrap) << std::endl;

        _supportsTwoSidedStencil = osg::isGLExtensionSupported( id, "GL_EXT_stencil_two_side" );
        OE_INFO << LC << "  2-sided stencils = " << SAYBOOL(_supportsTwoSidedStencil) << std::endl;

        //_supportsTexture2DLod = osg::isGLExtensionSupported( id, "GL_ARB_shader_texture_lod" );
        //OE_INFO << LC << "  texture2DLod = " << SAYBOOL(_supportsTexture2DLod) << std::endl;

        // ATI workarounds:
        bool isATI = _vendor.find("ATI ") == 0;

        _supportsMipmappedTextureUpdates = isATI && enableATIworkarounds ? false : true;
        OE_INFO << LC << "  Mipmapped texture updates = " << SAYBOOL(_supportsMipmappedTextureUpdates) << std::endl;

        // Intel workarounds:
        bool isIntel = 
            _vendor.find("Intel ")   != std::string::npos ||
            _vendor.find("Intel(R)") != std::string::npos;
        _maxFastTextureSize = isIntel ? std::min(2048, _maxTextureSize) : _maxTextureSize;
        OE_INFO << LC << "Max Fast Texture Size = " << _maxFastTextureSize << std::endl;
    }
}

Here is the call graph for this function:


Member Function Documentation

float osgEarth::Capabilities::getGLSLVersion ( ) const [inline]

the GLSL version

Definition at line 58 of file Capabilities.

{ return _GLSLversion; }
int osgEarth::Capabilities::getMaxFastTextureSize ( ) const [inline]

maximum texture size that doesn't cause a slowdown (vendor-specific)

Definition at line 48 of file Capabilities.

{ return _maxFastTextureSize; }

Here is the caller graph for this function:

int osgEarth::Capabilities::getMaxFFPTextureUnits ( ) const [inline]

maximum # of texture units exposed in the fixed-function pipeline

Definition at line 36 of file Capabilities.

{ return _maxFFPTextureUnits; }

Here is the caller graph for this function:

int osgEarth::Capabilities::getMaxGPUTextureCoordSets ( ) const [inline]

maximum # of texture coordinate sets available in a GPU fragment shader

Definition at line 42 of file Capabilities.

int osgEarth::Capabilities::getMaxGPUTextureUnits ( ) const [inline]

maximum # of texture image units exposed in a GPU fragment shader

Definition at line 39 of file Capabilities.

{ return _maxGPUTextureUnits; }

Here is the caller graph for this function:

int osgEarth::Capabilities::getMaxLights ( ) const [inline]

maximum number of openGL lights

Definition at line 51 of file Capabilities.

{ return _maxLights; }

Here is the caller graph for this function:

int osgEarth::Capabilities::getMaxTextureSize ( ) const [inline]

maximum supported size (in pixels) of a texture

Definition at line 45 of file Capabilities.

{ return _maxTextureSize; }
bool osgEarth::Capabilities::supportsGLSL ( float  minimumVersion = 1.0f) const [inline]

whether the GPU supports shaders

Definition at line 54 of file Capabilities.

                                                            { 
            return _supportsGLSL && _GLSLversion >= minimumVersion; }

Here is the caller graph for this function:

bool osgEarth::Capabilities::supportsMipmappedTextureUpdates ( ) const [inline]

whether the GPU properly supports updating an existing texture with a new mipmapped image

Definition at line 79 of file Capabilities.

Here is the caller graph for this function:

bool osgEarth::Capabilities::supportsMultiTexture ( ) const [inline]

whether the GPU supports OpenGL multi-texturing

Definition at line 67 of file Capabilities.

Here is the caller graph for this function:

bool osgEarth::Capabilities::supportsStencilWrap ( ) const [inline]

whether the GPU supports OpenGL stencil wrapping extensions

Definition at line 70 of file Capabilities.

Here is the caller graph for this function:

bool osgEarth::Capabilities::supportsTexture2DLod ( ) const [inline]

whether the GPU support the texture2dLod() function

Definition at line 76 of file Capabilities.

bool osgEarth::Capabilities::supportsTexture3D ( ) const [inline]

whether the GPU supports OpenGL 3D textures

Definition at line 64 of file Capabilities.

{ return _supportsTexture3D; }
bool osgEarth::Capabilities::supportsTextureArrays ( ) const [inline]

whether the GPU supports texture arrays

Definition at line 61 of file Capabilities.

Here is the caller graph for this function:

bool osgEarth::Capabilities::supportsTwoSidedStencil ( ) const [inline]

whether the GPU supports OpenGL the two-sided stenciling extension

Definition at line 73 of file Capabilities.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class Registry [friend]

Definition at line 105 of file Capabilities.


Member Data Documentation

Definition at line 92 of file Capabilities.

Definition at line 89 of file Capabilities.

Definition at line 85 of file Capabilities.

Definition at line 87 of file Capabilities.

Definition at line 86 of file Capabilities.

Definition at line 90 of file Capabilities.

Definition at line 88 of file Capabilities.

std::string osgEarth::Capabilities::_renderer [private]

Definition at line 101 of file Capabilities.

Definition at line 91 of file Capabilities.

Definition at line 99 of file Capabilities.

Definition at line 95 of file Capabilities.

Definition at line 96 of file Capabilities.

Definition at line 98 of file Capabilities.

Definition at line 94 of file Capabilities.

Definition at line 93 of file Capabilities.

Definition at line 97 of file Capabilities.

std::string osgEarth::Capabilities::_vendor [private]

Definition at line 100 of file Capabilities.

std::string osgEarth::Capabilities::_version [private]

Definition at line 102 of file Capabilities.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines