3 * Copyright (C) 2006-2007 Mathias Froehlich
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 # include <simgear_config.h>
26 #include "SGSceneFeatures.hxx"
28 #include <osg/FragmentProgram>
29 #include <osg/VertexProgram>
31 #include <osg/PointSprite>
32 #include <osg/Texture>
34 #include <simgear/structure/SGSharedPtr.hxx>
35 #include <simgear/threads/SGThread.hxx>
36 #include <simgear/threads/SGGuard.hxx>
38 SGSceneFeatures::SGSceneFeatures() :
39 _textureCompression(UseARBCompression),
41 _pointSpriteLights(true),
42 _distanceAttenuationLights(true)
47 SGSceneFeatures::instance()
49 static SGSharedPtr<SGSceneFeatures> sceneFeatures;
53 SGGuard<SGMutex> guard(mutex);
56 sceneFeatures = new SGSceneFeatures;
61 SGSceneFeatures::setTextureCompression(osg::Texture* texture) const
63 switch (_textureCompression) {
64 case UseARBCompression:
65 texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION);
67 case UseDXT1Compression:
68 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT1_COMPRESSION);
70 case UseDXT3Compression:
71 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION);
73 case UseDXT5Compression:
74 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT5_COMPRESSION);
77 texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
83 SGSceneFeatures::getHavePointSprites(unsigned contextId) const
85 return osg::PointSprite::isPointSpriteSupported(contextId);
89 SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const
91 const osg::FragmentProgram::Extensions* fpe;
92 fpe = osg::FragmentProgram::getExtensions(contextId, true);
95 if (!fpe->isFragmentProgramSupported())
102 SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const
104 const osg::VertexProgram::Extensions* vpe;
105 vpe = osg::VertexProgram::getExtensions(contextId, true);
108 if (!vpe->isVertexProgramSupported())
115 SGSceneFeatures::getHaveShaderPrograms(unsigned contextId) const
117 if (!getHaveFragmentPrograms(contextId))
119 return getHaveVertexPrograms(contextId);
123 SGSceneFeatures::getHavePointParameters(unsigned contextId) const
125 const osg::Point::Extensions* pe;
126 pe = osg::Point::getExtensions(contextId, true);
129 if (!pe->isPointParametersSupported())