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 );
|
_glVersion = asciiToFloat( version );
|
||||||
_glslLanguageVersion = 0.0f;
|
_glslLanguageVersion = 0.0f;
|
||||||
|
|
||||||
_isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
|
_isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
|
||||||
_isVertexShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
|
_isVertexShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
|
||||||
_isFragmentShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_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");
|
_isGeometryShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_geometry_shader4");
|
||||||
_isGpuShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_gpu_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( isGlslSupported() )
|
||||||
{
|
{
|
||||||
// If glGetString raises an error, assume initial release "1.00"
|
// If glGetString raises an error, assume initial release "1.00"
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef std::set<std::string> ExtensionSet;
|
typedef std::set<std::string> ExtensionSet;
|
||||||
static osg::buffered_object<ExtensionSet> s_glExtensionSetList;
|
static osg::buffered_object<ExtensionSet> s_glExtensionSetList;
|
||||||
static osg::buffered_object<std::string> s_glRendererList;
|
static osg::buffered_object<std::string> s_glRendererList;
|
||||||
@ -315,7 +316,6 @@ std::string& osg::getGLExtensionDisableString()
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void* osg::getGLExtensionFuncPtr(const char *funcName)
|
void* osg::getGLExtensionFuncPtr(const char *funcName)
|
||||||
{
|
{
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
@ -367,15 +367,16 @@ void* osg::getGLExtensionFuncPtr(const char *funcName)
|
|||||||
|
|
||||||
typedef void (*__GLXextFuncPtr)(void);
|
typedef void (*__GLXextFuncPtr)(void);
|
||||||
typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*);
|
typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*);
|
||||||
|
|
||||||
|
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||||
static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType<GetProcAddressARBProc, void*>(dlsym(0, "glXGetProcAddressARB"));
|
static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType<GetProcAddressARBProc, void*>(dlsym(0, "glXGetProcAddressARB"));
|
||||||
if (s_glXGetProcAddressARB)
|
if (s_glXGetProcAddressARB)
|
||||||
{
|
{
|
||||||
return convertPointerType<void*, __GLXextFuncPtr>((s_glXGetProcAddressARB)(funcName));
|
return convertPointerType<void*, __GLXextFuncPtr>((s_glXGetProcAddressARB)(funcName));
|
||||||
}
|
}
|
||||||
else
|
#endif
|
||||||
{
|
|
||||||
return dlsym(0, funcName);
|
return dlsym(0, funcName);
|
||||||
}
|
|
||||||
|
|
||||||
#else // all other unixes
|
#else // all other unixes
|
||||||
|
|
||||||
|
@ -913,12 +913,10 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
State& state = *renderInfo.getState();
|
State& state = *renderInfo.getState();
|
||||||
Drawable::Extensions* extensions = Drawable::getExtensions(state.getContextID(),true);
|
|
||||||
|
|
||||||
bool useFastPath = areFastPathsUsed();
|
bool useFastPath = areFastPathsUsed();
|
||||||
|
|
||||||
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
||||||
bool handleVertexAttributes = !_vertexAttribList.empty() && extensions->isVertexProgramSupported();
|
bool handleVertexAttributes = !_vertexAttribList.empty();
|
||||||
|
|
||||||
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
||||||
|
|
||||||
|
@ -533,12 +533,17 @@ void StateSet::setGlobalDefaults()
|
|||||||
|
|
||||||
|
|
||||||
setMode(GL_DEPTH_TEST,StateAttribute::ON);
|
setMode(GL_DEPTH_TEST,StateAttribute::ON);
|
||||||
// setAttributeAndModes(new AlphaFunc,StateAttribute::OFF);
|
|
||||||
setAttributeAndModes(new BlendFunc,StateAttribute::OFF);
|
|
||||||
|
|
||||||
Material *material = new Material;
|
#if !defined(OSG_GLES2_AVAILABLE)
|
||||||
material->setColorMode(Material::AMBIENT_AND_DIFFUSE);
|
|
||||||
setAttributeAndModes(material,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);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,19 +209,21 @@ void SceneView::setDefaults(unsigned int options)
|
|||||||
|
|
||||||
if ((options & HEADLIGHT) || (options & SKY_LIGHT))
|
if ((options & HEADLIGHT) || (options & SKY_LIGHT))
|
||||||
{
|
{
|
||||||
_lightingMode=(options&HEADLIGHT) ? HEADLIGHT : SKY_LIGHT;
|
#if !defined(OSG_GLES2_AVAILABLE)
|
||||||
_light = new osg::Light;
|
_lightingMode=(options&HEADLIGHT) ? HEADLIGHT : SKY_LIGHT;
|
||||||
_light->setLightNum(0);
|
_light = new osg::Light;
|
||||||
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
|
_light->setLightNum(0);
|
||||||
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
|
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
|
||||||
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,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);
|
_globalStateSet->setAssociatedModes(_light.get(),osg::StateAttribute::ON);
|
||||||
|
|
||||||
// enable lighting by default.
|
|
||||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
|
||||||
|
|
||||||
|
// enable lighting by default.
|
||||||
|
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||||
osg::LightModel* lightmodel = new osg::LightModel;
|
osg::LightModel* lightmodel = new osg::LightModel;
|
||||||
lightmodel->setAmbientIntensity(osg::Vec4(0.1f,0.1f,0.1f,1.0f));
|
lightmodel->setAmbientIntensity(osg::Vec4(0.1f,0.1f,0.1f,1.0f));
|
||||||
@ -268,11 +270,13 @@ void SceneView::setDefaults(unsigned int options)
|
|||||||
|
|
||||||
_globalStateSet->setGlobalDefaults();
|
_globalStateSet->setGlobalDefaults();
|
||||||
|
|
||||||
// set up an texture environment by default to speed up blending operations.
|
#if !defined(OSG_GLES2_AVAILABLE)
|
||||||
osg::TexEnv* texenv = new osg::TexEnv;
|
// set up an texture environment by default to speed up blending operations.
|
||||||
texenv->setMode(osg::TexEnv::MODULATE);
|
osg::TexEnv* texenv = new osg::TexEnv;
|
||||||
_globalStateSet->setTextureAttributeAndModes(0,texenv, osg::StateAttribute::ON);
|
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));
|
_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)
|
if (_lightingMode!=NO_SCENEVIEW_LIGHT)
|
||||||
{
|
{
|
||||||
// add GL_LIGHTING mode
|
#if !defined(OSG_GLES2_AVAILABLE)
|
||||||
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
// add GL_LIGHTING mode
|
||||||
if (_light.valid())
|
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||||
{
|
if (_light.valid())
|
||||||
_globalStateSet->setAssociatedModes(_light.get(), osg::StateAttribute::ON);
|
{
|
||||||
}
|
_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());
|
renderStage->setCamera(_camera.get());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(_lightingMode)
|
#if !defined(OSG_GLES2_AVAILABLE)
|
||||||
{
|
switch(_lightingMode)
|
||||||
case(HEADLIGHT):
|
{
|
||||||
if (_light.valid()) renderStage->addPositionedAttribute(NULL,_light.get());
|
case(HEADLIGHT):
|
||||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide head light.*/"<<std::endl;
|
if (_light.valid()) renderStage->addPositionedAttribute(NULL,_light.get());
|
||||||
break;
|
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide head light.*/"<<std::endl;
|
||||||
case(SKY_LIGHT):
|
break;
|
||||||
if (_light.valid()) renderStage->addPositionedAttribute(mv.get(),_light.get());
|
case(SKY_LIGHT):
|
||||||
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<<std::endl;
|
if (_light.valid()) renderStage->addPositionedAttribute(mv.get(),_light.get());
|
||||||
break;
|
else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<<std::endl;
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_globalStateSet.valid()) cullVisitor->pushStateSet(_globalStateSet.get());
|
if (_globalStateSet.valid()) cullVisitor->pushStateSet(_globalStateSet.get());
|
||||||
if (_localStateSet.valid()) cullVisitor->pushStateSet(_localStateSet.get());
|
if (_localStateSet.valid()) cullVisitor->pushStateSet(_localStateSet.get());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user