diff --git a/src/osg/GL2Extensions.cpp b/src/osg/GL2Extensions.cpp index 680cbbcb9..99779c62c 100644 --- a/src/osg/GL2Extensions.cpp +++ b/src/osg/GL2Extensions.cpp @@ -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" diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index a77b99540..98e639896 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -30,6 +30,7 @@ #include #endif + typedef std::set ExtensionSet; static osg::buffered_object s_glExtensionSetList; static osg::buffered_object s_glRendererList; @@ -315,7 +316,6 @@ std::string& osg::getGLExtensionDisableString() #include #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(dlsym(0, "glXGetProcAddressARB")); if (s_glXGetProcAddressARB) { return convertPointerType((s_glXGetProcAddressARB)(funcName)); } - else - { - return dlsym(0, funcName); - } + #endif + + return dlsym(0, funcName); #else // all other unixes diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 6953fe41e..811276e49 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -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(); diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 0567de9f1..a449c225c 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -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 } diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 9c41356a6..13f9981a2 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -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.*/"<addPositionedAttribute(mv.get(),_light.get()); - else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<addPositionedAttribute(NULL,_light.get()); + else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide head light.*/"<addPositionedAttribute(mv.get(),_light.get()); + else osg::notify(osg::WARN)<<"Warning: no osg::Light attached to ogUtil::SceneView to provide sky light.*/"<pushStateSet(_globalStateSet.get()); if (_localStateSet.valid()) cullVisitor->pushStateSet(_localStateSet.get());