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),
48 SGSceneFeatures::instance()
50 static SGSharedPtr<SGSceneFeatures> sceneFeatures;
54 SGGuard<SGMutex> guard(mutex);
57 sceneFeatures = new SGSceneFeatures;
62 SGSceneFeatures::setTextureCompression(osg::Texture* texture) const
64 switch (_textureCompression) {
65 case UseARBCompression:
66 texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION);
68 case UseDXT1Compression:
69 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT1_COMPRESSION);
71 case UseDXT3Compression:
72 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION);
74 case UseDXT5Compression:
75 texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT5_COMPRESSION);
78 texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
84 SGSceneFeatures::getHavePointSprites(unsigned contextId) const
86 return osg::PointSprite::isPointSpriteSupported(contextId);
90 SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const
92 const osg::FragmentProgram::Extensions* fpe;
93 fpe = osg::FragmentProgram::getExtensions(contextId, true);
96 if (!fpe->isFragmentProgramSupported())
103 SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const
105 const osg::VertexProgram::Extensions* vpe;
106 vpe = osg::VertexProgram::getExtensions(contextId, true);
109 if (!vpe->isVertexProgramSupported())
116 SGSceneFeatures::getHaveShaderPrograms(unsigned contextId) const
118 if (!getHaveFragmentPrograms(contextId))
120 return getHaveVertexPrograms(contextId);
124 SGSceneFeatures::getHavePointParameters(unsigned contextId) const
126 const osg::Point::Extensions* pe;
127 pe = osg::Point::getExtensions(contextId, true);
130 if (!pe->isPointParametersSupported())