Updates to osgGL2 from Mike Weiblen
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/* file: src/osgGL2/ProgramObject.cpp
|
||||
* author: Mike Weiblen 2003-09-18
|
||||
* author: Mike Weiblen 2003-12-27
|
||||
*
|
||||
* See http://www.3dlabs.com/opengl2/ for more information regarding
|
||||
* the OpenGL Shading Language.
|
||||
@@ -34,6 +34,38 @@
|
||||
using namespace osgGL2;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace {
|
||||
|
||||
class InfoLog
|
||||
{
|
||||
public:
|
||||
InfoLog( Extensions* ext, const GLhandleARB handle )
|
||||
{
|
||||
int blen = 0; // length of buffer to allocate
|
||||
int slen = 0; // strlen GL actually wrote to buffer
|
||||
|
||||
ext->glGetObjectParameteriv(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB , &blen);
|
||||
if (blen > 1)
|
||||
{
|
||||
GLcharARB* infoLog = new GLcharARB[blen];
|
||||
ext->glGetInfoLog( handle, blen, &slen, infoLog );
|
||||
_text = infoLog;
|
||||
delete [] infoLog;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& operator()() { return _text; }
|
||||
|
||||
private:
|
||||
InfoLog();
|
||||
std::string _text;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// static cache of deleted GL2 objects which may only
|
||||
// by actually deleted in the correct GL context.
|
||||
@@ -305,8 +337,8 @@ void ProgramObject::PerContextProgObj::build()
|
||||
_dirty = (linked == 0);
|
||||
if( _dirty )
|
||||
{
|
||||
osg::notify(osg::WARN) << "glLinkProgram FAILED:" << std::endl;
|
||||
printInfoLog(osg::WARN);
|
||||
InfoLog log( _extensions.get(), _glProgObjHandle );
|
||||
osg::notify(osg::WARN) << "glLinkProgram FAILED:\n" << log() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,22 +365,6 @@ void ProgramObject::PerContextProgObj::applyUniformValues()
|
||||
}
|
||||
|
||||
|
||||
void ProgramObject::PerContextProgObj::printInfoLog(osg::NotifySeverity severity) const
|
||||
{
|
||||
int blen = 0; // length of buffer to allocate
|
||||
int slen = 0; // strlen GL actually wrote to buffer
|
||||
|
||||
_extensions->glGetObjectParameteriv(_glProgObjHandle, GL_OBJECT_INFO_LOG_LENGTH_ARB , &blen);
|
||||
if (blen > 1)
|
||||
{
|
||||
GLcharARB* infoLog = new GLcharARB[blen];
|
||||
_extensions->glGetInfoLog(_glProgObjHandle, blen, &slen, infoLog);
|
||||
osg::notify(severity) << infoLog << std::endl;
|
||||
delete infoLog;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// osgGL2::ShaderObject
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -426,7 +442,7 @@ bool ShaderObject::loadShaderSourceFromFile( const char* fileName )
|
||||
text[length] = '\0';
|
||||
|
||||
setShaderSource( text );
|
||||
delete text;
|
||||
delete [] text;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -437,7 +453,7 @@ const char* ShaderObject::getTypename() const
|
||||
{
|
||||
case VERTEX: return "Vertex";
|
||||
case FRAGMENT: return "Fragment";
|
||||
default: return "UNKNOWN";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,8 +531,9 @@ void ShaderObject::PerContextShaderObj::build()
|
||||
_dirty = (compiled == 0);
|
||||
if( _dirty )
|
||||
{
|
||||
osg::notify(osg::WARN) << _shadObj->getTypename() << " glCompileShader FAILED:" << std::endl;
|
||||
printInfoLog(osg::WARN);
|
||||
InfoLog log( _extensions.get(), _glShaderObjHandle );
|
||||
osg::notify(osg::WARN) << _shadObj->getTypename() <<
|
||||
" glCompileShader FAILED:\n" << log() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,20 +542,4 @@ void ShaderObject::PerContextShaderObj::attach(GLhandleARB progObj) const
|
||||
_extensions->glAttachObject( progObj, _glShaderObjHandle );
|
||||
}
|
||||
|
||||
void ShaderObject::PerContextShaderObj::printInfoLog(osg::NotifySeverity severity) const
|
||||
{
|
||||
int blen = 0; // length of buffer to allocate
|
||||
int slen = 0; // strlen GL actually wrote to buffer
|
||||
|
||||
_extensions->glGetObjectParameteriv(_glShaderObjHandle, GL_OBJECT_INFO_LOG_LENGTH_ARB , &blen);
|
||||
if (blen > 1)
|
||||
{
|
||||
GLcharARB* infoLog = new GLcharARB[blen];
|
||||
_extensions->glGetInfoLog(_glShaderObjHandle, blen, &slen, infoLog);
|
||||
osg::notify(severity) << infoLog << std::endl;
|
||||
delete infoLog;
|
||||
}
|
||||
}
|
||||
|
||||
/*EOF*/
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/* file: src/osgGL2/UniformValue
|
||||
* author: Mike Weiblen 2003-09-12
|
||||
* author: Mike Weiblen 2003-12-27
|
||||
*
|
||||
* See http://www.3dlabs.com/opengl2/ for more information regarding
|
||||
* the OpenGL Shading Language.
|
||||
@@ -38,13 +38,6 @@ int UniformValue::getLocation( Extensions *ext, const GLhandleARB progObj ) cons
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define META_UniformValueCtor( typeName ) \
|
||||
UniformValue_##typeName::UniformValue_##typeName( const char* uniformName, typeName value ) : \
|
||||
UniformValue( uniformName ) \
|
||||
{ _value = value; } \
|
||||
|
||||
|
||||
META_UniformValueCtor( int );
|
||||
void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
@@ -54,7 +47,6 @@ void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
}
|
||||
}
|
||||
|
||||
META_UniformValueCtor( float );
|
||||
void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
@@ -64,7 +56,6 @@ void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) con
|
||||
}
|
||||
}
|
||||
|
||||
META_UniformValueCtor( Vec2 );
|
||||
void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
@@ -74,7 +65,6 @@ void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) cons
|
||||
}
|
||||
}
|
||||
|
||||
META_UniformValueCtor( Vec3 );
|
||||
void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
@@ -84,7 +74,6 @@ void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) cons
|
||||
}
|
||||
}
|
||||
|
||||
META_UniformValueCtor( Vec4 );
|
||||
void UniformValue_Vec4::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
@@ -95,4 +84,3 @@ void UniformValue_Vec4::apply( Extensions *ext, const GLhandleARB progObj ) cons
|
||||
}
|
||||
|
||||
/*EOF*/
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const char* osgGL2GetVersion()
|
||||
{
|
||||
return "0.2.3";
|
||||
return "0.2.6";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user