Ported osgUtil, osgDB, osgGA, NodeKits and plugins to compile against OpenGL ES 1.1 and OpenGL ES 2.0.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <osgUtil/ShaderGen>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry> // for ShaderGenVisitor::update
|
||||
#include <osg/Fog>
|
||||
#include <sstream>
|
||||
|
||||
using namespace osgUtil;
|
||||
|
||||
Reference in New Issue
Block a user