diff --git a/applications/osgconv/OrientationConverter.cpp b/applications/osgconv/OrientationConverter.cpp index 9bdc5d160..3abd69bb1 100644 --- a/applications/osgconv/OrientationConverter.cpp +++ b/applications/osgconv/OrientationConverter.cpp @@ -60,8 +60,10 @@ Node* OrientationConverter::convert( Node *node ) if (!S.isIdentity()) { - // Add a normalize state. This will be removed if the FlattenStaticTransformsVisitor works - transform->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + #if !defined(OSG_GLES2_AVAILABLE) + // Add a normalize state. This will be removed if the FlattenStaticTransformsVisitor works + transform->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + #endif } root->addChild(transform); diff --git a/applications/present3D/present3D.cpp b/applications/present3D/present3D.cpp index ba740edb2..92b5396b1 100644 --- a/applications/present3D/present3D.cpp +++ b/applications/present3D/present3D.cpp @@ -723,7 +723,8 @@ int main( int argc, char **argv ) } -#if 1 +#if !defined(OSG_GLES2_AVAILABLE) + // add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins. // the alpha test is required for the volume rendering alpha clipping to work. loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON); diff --git a/include/osg/FrameBufferObject b/include/osg/FrameBufferObject index 293517c3a..9fbeb94a9 100644 --- a/include/osg/FrameBufferObject +++ b/include/osg/FrameBufferObject @@ -108,6 +108,10 @@ #define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 #endif +#ifndef GL_DEPTH_COMPONENT +#define GL_DEPTH_COMPONENT 0x1902 +#endif + #ifndef GL_VERSION_1_4 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 diff --git a/include/osg/PolygonOffset b/include/osg/PolygonOffset index 5a4ce91a7..360fd0490 100644 --- a/include/osg/PolygonOffset +++ b/include/osg/PolygonOffset @@ -16,6 +16,11 @@ #include +#ifndef GL_POLYGON_OFFSET_LINE + #define GL_POLYGON_OFFSET_LINE 0x2A02 + #define GL_POLYGON_OFFSET_POINT 0x2A01 +#endif + namespace osg { /** PolygonOffset - encapsulates the OpenGL glPolygonOffset state.*/ diff --git a/include/osg/Texture b/include/osg/Texture index 41b30ccea..e3406b9fe 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -145,8 +145,7 @@ #endif #ifndef GL_CLAMP - // OpenGL ES1 and ES2 doesn't provide GL_CLAMP but has GL_CLAMP_TO_EDGE - #define GL_CLAMP GL_CLAMP_TO_EDGE + #define GL_CLAMP 0x2900 #endif #ifndef GL_CLAMP_TO_BORDER_ARB diff --git a/include/osgPresentation/SlideShowConstructor b/include/osgPresentation/SlideShowConstructor index f55c8b1b8..8b53aea2b 100644 --- a/include/osgPresentation/SlideShowConstructor +++ b/include/osgPresentation/SlideShowConstructor @@ -391,7 +391,9 @@ protected: osg::StateSet* createTransformStateSet() { osg::StateSet* stateset = new osg::StateSet; - stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON); + #if !defined(OSG_GLES2_AVAILABLE) + stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON); + #endif return stateset; } diff --git a/include/osgText/Font b/include/osgText/Font index 312b5de2d..8dcbb7ef3 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -311,8 +311,6 @@ public: void subload() const; - void draw(osg::State& state) const; - protected: virtual ~Glyph(); diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 2ebf91ffe..19a67dcc2 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -32,28 +32,28 @@ #include "dxtctool.h" #if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) -#define GL_BITMAP 0x1A00 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_COLOR_INDEX 0x1900 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_STENCIL_INDEX 0x1901 -#define GL_RGBA8 0x8058 + #define GL_BITMAP 0x1A00 + #define GL_RED 0x1903 + #define GL_GREEN 0x1904 + #define GL_BLUE 0x1905 + #define GL_COLOR_INDEX 0x1900 + #define GL_DEPTH_COMPONENT 0x1902 + #define GL_INTENSITY12 0x804C + #define GL_INTENSITY16 0x804D + #define GL_INTENSITY4 0x804A + #define GL_INTENSITY8 0x804B + #define GL_LUMINANCE12 0x8041 + #define GL_LUMINANCE12_ALPHA4 0x8046 + #define GL_LUMINANCE12_ALPHA12 0x8047 + #define GL_LUMINANCE16 0x8042 + #define GL_LUMINANCE16_ALPHA16 0x8048 + #define GL_LUMINANCE4 0x803F + #define GL_LUMINANCE4_ALPHA4 0x8043 + #define GL_LUMINANCE6_ALPHA2 0x8044 + #define GL_LUMINANCE8 0x8040 + #define GL_LUMINANCE8_ALPHA8 0x8045 + #define GL_STENCIL_INDEX 0x1901 + #define GL_RGBA8 0x8058 #endif using namespace osg; diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index daf463bfd..c0fedfb69 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -1559,6 +1559,12 @@ void Texture::applyTexParameters(GLenum target, State& state) const if(wr == CLAMP_TO_BORDER) wr = CLAMP; } + + #if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) + if (ws == CLAMP) ws = CLAMP_TO_EDGE; + if (wt == CLAMP) wr = CLAMP_TO_EDGE; + if (wr == CLAMP) wt = CLAMP_TO_EDGE; + #endif const Image * image = getImage(0); if( image && diff --git a/src/osgFX/AnisotropicLighting.cpp b/src/osgFX/AnisotropicLighting.cpp index ef4c5291f..1acad4c83 100644 --- a/src/osgFX/AnisotropicLighting.cpp +++ b/src/osgFX/AnisotropicLighting.cpp @@ -216,7 +216,11 @@ namespace texenv->setMode(osg::TexEnv::DECAL); ss->setTextureAttributeAndModes(0, texenv.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); - ss->setMode( GL_ALPHA_TEST, osg::StateAttribute::OFF ); + #if !defined(OSG_GLES2_AVAILABLE) + ss->setMode( GL_ALPHA_TEST, osg::StateAttribute::OFF ); + #else + osg::notify(osg::NOTICE)<<"Warning: osgFX::AnisotropicLighting unable to disable GL_ALPHA_TEST."<setAttributeAndModes(_wf_mat.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); ss->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); - ss->setTextureMode(0, GL_TEXTURE_1D, osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF); ss->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF); addPass(ss.get()); diff --git a/src/osgFX/SpecularHighlights.cpp b/src/osgFX/SpecularHighlights.cpp index a054a0592..41ad9e7be 100644 --- a/src/osgFX/SpecularHighlights.cpp +++ b/src/osgFX/SpecularHighlights.cpp @@ -50,6 +50,8 @@ namespace void apply(osg::State& state) const { + #ifdef OSG_GL_MATRICES_AVAILABLE + glMatrixMode(GL_TEXTURE); if (_active) { @@ -74,6 +76,9 @@ namespace } glMatrixMode(GL_MODELVIEW); + #else + osg::notify(osg::NOTICE)<<"Warning: osgFX::SpecualHighlights unable to set texture matrix."<getMode(GL_LIGHTING)&osg::StateAttribute::ON); unsigned int mode = osg::StateAttribute::INHERIT|osg::StateAttribute::ON; - _texture = (_stateset->getTextureMode(0,GL_TEXTURE_1D)&mode) || - (_stateset->getTextureMode(0,GL_TEXTURE_2D)&mode) || + + _texture = (_stateset->getTextureMode(0,GL_TEXTURE_2D)&mode) || (_stateset->getTextureMode(0,GL_TEXTURE_3D)&mode) || (_stateset->getTextureMode(0,GL_TEXTURE_RECTANGLE)&mode) || (_stateset->getTextureMode(0,GL_TEXTURE_CUBE_MAP)&mode); + + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + _texture |= (_stateset->getTextureMode(0,GL_TEXTURE_1D)&mode); + #endif } if (ea.getHandled()) return false; @@ -183,11 +187,13 @@ void StateSetManipulator::setTextureEnabled(bool newtexture) if ( _texture ) mode = osg::StateAttribute::INHERIT|osg::StateAttribute::ON; for( unsigned int ii=0; ii<_maxNumOfTextureUnits; ii++ ) { + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) _stateset->setTextureMode( ii, GL_TEXTURE_1D, mode ); - _stateset->setTextureMode( ii, GL_TEXTURE_2D, mode ); - _stateset->setTextureMode( ii, GL_TEXTURE_3D, mode ); - _stateset->setTextureMode( ii, GL_TEXTURE_RECTANGLE, mode ); - _stateset->setTextureMode( ii, GL_TEXTURE_CUBE_MAP, mode); + #endif + _stateset->setTextureMode( ii, GL_TEXTURE_2D, mode ); + _stateset->setTextureMode( ii, GL_TEXTURE_3D, mode ); + _stateset->setTextureMode( ii, GL_TEXTURE_RECTANGLE, mode ); + _stateset->setTextureMode( ii, GL_TEXTURE_CUBE_MAP, mode); } } diff --git a/src/osgManipulator/TrackballDragger.cpp b/src/osgManipulator/TrackballDragger.cpp index e99148c66..45ae7c407 100644 --- a/src/osgManipulator/TrackballDragger.cpp +++ b/src/osgManipulator/TrackballDragger.cpp @@ -132,8 +132,12 @@ void TrackballDragger::setupDefaultGeometry() osg::PolygonMode* polymode = new osg::PolygonMode; polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); geode->getOrCreateStateSet()->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); - geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); geode->getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0f),osg::StateAttribute::ON); + + #if !defined(OSG_GLES2_AVAILABLE) + geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + #endif + } // Add line to all the individual 1D draggers. diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp index cfcab1a6c..67ffad5de 100644 --- a/src/osgParticle/ParticleSystem.cpp +++ b/src/osgParticle/ParticleSystem.cpp @@ -106,27 +106,41 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo osg::Matrix modelview = state.getModelViewMatrix(); // set up depth mask for first rendering pass +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) glPushAttrib(GL_DEPTH_BUFFER_BIT); +#endif + glDepthMask(GL_FALSE); // render, first pass single_pass_render(state, modelview); +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) // restore depth mask settings glPopAttrib(); +#endif // render, second pass if (_doublepass) { // set up color mask for second rendering pass +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) glPushAttrib(GL_COLOR_BUFFER_BIT); +#endif glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // render the particles onto the depth buffer single_pass_render(state, modelview); +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) // restore color mask settings glPopAttrib(); +#endif } + +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) + osg::notify(osg::NOTICE)<<"Warning: ParticleSystem::drawImplementation(..) not fully implemented."<setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON); - _pointStateSet->setMode(GL_VERTEX_PROGRAM_POINT_SIZE, osg::StateAttribute::ON); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + _pointStateSet->setMode(GL_VERTEX_PROGRAM_POINT_SIZE, osg::StateAttribute::ON); + #else + osg::notify(osg::NOTICE)<<"Warning: ParticleEffect::setUpGeometries(..) not fully implemented."<setRenderBinDetails(pointRenderBin,"DepthSortedBin"); } @@ -898,7 +903,10 @@ PrecipitationEffect::PrecipitationDrawable::PrecipitationDrawable(const Precipit void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const { - if (!_geometry) return; +#if defined(OSG_GL_MATRICES_AVAILABLE) + +if (!_geometry) return; + const osg::Geometry::Extensions* extensions = osg::Geometry::getExtensions(renderInfo.getContextID(),true); @@ -970,6 +978,7 @@ void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderI } glPopMatrix(); - - +#else + osg::notify(osg::NOTICE)<<"Warning: ParticleEffect::drawImplementation(..) not fully implemented."< #include @@ -21,6 +20,9 @@ #include "Q3BSPReader.h" #include "Q3BSPLoad.h" +#ifndef GL_RGBA8 + #define GL_RGBA8 0x8058 +#endif using namespace bsp; diff --git a/src/osgPlugins/dds/ReaderWriterDDS.cpp b/src/osgPlugins/dds/ReaderWriterDDS.cpp index 934765b93..306692045 100644 --- a/src/osgPlugins/dds/ReaderWriterDDS.cpp +++ b/src/osgPlugins/dds/ReaderWriterDDS.cpp @@ -35,6 +35,10 @@ #include #include +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) + #define GL_RED 0x1903 + #define GL_LUMINANCE4_ALPHA4 0x8043 +#endif // NOTICE ON WIN32: // typedef DWORD unsigned long; diff --git a/src/osgPlugins/hdr/ReaderWriterHDR.cpp b/src/osgPlugins/hdr/ReaderWriterHDR.cpp index 749a8edaa..52ed2f597 100644 --- a/src/osgPlugins/hdr/ReaderWriterHDR.cpp +++ b/src/osgPlugins/hdr/ReaderWriterHDR.cpp @@ -45,6 +45,15 @@ #include "hdrloader.h" #include "hdrwriter.h" +#ifndef GL_RGBA8 + #define GL_RGBA8 0x8058 +#endif + +#ifndef GL_RGB8 + #define GL_RGB8 0x8051 +#endif + + class ReaderWriterHDR : public osgDB::ReaderWriter { public: diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index 48ed407af..e199a46e0 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -95,6 +95,8 @@ class Logos: public osg::Drawable virtual void drawImplementation(osg::RenderInfo& renderInfo) const { + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + if( renderInfo.getContextID() != _contextID ) return; @@ -164,7 +166,10 @@ class Logos: public osg::Drawable glPopMatrix(); glMatrixMode( GL_PROJECTION ); glPopMatrix(); - glMatrixMode( GL_MODELVIEW ); + glMatrixMode( GL_MODELVIEW ); + #else + osg::notify(osg::NOTICE)<<"Warning: Logos::drawImplementation(..) not supported."< +#include #include #include #include +#include +#include +#include #include #include diff --git a/src/osgPlugins/rgb/ReaderWriterRGB.cpp b/src/osgPlugins/rgb/ReaderWriterRGB.cpp index 620269aa1..8dd5b3c6d 100644 --- a/src/osgPlugins/rgb/ReaderWriterRGB.cpp +++ b/src/osgPlugins/rgb/ReaderWriterRGB.cpp @@ -22,6 +22,14 @@ # define SEEK_SET 0 #endif +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) + #define GL_BITMAP 0x1A00 + #define GL_RED 0x1903 + #define GL_GREEN 0x1904 + #define GL_BLUE 0x1905 + #define GL_COLOR_INDEX 0x1900 +#endif + using namespace osg; diff --git a/src/osgShadow/OccluderGeometry.cpp b/src/osgShadow/OccluderGeometry.cpp index 21eea9693..e51edeb2b 100644 --- a/src/osgShadow/OccluderGeometry.cpp +++ b/src/osgShadow/OccluderGeometry.cpp @@ -947,11 +947,11 @@ void ShadowVolumeGeometry::drawImplementation(osg::RenderInfo& renderInfo) const } else { - glNormal3f(0.0f, 0.0f, 0.0f); + state->Normal(0.0f, 0.0f, 0.0f); } - glColor4f(0.5f, 1.0f, 1.0f, 1.0f); + state->Color(0.5f, 1.0f, 1.0f, 1.0f); glDrawArrays( GL_QUADS, 0, _vertices.size() ); } diff --git a/src/osgShadow/ShadowMap.cpp b/src/osgShadow/ShadowMap.cpp index 5dc9181ce..1ac885665 100644 --- a/src/osgShadow/ShadowMap.cpp +++ b/src/osgShadow/ShadowMap.cpp @@ -313,9 +313,11 @@ void ShadowMap::init() fakeTex->setImage(image); // add fake texture _stateset->setTextureAttribute(_baseTextureUnit,fakeTex,osg::StateAttribute::ON); - _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_2D,osg::StateAttribute::ON); _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_3D,osg::StateAttribute::OFF); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); + #endif } } diff --git a/src/osgShadow/SoftShadowMap.cpp b/src/osgShadow/SoftShadowMap.cpp index b987160e8..b9ee0678d 100755 --- a/src/osgShadow/SoftShadowMap.cpp +++ b/src/osgShadow/SoftShadowMap.cpp @@ -312,7 +312,14 @@ void SoftShadowMap::initJittering(osg::StateSet *ss) // the GPU Gem implementation uses a NV specific internal texture format (GL_SIGNED_RGBA_NV) // In order to make it more generic, we use GL_RGBA4 which should be cross platform. - image3D->setImage(size, size, R, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE, data3D, osg::Image::USE_NEW_DELETE); + #ifdef GL_RGBA4 + GLenum internalTextureFormat = GL_RGBA4; + #else + // OpenGLES 1.1 doesn't define GL_RGBA4, so we'll just assume RGBA + GLenum internalTextureFormat = GL_RGBA; + #endif + image3D->setImage(size, size, R, internalTextureFormat, GL_RGBA, GL_UNSIGNED_BYTE, data3D, osg::Image::USE_NEW_DELETE); + texture3D->setImage(image3D); ss->setTextureAttributeAndModes(_jitterTextureUnit, texture3D, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); diff --git a/src/osgShadow/StandardShadowMap.cpp b/src/osgShadow/StandardShadowMap.cpp index 16715f51e..a5aaa7522 100644 --- a/src/osgShadow/StandardShadowMap.cpp +++ b/src/osgShadow/StandardShadowMap.cpp @@ -478,9 +478,11 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv fakeTex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); _stateset->setTextureAttribute(st->_baseTextureUnit,fakeTex,osg::StateAttribute::ON); - _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_2D,osg::StateAttribute::ON); _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_3D,osg::StateAttribute::OFF); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); + #endif } { // Add shadow texture @@ -582,7 +584,9 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv for( unsigned stage = 1; stage < 4; stage ++ ) { - stateset->setTextureMode( stage, GL_TEXTURE_1D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + stateset->setTextureMode( stage, GL_TEXTURE_1D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); + #endif stateset->setTextureMode( stage, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); stateset->setTextureMode( stage, GL_TEXTURE_3D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); } diff --git a/src/osgSim/LightPointDrawable.cpp b/src/osgSim/LightPointDrawable.cpp index c11997a05..851806c22 100644 --- a/src/osgSim/LightPointDrawable.cpp +++ b/src/osgSim/LightPointDrawable.cpp @@ -84,6 +84,7 @@ void LightPointDrawable::reset() void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const { +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) osg::State& state = *renderInfo.getState(); state.applyMode(GL_POINT_SMOOTH,true); @@ -167,7 +168,9 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const // restore the state afterwards. state.apply(); - +#else + osg::notify(osg::NOTICE)<<"Warning: LightPointDrawable not supported."< +#include #include + namespace osgText { @@ -525,8 +527,10 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const { renderInfo.getState()->disableAllVertexArrays(); - glPushAttrib(GL_TRANSFORM_BIT); - glEnable(GL_RESCALE_NORMAL); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glPushAttrib(GL_TRANSFORM_BIT); + glEnable(GL_RESCALE_NORMAL); + #endif switch(_renderMode) { @@ -535,7 +539,9 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const default: renderPerGlyph(*renderInfo.getState()); break; } - glPopAttrib(); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glPopAttrib(); + #endif } if (_drawMode & BOUNDINGBOX) @@ -615,10 +621,10 @@ void Text3D::renderPerGlyph(osg::State & state) const for (it = itLine->begin(); it!=end; ++it) { - glPushMatrix(); - - glTranslatef(it->_position.x(), it->_position.y(), it->_position.z()); - + osg::ref_ptr matrix = new osg::RefMatrix(state.getModelViewMatrix()); + matrix->preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); + state.applyModelViewMatrix(matrix.get()); + // ** apply the vertex array state.setVertexPointer(it->_glyph->getVertexArray()); @@ -648,8 +654,6 @@ void Text3D::renderPerGlyph(osg::State & state) const { (*itr)->draw(state, false); } - - glPopMatrix(); } } } @@ -666,8 +670,10 @@ void Text3D::renderPerFace(osg::State & state) const LineRenderInfo::const_iterator it, end = itLine->end(); for (it = itLine->begin(); it!=end; ++it) { - glPushMatrix(); - glTranslatef(it->_position.x(), it->_position.y(), it->_position.z()); + osg::ref_ptr matrix = new osg::RefMatrix(state.getModelViewMatrix()); + matrix->preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); + state.applyModelViewMatrix(matrix.get()); + state.setVertexPointer(it->_glyph->getVertexArray()); // ** render the front face of the glyph @@ -676,7 +682,6 @@ void Text3D::renderPerFace(osg::State & state) const { (*itr)->draw(state, false); } - glPopMatrix(); } } @@ -688,8 +693,10 @@ void Text3D::renderPerFace(osg::State & state) const LineRenderInfo::const_iterator it, end = itLine->end(); for (it = itLine->begin(); it!=end; ++it) { - glPushMatrix(); - glTranslatef(it->_position.x(), it->_position.y(), it->_position.z()); + osg::ref_ptr matrix = new osg::RefMatrix(state.getModelViewMatrix()); + matrix->preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); + state.applyModelViewMatrix(matrix.get()); + state.setVertexPointer(it->_glyph->getVertexArray()); state.setNormalPointer(it->_glyph->getNormalArray()); @@ -698,13 +705,12 @@ void Text3D::renderPerFace(osg::State & state) const { (*itr)->draw(state, false); } - glPopMatrix(); } } // ** render all back face of the text - glNormal3f(0.0f,0.0f,-1.0f); + state.Normal(0.0f,0.0f,-1.0f); for (itLine = _textRenderInfo.begin(); itLine!=endLine; ++itLine) { @@ -712,8 +718,10 @@ void Text3D::renderPerFace(osg::State & state) const LineRenderInfo::const_iterator it, end = itLine->end(); for (it = itLine->begin(); it!=end; ++it) { - glPushMatrix(); - glTranslatef(it->_position.x(), it->_position.y(), it->_position.z()); + osg::ref_ptr matrix = new osg::RefMatrix(state.getModelViewMatrix()); + matrix->preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); + state.applyModelViewMatrix(matrix.get()); + state.setVertexPointer(it->_glyph->getVertexArray()); // ** render the back face of the glyph @@ -722,7 +730,6 @@ void Text3D::renderPerFace(osg::State & state) const { (*itr)->draw(state, false); } - glPopMatrix(); } } } diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index f1a705890..8f10a9173 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -466,10 +466,12 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo) // and before call to glCheckFramebufferStatus if ( !colorAttached ) { - setDrawBuffer( GL_NONE, true ); - glDrawBuffer( GL_NONE ); - setReadBuffer( GL_NONE, true ); - glReadBuffer( GL_NONE ); + setDrawBuffer( GL_NONE, true ); + setReadBuffer( GL_NONE, true ); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glDrawBuffer( GL_NONE ); + glReadBuffer( GL_NONE ); + #endif } GLenum status = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); @@ -761,7 +763,9 @@ void RenderStage::copyTexture(osg::RenderInfo& renderInfo) if ( _readBufferApplyMask ) { - glReadBuffer(_readBuffer); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glReadBuffer(_readBuffer); + #endif } // need to implement texture cube map etc... @@ -860,11 +864,15 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b if (!using_multiple_render_targets) { - if( getDrawBufferApplyMask() ) - glDrawBuffer(_drawBuffer); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + + if( getDrawBufferApplyMask() ) + glDrawBuffer(_drawBuffer); - if( getReadBufferApplyMask() ) - glReadBuffer(_readBuffer); + if( getReadBufferApplyMask() ) + glReadBuffer(_readBuffer); + + #endif } if (fbo_supported) @@ -962,21 +970,25 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b { if (read_fbo) SubFunc::applyReadFBO(apply_read_fbo, read_fbo, state); - if (using_multiple_render_targets) - { - int attachment=itr->first; - if (attachment==osg::Camera::DEPTH_BUFFER || attachment==osg::Camera::STENCIL_BUFFER) { - // assume first buffer rendered to is the one we want - glReadBuffer(read_fbo->getMultipleRenderingTargets()[0]); - } else { - glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0)); - } - } else { - if (_readBuffer != GL_NONE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + + if (using_multiple_render_targets) { - glReadBuffer(_readBuffer); + int attachment=itr->first; + if (attachment==osg::Camera::DEPTH_BUFFER || attachment==osg::Camera::STENCIL_BUFFER) { + // assume first buffer rendered to is the one we want + glReadBuffer(read_fbo->getMultipleRenderingTargets()[0]); + } else { + glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0)); + } + } else { + if (_readBuffer != GL_NONE) + { + glReadBuffer(_readBuffer); + } } - } + + #endif GLenum pixelFormat = itr->second._image->getPixelFormat(); if (pixelFormat==0) pixelFormat = _imageReadPixelFormat; @@ -1257,7 +1269,12 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr if (_clearMask & GL_DEPTH_BUFFER_BIT) { - glClearDepth( _clearDepth); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glClearDepth( _clearDepth); + #else + glClearDepthf( _clearDepth); + #endif + glDepthMask ( GL_TRUE ); state.haveAppliedAttribute( osg::StateAttribute::DEPTH ); } @@ -1269,20 +1286,24 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr state.haveAppliedAttribute( osg::StateAttribute::STENCIL ); } - if (_clearMask & GL_ACCUM_BUFFER_BIT) - { - glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]); - } - + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + if (_clearMask & GL_ACCUM_BUFFER_BIT) + { + glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]); + } + #endif + glClear( _clearMask ); -#ifdef USE_SCISSOR_TEST - glDisable( GL_SCISSOR_TEST ); -#endif + #ifdef USE_SCISSOR_TEST + glDisable( GL_SCISSOR_TEST ); + #endif - glMatrixMode( GL_MODELVIEW ); - glLoadIdentity(); + #ifdef OSG_GL_MATRICES_AVAILABLE + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + #endif // apply the positional state. if (_inheritedPositionalStateContainer.valid()) diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 5aa8e0a3a..bbe50a224 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -30,6 +30,12 @@ using namespace osg; using namespace osgUtil; +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) + // define under GLES to keep the main SceneView.cpp clean. + #define GL_BACK_LEFT 0x0402 + #define GL_BACK_RIGHT 0x0403 +#endif + static const GLubyte patternVertEven[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, @@ -1273,6 +1279,7 @@ void SceneView::draw() break; case(osg::DisplaySettings::VERTICAL_INTERLACE): { + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER) ) { _renderStageLeft->setDrawBuffer(_camera->getDrawBuffer()); @@ -1305,12 +1312,14 @@ void SceneView::draw() _interlacedStereoStencilWidth != getViewport()->width() || _interlacedStereoStencilHeight != getViewport()->height() ) { - getViewport()->apply(*state); + state->applyProjectionMatrix(0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(getViewport()->x(), getViewport()->width(), getViewport()->y(), getViewport()->height(), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + getViewport()->apply(*state); getState()->applyMode(GL_LIGHTING,false); getState()->applyMode(GL_DEPTH_TEST,false); glStencilMask(~0u); @@ -1346,10 +1355,14 @@ void SceneView::draw() glStencilFunc(GL_NOTEQUAL, 0, ~0u); _renderStageRight->draw(_renderInfo,previous); glDisable(GL_STENCIL_TEST); + #else + osg::notify(osg::NOTICE)<<"Warning: SceneView::draw() - VERTICAL_INTERLACE stereo not supported."<getInheritanceMask() & DRAW_BUFFER) ) { _renderStageLeft->setDrawBuffer(_camera->getDrawBuffer()); @@ -1382,12 +1395,13 @@ void SceneView::draw() _interlacedStereoStencilWidth != getViewport()->width() || _interlacedStereoStencilHeight != getViewport()->height() ) { - getViewport()->apply(*state); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(getViewport()->x(), getViewport()->width(), getViewport()->y(), getViewport()->height(), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + getViewport()->apply(*state); getState()->applyMode(GL_LIGHTING,false); getState()->applyMode(GL_DEPTH_TEST,false); glStencilMask(~0u); @@ -1423,10 +1437,14 @@ void SceneView::draw() glStencilFunc(GL_NOTEQUAL, 0, ~0u); _renderStageRight->draw(_renderInfo,previous); glDisable(GL_STENCIL_TEST); + #else + osg::notify(osg::NOTICE)<<"Warning: SceneView::draw() - HORIZONTAL_INTERLACE stereo not supported."<getInheritanceMask() & DRAW_BUFFER) ) { _renderStageLeft->setDrawBuffer(_camera->getDrawBuffer()); @@ -1459,12 +1477,15 @@ void SceneView::draw() _interlacedStereoStencilWidth != getViewport()->width() || _interlacedStereoStencilHeight != getViewport()->height() ) { - getViewport()->apply(*state); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(getViewport()->x(), getViewport()->width(), getViewport()->y(), getViewport()->height(), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + + getViewport()->apply(*state); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glStencilMask(~0u); @@ -1500,6 +1521,9 @@ void SceneView::draw() glStencilFunc(GL_NOTEQUAL, 0, ~0u); _renderStageRight->draw(_renderInfo,previous); glDisable(GL_STENCIL_TEST); + #else + osg::notify(osg::NOTICE)<<"Warning: SceneView::draw() - CHECKERBOARD stereo not supported."< #include #include // for ShaderGenVisitor::update +#include #include using namespace osgUtil; diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index 349e94a03..04cf919a6 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -108,16 +108,19 @@ ELSE() SET(OSGVIEWER_USE_XRANDR OFF) ENDIF() - SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} - ${HEADER_PATH}/api/X11/GraphicsWindowX11 - ${HEADER_PATH}/api/X11/PixelBufferX11 - ) + IF(OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE) + ELSE() + SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} + ${HEADER_PATH}/api/X11/GraphicsWindowX11 + ${HEADER_PATH}/api/X11/PixelBufferX11 + ) + + SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} + GraphicsWindowX11.cpp + PixelBufferX11.cpp + ) + ENDIF() - SET(LIB_COMMON_FILES ${LIB_COMMON_FILES} - GraphicsWindowX11.cpp - PixelBufferX11.cpp - ) - IF(OSGVIEWER_USE_XRANDR) ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR) SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XRANDR_INCLUDE_DIRS} ) diff --git a/src/osgViewer/ScreenCaptureHandler.cpp b/src/osgViewer/ScreenCaptureHandler.cpp index b0e53e0cd..d09023712 100644 --- a/src/osgViewer/ScreenCaptureHandler.cpp +++ b/src/osgViewer/ScreenCaptureHandler.cpp @@ -490,7 +490,9 @@ void WindowCaptureCallback::setCaptureOperation(ScreenCaptureHandler::CaptureOpe void WindowCaptureCallback::operator () (osg::RenderInfo& renderInfo) const { +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) glReadBuffer(_readBuffer); +#endif osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext(); osg::ref_ptr cd = getContextData(gc);