This commit is contained in:
Robert Osfield
2016-08-26 18:00:52 +01:00
25 changed files with 372 additions and 253 deletions

View File

@@ -449,6 +449,13 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen
{
unsigned int contextID = state.getContextID();
if (_ximpl->targetType == Pimpl::RENDERBUFFER)
{
ext->glFramebufferRenderbuffer(target, attachment_point, GL_RENDERBUFFER_EXT, _ximpl->renderbufferTarget->getObjectID(contextID, ext));
return;
}
// targetType must be a texture, make sure we have a valid texture object
Texture::TextureObject *tobj = 0;
if (_ximpl->textureTarget.valid())
{
@@ -465,10 +472,8 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen
switch (_ximpl->targetType)
{
default:
case Pimpl::RENDERBUFFER:
ext->glFramebufferRenderbuffer(target, attachment_point, GL_RENDERBUFFER_EXT, _ximpl->renderbufferTarget->getObjectID(contextID, ext));
break;
break; // already handled above. case should never be hit, just here to quieten compiler warning.
case Pimpl::TEXTURE1D:
ext->glFramebufferTexture1D(target, attachment_point, GL_TEXTURE_1D, tobj->id(), _ximpl->level);
break;

View File

@@ -767,7 +767,7 @@ void GraphicsContext::removeCamera(osg::Camera* camera)
nitr != nodes.end();
++nitr)
{
const_cast<osg::Node*>(*nitr)->releaseGLObjects(_state.get());
(*nitr)->releaseGLObjects(_state.get());
}
// release the context of the any RenderingCache that the Camera has.

View File

@@ -884,9 +884,9 @@ void State::resetVertexAttributeAlias(bool compactAliasing, unsigned int numText
if (compactAliasing)
{
unsigned int slot = 0;
setUpVertexAttribAlias(_vertexAlias, slot++, "gl_Vertex","osg_Vertex","attribute vec4 ");
setUpVertexAttribAlias(_normalAlias, slot++, "gl_Normal","osg_Normal","attribute vec3 ");
setUpVertexAttribAlias(_colorAlias, slot++, "gl_Color","osg_Color","attribute vec4 ");
setUpVertexAttribAlias(_vertexAlias, slot++, "gl_Vertex","osg_Vertex","vec4 ");
setUpVertexAttribAlias(_normalAlias, slot++, "gl_Normal","osg_Normal","vec3 ");
setUpVertexAttribAlias(_colorAlias, slot++, "gl_Color","osg_Color","vec4 ");
_texCoordAliasList.resize(numTextureUnits);
for(unsigned int i=0; i<_texCoordAliasList.size(); i++)
@@ -896,20 +896,20 @@ void State::resetVertexAttributeAlias(bool compactAliasing, unsigned int numText
gl_MultiTexCoord<<"gl_MultiTexCoord"<<i;
osg_MultiTexCoord<<"osg_MultiTexCoord"<<i;
setUpVertexAttribAlias(_texCoordAliasList[i], slot++, gl_MultiTexCoord.str(), osg_MultiTexCoord.str(), "attribute vec4 ");
setUpVertexAttribAlias(_texCoordAliasList[i], slot++, gl_MultiTexCoord.str(), osg_MultiTexCoord.str(), "vec4 ");
}
setUpVertexAttribAlias(_secondaryColorAlias, slot++, "gl_SecondaryColor","osg_SecondaryColor","attribute vec4 ");
setUpVertexAttribAlias(_fogCoordAlias, slot++, "gl_FogCoord","osg_FogCoord","attribute float ");
setUpVertexAttribAlias(_secondaryColorAlias, slot++, "gl_SecondaryColor","osg_SecondaryColor","vec4 ");
setUpVertexAttribAlias(_fogCoordAlias, slot++, "gl_FogCoord","osg_FogCoord","float ");
}
else
{
setUpVertexAttribAlias(_vertexAlias,0, "gl_Vertex","osg_Vertex","attribute vec4 ");
setUpVertexAttribAlias(_normalAlias, 2, "gl_Normal","osg_Normal","attribute vec3 ");
setUpVertexAttribAlias(_colorAlias, 3, "gl_Color","osg_Color","attribute vec4 ");
setUpVertexAttribAlias(_secondaryColorAlias, 4, "gl_SecondaryColor","osg_SecondaryColor","attribute vec4 ");
setUpVertexAttribAlias(_fogCoordAlias, 5, "gl_FogCoord","osg_FogCoord","attribute float ");
setUpVertexAttribAlias(_vertexAlias,0, "gl_Vertex","osg_Vertex","vec4 ");
setUpVertexAttribAlias(_normalAlias, 2, "gl_Normal","osg_Normal","vec3 ");
setUpVertexAttribAlias(_colorAlias, 3, "gl_Color","osg_Color","vec4 ");
setUpVertexAttribAlias(_secondaryColorAlias, 4, "gl_SecondaryColor","osg_SecondaryColor","vec4 ");
setUpVertexAttribAlias(_fogCoordAlias, 5, "gl_FogCoord","osg_FogCoord","float ");
unsigned int base = 8;
_texCoordAliasList.resize(numTextureUnits);
@@ -920,7 +920,7 @@ void State::resetVertexAttributeAlias(bool compactAliasing, unsigned int numText
gl_MultiTexCoord<<"gl_MultiTexCoord"<<i;
osg_MultiTexCoord<<"osg_MultiTexCoord"<<i;
setUpVertexAttribAlias(_texCoordAliasList[i], base+i, gl_MultiTexCoord.str(), osg_MultiTexCoord.str(), "attribute vec4 ");
setUpVertexAttribAlias(_texCoordAliasList[i], base+i, gl_MultiTexCoord.str(), osg_MultiTexCoord.str(), "vec4 ");
}
}
}
@@ -1442,11 +1442,11 @@ namespace State_Utils
return replacedStr;
}
void replaceAndInsertDeclaration(std::string& source, std::string::size_type declPos, const std::string& originalStr, const std::string& newStr, const std::string& declarationPrefix)
void replaceAndInsertDeclaration(std::string& source, std::string::size_type declPos, const std::string& originalStr, const std::string& newStr, const std::string& qualifier, const std::string& declarationPrefix)
{
if (replace(source, originalStr, newStr))
{
source.insert(declPos, declarationPrefix + newStr + std::string(";\n"));
source.insert(declPos, qualifier + declarationPrefix + newStr + std::string(";\n"));
}
}
}
@@ -1457,11 +1457,19 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
OSG_INFO<<"++Before Converted source "<<std::endl<<source<<std::endl<<"++++++++"<<std::endl;
std::string attributeQualifier("attribute ");
// find the first legal insertion point for replacement declarations. GLSL requires that nothing
// precede a "#verson" compiler directive, so we must insert new declarations after it.
std::string::size_type declPos = source.rfind( "#version " );
if ( declPos != std::string::npos )
{
declPos = source.find(" ", declPos); // move to the first space after "#version"
declPos = source.find_first_not_of(std::string(" "), declPos); // skip all the spaces until you reach the version number
std::string versionNumber(source, declPos, 3);
int glslVersion = atoi(versionNumber.c_str());
OSG_INFO<<"shader version found: "<< glslVersion <<std::endl;
if (glslVersion >= 130) attributeQualifier = "in ";
// found the string, now find the next linefeed and set the insertion point after it.
declPos = source.find( '\n', declPos );
declPos = declPos != std::string::npos ? declPos+1 : source.length();
@@ -1477,23 +1485,23 @@ bool State::convertVertexShaderSourceToOsgBuiltIns(std::string& source) const
State_Utils::replace(source, "ftransform()", "gl_ModelViewProjectionMatrix * gl_Vertex");
// replace built in uniform
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewMatrix", "osg_ModelViewMatrix", "uniform mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewProjectionMatrix", "osg_ModelViewProjectionMatrix", "uniform mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ProjectionMatrix", "osg_ProjectionMatrix", "uniform mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_NormalMatrix", "osg_NormalMatrix", "uniform mat3 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewMatrix", "osg_ModelViewMatrix", "uniform ", "mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ModelViewProjectionMatrix", "osg_ModelViewProjectionMatrix", "uniform ", "mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_ProjectionMatrix", "osg_ProjectionMatrix", "uniform ", "mat4 ");
State_Utils::replaceAndInsertDeclaration(source, declPos, "gl_NormalMatrix", "osg_NormalMatrix", "uniform ", "mat3 ");
}
if (_useVertexAttributeAliasing)
{
State_Utils::replaceAndInsertDeclaration(source, declPos, _vertexAlias._glName, _vertexAlias._osgName, _vertexAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _normalAlias._glName, _normalAlias._osgName, _normalAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _colorAlias._glName, _colorAlias._osgName, _colorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _secondaryColorAlias._glName, _secondaryColorAlias._osgName, _secondaryColorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _fogCoordAlias._glName, _fogCoordAlias._osgName, _fogCoordAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _vertexAlias._glName, _vertexAlias._osgName, attributeQualifier, _vertexAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _normalAlias._glName, _normalAlias._osgName, attributeQualifier, _normalAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _colorAlias._glName, _colorAlias._osgName, attributeQualifier, _colorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _secondaryColorAlias._glName, _secondaryColorAlias._osgName, attributeQualifier, _secondaryColorAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, _fogCoordAlias._glName, _fogCoordAlias._osgName, attributeQualifier, _fogCoordAlias._declaration);
for (size_t i=0; i<_texCoordAliasList.size(); i++)
{
const VertexAttribAlias& texCoordAlias = _texCoordAliasList[i];
State_Utils::replaceAndInsertDeclaration(source, declPos, texCoordAlias._glName, texCoordAlias._osgName, texCoordAlias._declaration);
State_Utils::replaceAndInsertDeclaration(source, declPos, texCoordAlias._glName, texCoordAlias._osgName, attributeQualifier, texCoordAlias._declaration);
}
}
@@ -1725,7 +1733,6 @@ void State::print(std::ostream& fout) const
#if 0
GraphicsContext* _graphicsContext;
unsigned int _contextID;
bool _shaderCompositionEnabled;
bool _shaderCompositionDirty;
osg::ref_ptr<ShaderComposer> _shaderComposer;

View File

@@ -1669,6 +1669,14 @@ void Texture::computeInternalFormatType() const
case GL_RGB16UI_EXT:
case GL_RGB8UI_EXT:
case GL_RG32UI:
case GL_RG16UI:
case GL_RG8UI:
case GL_R32UI:
case GL_R16UI:
case GL_R8UI:
case GL_LUMINANCE32UI_EXT:
case GL_LUMINANCE16UI_EXT:
case GL_LUMINANCE8UI_EXT:
@@ -1691,6 +1699,14 @@ void Texture::computeInternalFormatType() const
case GL_RGB16I_EXT:
case GL_RGB8I_EXT:
case GL_RG32I:
case GL_RG16I:
case GL_RG8I:
case GL_R32I:
case GL_R16I:
case GL_R8I:
case GL_LUMINANCE32I_EXT:
case GL_LUMINANCE16I_EXT:
case GL_LUMINANCE8I_EXT:
@@ -1711,6 +1727,12 @@ void Texture::computeInternalFormatType() const
case GL_RGB32F_ARB:
case GL_RGB16F_ARB:
case GL_RG32F:
case GL_RG16F:
case GL_R32F:
case GL_R16F:
case GL_LUMINANCE32F_ARB:
case GL_LUMINANCE16F_ARB:

View File

@@ -18,7 +18,7 @@
#include <osgDB/FileUtils>
#include <osgDB/WriteFile>
#include <osgDB/ObjectWrapper>
#include <fstream>
#include <osgDB/fstream>
#include <sstream>
#include <stdlib.h>
@@ -558,7 +558,7 @@ void OutputStream::writeImage( const osg::Image* img )
if ( isBinary() )
{
std::string fullPath = osgDB::findDataFile( img->getFileName() );
std::ifstream infile( fullPath.c_str(), std::ios::in|std::ios::binary );
osgDB::ifstream infile( fullPath.c_str(), std::ios::in|std::ios::binary );
if ( infile )
{
infile.seekg( 0, std::ios::end );

View File

@@ -1,3 +1,8 @@
# AVFoundation plugin only works with OSX/Cocoa (not X11 or Carbon)
IF(NOT OSG_WINDOWING_SYSTEM STREQUAL "Cocoa")
MESSAGE(WARNING "Disabling AVFoundation plugin because it requires OSG_WINDOWING_SYSTEM to be Cocoa")
RETURN()
ENDIF()
SET(TARGET_SRC
OSXAVFoundationVideo.mm

View File

@@ -142,6 +142,7 @@ EasyCurl::EasyCurl()
_previousHttpAuthentication = 0;
_connectTimeout = 0; // no timeout by default.
_timeout = 0;
_sslVerifyPeer = 1L;
_curl = curl_easy_init();
@@ -252,6 +253,9 @@ void EasyCurl::setOptions(const std::string& proxyAddress, const std::string& fi
curl_easy_setopt(_curl, CURLOPT_PROXY, proxyAddress.c_str()); //Sets proxy address and port on libcurl
}
// setting ssl verify peer (default is enabled)
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYPEER, _sslVerifyPeer);
const osgDB::AuthenticationDetails* details = authenticationMap ?
authenticationMap->getAuthenticationDetails(fileName) :
0;
@@ -385,6 +389,7 @@ ReaderWriterCURL::ReaderWriterCURL()
supportsOption("OSG_CURL_PROXYPORT","Specify the http proxy port.");
supportsOption("OSG_CURL_CONNECTTIMEOUT","Specify the connection timeout duration in seconds [default = 0 = not set].");
supportsOption("OSG_CURL_TIMEOUT","Specify the timeout duration of the whole transfer in seconds [default = 0 = not set].");
supportsOption("OSG_CURL_SSL_VERIFYPEER","Specify ssl verification peer [default = 1 = set].");
}
ReaderWriterCURL::~ReaderWriterCURL()
@@ -428,11 +433,13 @@ osgDB::ReaderWriter::WriteResult ReaderWriterCURL::writeFile(const osg::Object&
std::string proxyAddress;
long connectTimeout = 0;
long timeout = 0;
getConnectionOptions(options, proxyAddress, connectTimeout, timeout);
long sslVerifyPeer = 1;
getConnectionOptions(options, proxyAddress, connectTimeout, timeout, sslVerifyPeer);
EasyCurl::StreamObject sp(&responseBuffer, &requestBuffer, std::string());
EasyCurl& easyCurl = getEasyCurl();
easyCurl.setConnectionTimeout(connectTimeout);
easyCurl.setTimeout(timeout);
easyCurl.setSSLVerifyPeer(sslVerifyPeer);
// Output requestBuffer via curl, and return responseBuffer in message of result.
return easyCurl.write(proxyAddress, fullFileName, sp, options);
@@ -452,7 +459,11 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType
return ReadResult::FILE_NOT_HANDLED;
}
void ReaderWriterCURL::getConnectionOptions(const osgDB::ReaderWriter::Options *options, std::string& proxyAddress, long& connectTimeout, long& timeout) const
void ReaderWriterCURL::getConnectionOptions(const osgDB::ReaderWriter::Options *options,
std::string& proxyAddress,
long& connectTimeout,
long& timeout,
long& sslVerifyPeer) const
{
if (options)
{
@@ -469,8 +480,11 @@ void ReaderWriterCURL::getConnectionOptions(const osgDB::ReaderWriter::Options *
connectTimeout = atol(opt.substr( index+1 ).c_str()); // this will return 0 in case of improper format.
else if( opt.substr( 0, index ) == "OSG_CURL_TIMEOUT" )
timeout = atol(opt.substr( index+1 ).c_str()); // this will return 0 in case of improper format.
else if( opt.substr(0, index) == "OSG_CURL_SSL_VERIFYPEER" )
sslVerifyPeer = atol(opt.substr( index+1 ).c_str()); // this will return 0 in case of improper format.
}
//Setting Proxy by OSG Options
if(!optProxy.empty())
{
@@ -529,7 +543,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType
std::string proxyAddress;
long connectTimeout = 0;
long timeout = 0;
getConnectionOptions(options, proxyAddress, connectTimeout, timeout);
long sslVerifyPeer = 1;
getConnectionOptions(options, proxyAddress, connectTimeout, timeout, sslVerifyPeer);
bool uncompress = false;
@@ -568,6 +583,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType
// setup the timeouts:
easyCurl.setConnectionTimeout(connectTimeout);
easyCurl.setTimeout(timeout);
easyCurl.setSSLVerifyPeer(sslVerifyPeer);
ReadResult curlResult = easyCurl.read(proxyAddress, fileName, sp, options);

View File

@@ -61,6 +61,8 @@ class EasyCurl : public osg::Referenced
// the timeout variable is used to limit the whole transfer duration instead of the connection phase only.
inline void setTimeout(long val) { _timeout = val; }
inline void setSSLVerifyPeer(long verifyPeer) { _sslVerifyPeer = verifyPeer; }
// Perform HTTP GET to download data from web server.
osgDB::ReaderWriter::ReadResult read(const std::string& proxyAddress, const std::string& fileName, StreamObject& sp, const osgDB::ReaderWriter::Options *options);
@@ -91,6 +93,7 @@ class EasyCurl : public osg::Referenced
long _previousHttpAuthentication;
long _connectTimeout;
long _timeout;
long _sslVerifyPeer;
};
@@ -171,7 +174,7 @@ class ReaderWriterCURL : public osgDB::ReaderWriter
bool read(std::istream& fin, std::string& destination) const;
protected:
void getConnectionOptions(const osgDB::ReaderWriter::Options *options, std::string& proxyAddress, long& connectTimeout, long& timeout) const;
void getConnectionOptions(const osgDB::ReaderWriter::Options *options, std::string& proxyAddress, long& connectTimeout, long& timeout, long& sslVerifyPeer) const;
typedef std::map< OpenThreads::Thread*, osg::ref_ptr<EasyCurl> > ThreadCurlMap;

View File

@@ -446,7 +446,7 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(const osgText::FontResolution& fontR
}
}
FT_Error error = FT_Load_Char( _face, charindex, FT_LOAD_DEFAULT|_flags );
FT_Error error = FT_Load_Char( _face, charindex, FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | _flags );
if (error)
{
OSG_WARN << "FT_Load_Char(...) error 0x"<<std::hex<<error<<std::dec<<std::endl;

View File

@@ -28,8 +28,6 @@
#include "utf8_string"
using namespace std;
// A simple class wrapping ofstream calls to enable generic cleaning of json data.
// Especially 'standard' json should:
// * have utf-8 encoded string
@@ -37,8 +35,11 @@ using namespace std;
// * does not support inf or nan values
#if defined(WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<=1700)
inline int isfinite( double x ) { return _finite( x ); }
inline int isinf( double x ) { return !_finite( x ) && !_isnan( x ); }
namespace std
{
inline int isfinite( double x ) { return _finite( x ); }
inline int isinf( double x ) { return !_finite( x ) && !_isnan( x ); }
}
#endif
@@ -91,11 +92,11 @@ class json_stream : public osgDB::ofstream {
}
double to_valid_float(const double d) {
if(isfinite(d)) {
if(std::isfinite(d)) {
return d;
}
else {
if(isinf(d)) {
if(std::isinf(d)) {
return std::numeric_limits<double>::max();
}
// no much way to do better than replace invalid float NaN by 0

View File

@@ -588,9 +588,11 @@ ReaderWriterSTL::ReaderObject::ReadResult ReaderWriterSTL::AsciiReaderObject::re
while (fgets(buf, sizeof(buf), fp))
{
// strip '\n' or '\r\n' and trailing whitespace
unsigned int len = strlen(buf) - 1;
unsigned int len = strlen(buf);
if (len==0) continue;
// strip '\n' or '\r\n' and trailing whitespace
--len;
while (len && (buf[len] == '\n' || buf[len] == '\r' || isspace(buf[len])))
{
buf[len--] = '\0';

View File

@@ -77,7 +77,7 @@ void StateToCompile::apply(osg::Drawable& drawable)
_drawablesHandled.insert(&drawable);
if (_markerObject.get()!=drawable.getUserData())
if (!_markerObject || _markerObject.get()!=drawable.getUserData())
{
if (drawable.getDataVariance()!=osg::Object::STATIC)
{
@@ -114,7 +114,7 @@ void StateToCompile::apply(osg::Drawable& drawable)
}
// mark the drawable as visited
if (drawable.getUserData()==0) drawable.setUserData(_markerObject.get());
if (_markerObject.valid() && drawable.getUserData()==0) drawable.setUserData(_markerObject.get());
}
}
@@ -125,15 +125,15 @@ void StateToCompile::apply(osg::StateSet& stateset)
_statesetsHandled.insert(&stateset);
if ((_mode & GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES)!=0 &&
_markerObject.get()!=stateset.getUserData())
(!_markerObject || _markerObject.get()!=stateset.getUserData()))
{
osg::Program* program = dynamic_cast<osg::Program*>(stateset.getAttribute(osg::StateAttribute::PROGRAM));
if (program && _markerObject.get()!=program->getUserData())
if (program && (!_markerObject || _markerObject.get()!=program->getUserData()))
{
_programs.insert(program);
// mark the stateset as visited
if (program->getUserData()==0) program->setUserData(_markerObject.get());
if (_markerObject.valid() && program->getUserData()==0) program->setUserData(_markerObject.get());
}
const osg::StateSet::TextureAttributeList& tal = stateset.getTextureAttributeList();
@@ -159,14 +159,14 @@ void StateToCompile::apply(osg::StateSet& stateset)
}
// mark the stateset as visited
if (stateset.getUserData()==0) stateset.setUserData(_markerObject.get());
if (_markerObject.valid() && stateset.getUserData()==0) stateset.setUserData(_markerObject.get());
}
}
void StateToCompile::apply(osg::Texture& texture)
{
// don't make any changes if Texture already processed
if (_markerObject.get()==texture.getUserData()) return;
if (_markerObject.valid() && _markerObject.get()==texture.getUserData()) return;
if (_assignPBOToImages)
{
@@ -213,7 +213,7 @@ void StateToCompile::apply(osg::Texture& texture)
}
}
if (texture.getUserData()==0) texture.setUserData(_markerObject.get());
if (_markerObject.valid() && texture.getUserData()==0) texture.setUserData(_markerObject.get());
_textures.insert(&texture);
}
@@ -420,7 +420,8 @@ void IncrementalCompileOperation::CompileSet::buildCompileMap(ContextSet& contex
{
if (contexts.empty() || !_subgraphToCompile) return;
StateToCompile stc(mode);
StateToCompile stc(mode, _markerObject.get());
_subgraphToCompile->accept(stc);
buildCompileMap(contexts, stc);
@@ -579,6 +580,9 @@ void IncrementalCompileOperation::add(CompileSet* compileSet, bool callBuildComp
{
if (!compileSet) return;
// pass on the markerObject to the CompileSet
compileSet->_markerObject = _markerObject;
if (compileSet->_subgraphToCompile.valid())
{
// force a compute of the bound of the subgraph to avoid the update traversal from having to do this work

View File

@@ -281,107 +281,74 @@ void TangentSpaceGenerator::compute(osg::PrimitiveSet *pset,
OSG_WARN << "Warning: TangentSpaceGenerator: texture coord array must be Vec2Array, Vec3Array or Vec4Array" << std::endl;
}
if(nx){
osg::Vec3 V, T1, T2, T3, B1, B2, B3;
osg::Vec3 V, T1, T2, T3, B1, B2, B3;
V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.x() += -V.y() / V.x();
B1.x() += -V.z() / V.x();
T2.x() += -V.y() / V.x();
B2.x() += -V.z() / V.x();
T3.x() += -V.y() / V.x();
B3.x() += -V.z() / V.x();
}
V = osg::Vec3(P2.y() - P1.y(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.y() - P1.y(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.y() += -V.y() / V.x();
B1.y() += -V.z() / V.x();
T2.y() += -V.y() / V.x();
B2.y() += -V.z() / V.x();
T3.y() += -V.y() / V.x();
B3.y() += -V.z() / V.x();
}
V = osg::Vec3(P2.z() - P1.z(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.z() - P1.z(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.z() += -V.y() / V.x();
B1.z() += -V.z() / V.x();
T2.z() += -V.y() / V.x();
B2.z() += -V.z() / V.x();
T3.z() += -V.y() / V.x();
B3.z() += -V.z() / V.x();
}
osg::Vec3 tempvec;
tempvec = N1 ^ T1;
(*T_)[iA] = osg::Vec4(tempvec ^ N1, 0);
tempvec = B1 ^ N1;
(*B_)[iA] = osg::Vec4(N1 ^ tempvec, 0);
tempvec = N2 ^ T2;
(*T_)[iB] = osg::Vec4(tempvec ^ N2, 0);
tempvec = B2 ^ N2;
(*B_)[iB] = osg::Vec4(N2 ^ tempvec, 0);
tempvec = N3 ^ T3;
(*T_)[iC] = osg::Vec4(tempvec ^ N3, 0);
tempvec = B3 ^ N3;
(*B_)[iC] = osg::Vec4(N3 ^ tempvec, 0);
(*N_)[iA] += osg::Vec4(N1, 0);
(*N_)[iB] += osg::Vec4(N2, 0);
(*N_)[iC] += osg::Vec4(N3, 0);
// no normal per vertex use the one by face
if (!nx) {
N1 = (P2 - P1) ^ (P3 - P1);
N2 = N1;
N3 = N1;
}
else{
osg::Vec3 face_normal = (P2 - P1) ^ (P3 - P1);
osg::Vec3 V;
V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].x() += -V.y() / V.x();
(*B_)[iA].x() += -V.z() / V.x();
(*T_)[iB].x() += -V.y() / V.x();
(*B_)[iB].x() += -V.z() / V.x();
(*T_)[iC].x() += -V.y() / V.x();
(*B_)[iC].x() += -V.z() / V.x();
}
V = osg::Vec3(P2.y() - P1.y(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.y() - P1.y(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].y() += -V.y() / V.x();
(*B_)[iA].y() += -V.z() / V.x();
(*T_)[iB].y() += -V.y() / V.x();
(*B_)[iB].y() += -V.z() / V.x();
(*T_)[iC].y() += -V.y() / V.x();
(*B_)[iC].y() += -V.z() / V.x();
}
V = osg::Vec3(P2.z() - P1.z(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.z() - P1.z(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
(*T_)[iA].z() += -V.y() / V.x();
(*B_)[iA].z() += -V.z() / V.x();
(*T_)[iB].z() += -V.y() / V.x();
(*B_)[iB].z() += -V.z() / V.x();
(*T_)[iC].z() += -V.y() / V.x();
(*B_)[iC].z() += -V.z() / V.x();
}
(*N_)[iA] += osg::Vec4(face_normal, 0);
(*N_)[iB] += osg::Vec4(face_normal, 0);
(*N_)[iC] += osg::Vec4(face_normal, 0);
V = osg::Vec3(P2.x() - P1.x(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.x() - P1.x(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.x() += -V.y() / V.x();
B1.x() += -V.z() / V.x();
T2.x() += -V.y() / V.x();
B2.x() += -V.z() / V.x();
T3.x() += -V.y() / V.x();
B3.x() += -V.z() / V.x();
}
V = osg::Vec3(P2.y() - P1.y(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.y() - P1.y(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.y() += -V.y() / V.x();
B1.y() += -V.z() / V.x();
T2.y() += -V.y() / V.x();
B2.y() += -V.z() / V.x();
T3.y() += -V.y() / V.x();
B3.y() += -V.z() / V.x();
}
V = osg::Vec3(P2.z() - P1.z(), uv2.x() - uv1.x(), uv2.y() - uv1.y()) ^
osg::Vec3(P3.z() - P1.z(), uv3.x() - uv1.x(), uv3.y() - uv1.y());
if (V.x() != 0) {
V.normalize();
T1.z() += -V.y() / V.x();
B1.z() += -V.z() / V.x();
T2.z() += -V.y() / V.x();
B2.z() += -V.z() / V.x();
T3.z() += -V.y() / V.x();
B3.z() += -V.z() / V.x();
}
osg::Vec3 tempvec;
tempvec = N1 ^ T1;
(*T_)[iA] += osg::Vec4(tempvec ^ N1, 0);
tempvec = B1 ^ N1;
(*B_)[iA] += osg::Vec4(N1 ^ tempvec, 0);
tempvec = N2 ^ T2;
(*T_)[iB] += osg::Vec4(tempvec ^ N2, 0);
tempvec = B2 ^ N2;
(*B_)[iB] += osg::Vec4(N2 ^ tempvec, 0);
tempvec = N3 ^ T3;
(*T_)[iC] += osg::Vec4(tempvec ^ N3, 0);
tempvec = B3 ^ N3;
(*B_)[iC] += osg::Vec4(N3 ^ tempvec, 0);
(*N_)[iA] += osg::Vec4(N1, 0);
(*N_)[iB] += osg::Vec4(N2, 0);
(*N_)[iC] += osg::Vec4(N3, 0);
}

View File

@@ -81,27 +81,10 @@ IF(WIN32 AND NOT ANDROID)
PixelBufferWin32.cpp
)
ELSE()
IF(APPLE AND NOT ANDROID)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Windowing system type for graphics window creation, options only IOS.")
ELSE()
IF(${OSG_OSX_SDK_NAME} STREQUAL "macosx10.4" OR
${OSG_OSX_SDK_NAME} STREQUAL "macosx10.3" OR
${OSG_OSX_SDK_NAME} STREQUAL "macosx10.2" OR
${OSG_OSX_SDK_NAME} STREQUAL "macosx10.1")
SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
ELSE()
SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
ENDIF()
ENDIF()
IF(ANDROID)
SET(OSG_WINDOWING_SYSTEM "None" CACHE STRING "None Windowing system type for graphics window creation.")
ELSE()
IF(ANDROID)
SET(OSG_WINDOWING_SYSTEM "None" CACHE STRING "None Windowing system type for graphics window creation.")
ELSE()
SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation. options only X11")
ENDIF()
SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation. options only X11")
ENDIF()
IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Cocoa")
@@ -222,30 +205,18 @@ ELSE()
ENDIF()
ENDIF()
# X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
IF(APPLE)
# hack for finding the iphone opengl es lib
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET(OPENGL_INCLUDE_DIR ${IPHONE_SDKROOT}System/Library/Frameworks)
SET(OPENGL_LIBRARIES ${IPHONE_SDKROOT}System/Library/Frameworks/OpenGLES)
SET(OPENGL_INCLUDE_DIR ${IPHONE_SDKROOT}/System/Library/Frameworks)
SET(OPENGL_LIBRARIES ${IPHONE_SDKROOT}/System/Library/Frameworks/OpenGLES)
ELSE()
# Find GL/glx.h
IF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
SET(OPENGL_INCLUDE_DIR /usr/X11/include)
SET(OPENGL_LIBRARIES /usr/X11/lib/libGL.dylib)
ELSEIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11R6/include/GL/glx.h)
SET(OPENGL_INCLUDE_DIR /usr/X11R6/include)
SET(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib)
ENDIF()
INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OPENGL_INCLUDE_DIR})
SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${OPENGL_LIBRARIES} ${LIB_EXTRA_LIBS})
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${LIB_EXTRA_LIBS})
ENDIF()
ELSE(APPLE)
SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${LIB_EXTRA_LIBS})
SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${LIB_EXTRA_LIBS})
ENDIF(APPLE)
ELSE()
MESSAGE(STATUS "Windowing system not supported")

View File

@@ -1202,6 +1202,11 @@ bool GraphicsWindowCocoa::realizeImplementation()
attr[i++] = static_cast<NSOpenGLPixelFormatAttribute>(_traits->samples);
}
#ifdef OSG_GL3_AVAILABLE
attr[i++] = NSOpenGLPFAOpenGLProfile;
attr[i++] = NSOpenGLProfileVersion3_2Core;
OSG_DEBUG << "GraphicsWindowCocoa::realizeImplementation :: set up for GL3 Core Profile"<< std::endl;
#endif
attr[i++] = NSOpenGLPFAAccelerated;
attr[i] = static_cast<NSOpenGLPixelFormatAttribute>(0);