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>
33 #include <simgear/structure/SGSharedPtr.hxx>
34 #include <simgear/threads/SGThread.hxx>
35 #include <simgear/threads/SGGuard.hxx>
37 SGSceneFeatures::SGSceneFeatures() :
39 _pointSpriteLights(true),
40 _distanceAttenuationLights(true)
45 SGSceneFeatures::instance()
47 static SGSharedPtr<SGSceneFeatures> sceneFeatures;
51 SGGuard<SGMutex> guard(mutex);
54 sceneFeatures = new SGSceneFeatures;
59 SGSceneFeatures::getHavePointSprites(unsigned contextId) const
61 return osg::PointSprite::isPointSpriteSupported(contextId);
65 SGSceneFeatures::getHaveFragmentPrograms(unsigned contextId) const
67 const osg::FragmentProgram::Extensions* fpe;
68 fpe = osg::FragmentProgram::getExtensions(contextId, true);
71 if (!fpe->isFragmentProgramSupported())
78 SGSceneFeatures::getHaveVertexPrograms(unsigned contextId) const
80 const osg::VertexProgram::Extensions* vpe;
81 vpe = osg::VertexProgram::getExtensions(contextId, true);
84 if (!vpe->isVertexProgramSupported())
91 SGSceneFeatures::getHaveShaderPrograms(unsigned contextId) const
93 if (!getHaveFragmentPrograms(contextId))
95 return getHaveVertexPrograms(contextId);
99 SGSceneFeatures::getHavePointParameters(unsigned contextId) const
101 const osg::Point::Extensions* pe;
102 pe = osg::Point::getExtensions(contextId, true);
105 if (!pe->isPointParametersSupported())