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

@ -60,8 +60,10 @@ Node* OrientationConverter::convert( Node *node )
if (!S.isIdentity())
{
#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);

View File

@ -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);

View File

@ -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

View File

@ -16,6 +16,11 @@
#include <osg/StateAttribute>
#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.*/

View File

@ -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

View File

@ -391,7 +391,9 @@ protected:
osg::StateSet* createTransformStateSet()
{
osg::StateSet* stateset = new osg::StateSet;
#if !defined(OSG_GLES2_AVAILABLE)
stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON);
#endif
return stateset;
}

View File

@ -311,8 +311,6 @@ public:
void subload() const;
void draw(osg::State& state) const;
protected:
virtual ~Glyph();

View File

@ -1560,6 +1560,12 @@ void Texture::applyTexParameters(GLenum target, State& state) const
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 &&
image->isMipmap() &&

View File

@ -216,7 +216,11 @@ namespace
texenv->setMode(osg::TexEnv::DECAL);
ss->setTextureAttributeAndModes(0, texenv.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
#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."<<std::endl;
#endif
addPass(ss.get());
}

View File

@ -58,7 +58,6 @@ namespace
ss->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());

View File

@ -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."<<std::endl;
#endif
}
private:

View File

@ -96,11 +96,15 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
_lighting =(_stateset->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,7 +187,9 @@ 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 );
#endif
_stateset->setTextureMode( ii, GL_TEXTURE_2D, mode );
_stateset->setTextureMode( ii, GL_TEXTURE_3D, mode );
_stateset->setTextureMode( ii, GL_TEXTURE_RECTANGLE, mode );

View File

@ -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.

View File

@ -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."<<std::endl;
#endif
}
void osgParticle::ParticleSystem::setDefaultAttributes(const std::string& texturefile, bool emissive_particles, bool lighting, int texture_unit)

View File

@ -729,7 +729,12 @@ void PrecipitationEffect::setUpGeometries(unsigned int numParticles)
osg::PointSprite *sprite = new osg::PointSprite();
_pointStateSet->setTextureAttributeAndModes(0, sprite, 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."<<std::endl;
#endif
_pointStateSet->setRenderBinDetails(pointRenderBin,"DepthSortedBin");
}
@ -898,8 +903,11 @@ PrecipitationEffect::PrecipitationDrawable::PrecipitationDrawable(const Precipit
void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if defined(OSG_GL_MATRICES_AVAILABLE)
if (!_geometry) return;
const osg::Geometry::Extensions* extensions = osg::Geometry::getExtensions(renderInfo.getContextID(),true);
// save OpenGL matrices
@ -970,6 +978,7 @@ void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderI
}
glPopMatrix();
#else
osg::notify(osg::NOTICE)<<"Warning: ParticleEffect::drawImplementation(..) not fully implemented."<<std::endl;
#endif
}

View File

@ -12,7 +12,7 @@
*/
//
// OpenFlight® loader for OpenSceneGraph
// OpenFlight (R) loader for OpenSceneGraph
//
// Copyright (C) 2005-2007 Brede Johansen
//
@ -30,6 +30,17 @@
#include "AttrData.h"
#include "RecordInputStream.h"
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#define GL_RGB5 0x8050
#define GL_RGBA4 0x8056
#define GL_RGBA8 0x8058
#define GL_RGBA12 0x805A
#define GL_RGB12 0x8053
#define GL_LUMINANCE12_ALPHA4 0x8046
#define GL_LUMINANCE12_ALPHA12 0x8047
#define GL_INTENSITY16 0x804D
#endif
namespace flt {
class VertexPalette : public Record

View File

@ -1,4 +1,3 @@
#include <osg/TexEnv>
#include <osg/CullFace>
@ -21,6 +20,9 @@
#include "Q3BSPReader.h"
#include "Q3BSPLoad.h"
#ifndef GL_RGBA8
#define GL_RGBA8 0x8058
#endif
using namespace bsp;

View File

@ -35,6 +35,10 @@
#include <stdio.h>
#include <string.h>
#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;

View File

@ -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:

View File

@ -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;
@ -165,6 +167,9 @@ class Logos: public osg::Drawable
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
#else
osg::notify(osg::NOTICE)<<"Warning: Logos::drawImplementation(..) not supported."<<std::endl;
#endif
}
void addLogo( RelativePosition pos, std::string name )

View File

@ -1,7 +1,11 @@
#include <osg/StateSet>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/TextureCubeMap>
#include <osg/TextureRectangle>
#include <osg/TexGen>
#include <osg/PolygonOffset>
#include <osg/LineStipple>
#include <osgDB/Registry>
#include <osgDB/Input>

View File

@ -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;

View File

@ -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() );
}

View File

@ -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
}
}

View File

@ -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);

View File

@ -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 ++ )
{
#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 );
}

View File

@ -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."<<std::endl;
#endif
}
osg::BoundingBox LightPointDrawable::computeBound() const

View File

@ -30,6 +30,7 @@ LightPointSpriteDrawable::LightPointSpriteDrawable(const LightPointSpriteDrawabl
void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
osg::State& state = *renderInfo.getState();
if (!state.getModeValidity(GL_POINT_SPRITE_ARB))
@ -124,7 +125,9 @@ void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) c
// restore the state afterwards.
state.apply();
#else
osg::notify(osg::NOTICE)<<"Warning: LightPointDrawable not supported."<<std::endl;
#endif
}

View File

@ -905,27 +905,3 @@ void Font::Glyph::subload() const
"\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();
#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;
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
glPopAttrib();
#endif
}
if (_drawMode & BOUNDINGBOX)
@ -615,9 +621,9 @@ 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();
}
}
}

View File

@ -467,9 +467,11 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
if ( !colorAttached )
{
setDrawBuffer( GL_NONE, true );
glDrawBuffer( GL_NONE );
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 )
{
#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 !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if( getDrawBufferApplyMask() )
glDrawBuffer(_drawBuffer);
if( getReadBufferApplyMask() )
glReadBuffer(_readBuffer);
#endif
}
if (fbo_supported)
@ -962,6 +970,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
{
if (read_fbo) SubFunc::applyReadFBO(apply_read_fbo, read_fbo, state);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if (using_multiple_render_targets)
{
int attachment=itr->first;
@ -978,6 +988,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
}
}
#endif
GLenum pixelFormat = itr->second._image->getPixelFormat();
if (pixelFormat==0) pixelFormat = _imageReadPixelFormat;
if (pixelFormat==0) pixelFormat = GL_RGB;
@ -1257,7 +1269,12 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
if (_clearMask & GL_DEPTH_BUFFER_BIT)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
glClearDepth( _clearDepth);
#else
glClearDepthf( _clearDepth);
#endif
glDepthMask ( GL_TRUE );
state.haveAppliedAttribute( osg::StateAttribute::DEPTH );
}
@ -1269,10 +1286,12 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
state.haveAppliedAttribute( osg::StateAttribute::STENCIL );
}
#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 );
@ -1281,8 +1300,10 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
glDisable( GL_SCISSOR_TEST );
#endif
#ifdef OSG_GL_MATRICES_AVAILABLE
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
#endif
// apply the positional state.
if (_inheritedPositionalStateContainer.valid())

View File

@ -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."<<std::endl;
#endif
}
break;
case(osg::DisplaySettings::HORIZONTAL_INTERLACE):
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if( 0 == ( _camera->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."<<std::endl;
#endif
}
break;
case(osg::DisplaySettings::CHECKERBOARD):
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if( 0 == ( _camera->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."<<std::endl;
#endif
}
break;
default:

View File

@ -19,6 +19,7 @@
#include <osgUtil/ShaderGen>
#include <osg/Geode>
#include <osg/Geometry> // for ShaderGenVisitor::update
#include <osg/Fog>
#include <sstream>
using namespace osgUtil;

View File

@ -108,6 +108,8 @@ ELSE()
SET(OSGVIEWER_USE_XRANDR OFF)
ENDIF()
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
@ -117,6 +119,7 @@ ELSE()
GraphicsWindowX11.cpp
PixelBufferX11.cpp
)
ENDIF()
IF(OSGVIEWER_USE_XRANDR)
ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)

View File

@ -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<ContextData> cd = getContextData(gc);