Fixed handling of GL function pointer setup for GLES1/GLES2 targets
Dropped the fixed function pipeline defaults from StateSet and SceneView.
This commit is contained in:
parent
9c5409ad8a
commit
08903d65a1
@ -328,7 +328,7 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
|
||||
|
||||
_glVersion = asciiToFloat( version );
|
||||
_glslLanguageVersion = 0.0f;
|
||||
|
||||
|
||||
_isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
|
||||
_isVertexShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
|
||||
_isFragmentShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_shader");
|
||||
@ -336,6 +336,15 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
|
||||
_isGeometryShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_geometry_shader4");
|
||||
_isGpuShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_gpu_shader4");
|
||||
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
_glVersion = 2.0;
|
||||
_isShaderObjectsSupported = true;
|
||||
_isVertexShaderSupported = true;
|
||||
_isFragmentShaderSupported = true;
|
||||
_isLanguage100Supported = true;
|
||||
#endif
|
||||
|
||||
if( isGlslSupported() )
|
||||
{
|
||||
// If glGetString raises an error, assume initial release "1.00"
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
typedef std::set<std::string> ExtensionSet;
|
||||
static osg::buffered_object<ExtensionSet> s_glExtensionSetList;
|
||||
static osg::buffered_object<std::string> s_glRendererList;
|
||||
@ -315,7 +316,6 @@ std::string& osg::getGLExtensionDisableString()
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
||||
void* osg::getGLExtensionFuncPtr(const char *funcName)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
@ -367,15 +367,16 @@ void* osg::getGLExtensionFuncPtr(const char *funcName)
|
||||
|
||||
typedef void (*__GLXextFuncPtr)(void);
|
||||
typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*);
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType<GetProcAddressARBProc, void*>(dlsym(0, "glXGetProcAddressARB"));
|
||||
if (s_glXGetProcAddressARB)
|
||||
{
|
||||
return convertPointerType<void*, __GLXextFuncPtr>((s_glXGetProcAddressARB)(funcName));
|
||||
}
|
||||
else
|
||||
{
|
||||
return dlsym(0, funcName);
|
||||
}
|
||||
#endif
|
||||
|
||||
return dlsym(0, funcName);
|
||||
|
||||
#else // all other unixes
|
||||
|
||||
|
@ -913,12 +913,10 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||
}
|
||||
|
||||
State& state = *renderInfo.getState();
|
||||
Drawable::Extensions* extensions = Drawable::getExtensions(state.getContextID(),true);
|
||||
|
||||
bool useFastPath = areFastPathsUsed();
|
||||
|
||||
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
||||
bool handleVertexAttributes = !_vertexAttribList.empty() && extensions->isVertexProgramSupported();
|
||||
bool handleVertexAttributes = !_vertexAttribList.empty();
|
||||
|
||||
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
||||
|
||||
|
@ -533,12 +533,17 @@ void StateSet::setGlobalDefaults()
|
||||
|
||||
|
||||
setMode(GL_DEPTH_TEST,StateAttribute::ON);
|
||||
// setAttributeAndModes(new AlphaFunc,StateAttribute::OFF);
|
||||
setAttributeAndModes(new BlendFunc,StateAttribute::OFF);
|
||||
|
||||
Material *material = new Material;
|
||||
material->setColorMode(Material::AMBIENT_AND_DIFFUSE);
|
||||
setAttributeAndModes(material,StateAttribute::ON);
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
|
||||
// setAttributeAndModes(new AlphaFunc,StateAttribute::OFF);
|
||||
setAttributeAndModes(new BlendFunc,StateAttribute::OFF);
|
||||
|
||||
Material *material = new Material;
|
||||
material->setColorMode(Material::AMBIENT_AND_DIFFUSE);
|
||||
setAttributeAndModes(material,StateAttribute::ON);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,19 +209,21 @@ void SceneView::setDefaults(unsigned int options)
|
||||
|
||||
if ((options & HEADLIGHT) || (options & SKY_LIGHT))
|
||||
{
|
||||
_lightingMode=(options&HEADLIGHT) ? HEADLIGHT : SKY_LIGHT;
|
||||
_light = new osg::Light;
|
||||
_light->setLightNum(0);
|
||||
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
|
||||
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
|
||||
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
_lightingMode=(options&HEADLIGHT) ? HEADLIGHT : SKY_LIGHT;
|
||||
_light = new osg::Light;
|
||||
_light->setLightNum(0);
|
||||
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
|
||||
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
|
||||
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
|
||||
_globalStateSet->setAssociatedModes(_light.get(),osg::StateAttribute::ON);
|
||||
|
||||
// enable lighting by default.
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
_globalStateSet->setAssociatedModes(_light.get(),osg::StateAttribute::ON);
|
||||
|
||||
// enable lighting by default.
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
osg::LightModel* lightmodel = new osg::LightModel;
|
||||
lightmodel->setAmbientIntensity(osg::Vec4(0.1f,0.1f,0.1f,1.0f));
|
||||
@ -268,11 +270,13 @@ void SceneView::setDefaults(unsigned int options)
|
||||
|
||||
_globalStateSet->setGlobalDefaults();
|
||||
|
||||
// set up an texture environment by default to speed up blending operations.
|
||||
osg::TexEnv* texenv = new osg::TexEnv;
|
||||
texenv->setMode(osg::TexEnv::MODULATE);
|
||||
_globalStateSet->setTextureAttributeAndModes(0,texenv, osg::StateAttribute::ON);
|
||||
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
// set up an texture environment by default to speed up blending operations.
|
||||
osg::TexEnv* texenv = new osg::TexEnv;
|
||||
texenv->setMode(osg::TexEnv::MODULATE);
|
||||
_globalStateSet->setTextureAttributeAndModes(0,texenv, osg::StateAttribute::ON);
|
||||
#endif
|
||||
|
||||
_camera->setClearColor(osg::Vec4(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
}
|
||||
|
||||
@ -670,12 +674,14 @@ void SceneView::setLightingMode(LightingMode mode)
|
||||
|
||||
if (_lightingMode!=NO_SCENEVIEW_LIGHT)
|
||||
{
|
||||
// add GL_LIGHTING mode
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
if (_light.valid())
|
||||
{
|
||||
_globalStateSet->setAssociatedModes(_light.get(), osg::StateAttribute::ON);
|
||||
}
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
// add GL_LIGHTING mode
|
||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
if (_light.valid())
|
||||
{
|
||||
_globalStateSet->setAssociatedModes(_light.get(), osg::StateAttribute::ON);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -938,20 +944,22 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
renderStage->setCamera(_camera.get());
|
||||
#endif
|
||||
|
||||
switch(_lightingMode)
|
||||
{
|
||||
case(HEADLIGHT):
|
||||
if (_light.valid()) renderStage->addPositionedAttribute(NULL,_light.get());
|
||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide head light.*/"<<std::endl;
|
||||
break;
|
||||
case(SKY_LIGHT):
|
||||
if (_light.valid()) renderStage->addPositionedAttribute(mv.get(),_light.get());
|
||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<<std::endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
switch(_lightingMode)
|
||||
{
|
||||
case(HEADLIGHT):
|
||||
if (_light.valid()) renderStage->addPositionedAttribute(NULL,_light.get());
|
||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide head light.*/"<<std::endl;
|
||||
break;
|
||||
case(SKY_LIGHT):
|
||||
if (_light.valid()) renderStage->addPositionedAttribute(mv.get(),_light.get());
|
||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<<std::endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_globalStateSet.valid()) cullVisitor->pushStateSet(_globalStateSet.get());
|
||||
if (_localStateSet.valid()) cullVisitor->pushStateSet(_localStateSet.get());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user