Ported osgUtil, osgDB, osgGA, NodeKits and plugins to compile against OpenGL ES 1.1 and OpenGL ES 2.0.

This commit is contained in:
Robert Osfield
2009-10-28 20:31:57 +00:00
parent 7e7135be59
commit d17d7159a1
37 changed files with 318 additions and 146 deletions

View File

@@ -904,28 +904,4 @@ void Font::Glyph::subload() const
"\t 0x"<<(GLenum)getDataType()<<std::endl<<
"\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl;
}
}
void Font::Glyph::draw(osg::State& state) const
{
GLuint& globj = _globjList[state.getContextID()];
// call the globj if already set otherwise compile and execute.
if( globj != 0 )
{
glCallList( globj );
}
else
{
globj = glGenLists( 1 );
glNewList( globj, GL_COMPILE_AND_EXECUTE );
glPixelStorei(GL_UNPACK_ALIGNMENT,getPacking());
glDrawPixels(s(), t(),
(GLenum)getPixelFormat(),
(GLenum)getDataType(),
data() );
glEndList();
}
}
}

View File

@@ -1351,9 +1351,9 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
if (_drawMode & FILLEDBOUNDINGBOX)
{
if (_textBB.valid())
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);
const osg::Matrix& matrix = _autoTransformCache[contextID]._matrix;
@@ -1406,6 +1406,9 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
glDisable(GL_POLYGON_OFFSET_FILL);
glPopAttrib();
}
#else
osg::notify(osg::NOTICE)<<"Warning: Text::drawImplementation() fillMode FILLEDBOUNDINGBOX not supported"<<std::endl;
#endif
}
}
@@ -1814,7 +1817,7 @@ void Text::drawForegroundText(osg::State& state, const GlyphQuads& glyphquad, co
if(_colorGradientMode == SOLID)
{
state.disableColorPointer();
glColor4f(colorMultiplier.r()*_color.r(),colorMultiplier.g()*_color.g(),colorMultiplier.b()*_color.b(),colorMultiplier.a()*_color.a());
state.Color(colorMultiplier.r()*_color.r(),colorMultiplier.g()*_color.g(),colorMultiplier.b()*_color.b(),colorMultiplier.a()*_color.a());
}
else
{
@@ -1845,9 +1848,9 @@ void Text::renderOnlyForegroundText(osg::State& state, const osg::Vec4& colorMul
void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
unsigned int contextID = state.getContextID();
if (!osg::PolygonOffset::areFactorAndUnitsMultipliersSet())
{
osg::PolygonOffset::setFactorAndUnitsMultipliersUsingBestGuessForDriver();
@@ -1902,11 +1905,15 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
}
glPopAttrib();
#else
osg::notify(osg::NOTICE)<<"Warning: Text::renderWithPolygonOffset(..) not implemented."<<std::endl;
#endif
}
void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
unsigned int contextID = state.getContextID();
glPushAttrib(GL_DEPTH_BUFFER_BIT);
@@ -1952,11 +1959,15 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
}
glPopAttrib();
#else
osg::notify(osg::NOTICE)<<"Warning: Text::renderWithNoDepthBuffer(..) not implemented."<<std::endl;
#endif
}
// This idea comes from Paul Martz's OpenGL FAQ: 13.050
void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
unsigned int contextID = state.getContextID();
// Hmmm, the man page says GL_VIEWPORT_BIT for Depth range (near and far)
@@ -2009,10 +2020,14 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
}
glPopAttrib();
#else
osg::notify(osg::NOTICE)<<"Warning: Text::renderWithDepthRange(..) not implemented."<<std::endl;
#endif
}
void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
/* Here are the steps:
* 1) Disable drawing color
* 2) Enable the stencil buffer
@@ -2166,4 +2181,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
}
glPopAttrib();
#else
osg::notify(osg::NOTICE)<<"Warning: Text::renderWithStencilBuffer(..) not implemented."<<std::endl;
#endif
}

View File

@@ -12,7 +12,9 @@
*/
#include <osgText/Text3D>
#include <osg/Vec3d>
#include <osg/io_utils>
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<osg::RefMatrix> 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<osg::RefMatrix> 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<osg::RefMatrix> 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<osg::RefMatrix> 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();
}
}
}