From Colin McDonald, "If the glCreateProgram in osg::Program fails for any reason, then subsequently
Program::PerContextProgram::linkProgram would crash. I've put in some checks to prevent that."
This commit is contained in:
parent
3f686d8719
commit
5c8a5307d6
@ -656,7 +656,15 @@ Program::PerContextProgram::PerContextProgram(const Program* program, unsigned i
|
||||
{
|
||||
_extensions = GLExtensions::Get( _contextID, true );
|
||||
_glProgramHandle = _extensions->glCreateProgram();
|
||||
_ownsProgramHandle = true;
|
||||
|
||||
if (_glProgramHandle)
|
||||
{
|
||||
_ownsProgramHandle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_WARN << "Unable to create osg::Program \"" << _program->getName() << "\"" << " contextID=" << _contextID << std::endl;
|
||||
}
|
||||
}
|
||||
requestLink();
|
||||
}
|
||||
@ -682,6 +690,8 @@ void Program::PerContextProgram::linkProgram(osg::State& state)
|
||||
if( ! _needsLink ) return;
|
||||
_needsLink = false;
|
||||
|
||||
if (!_glProgramHandle) return;
|
||||
|
||||
OSG_INFO << "Linking osg::Program \"" << _program->getName() << "\""
|
||||
<< " id=" << _glProgramHandle
|
||||
<< " contextID=" << _contextID
|
||||
@ -709,7 +719,7 @@ void Program::PerContextProgram::linkProgram(osg::State& state)
|
||||
if (!_loadedBinary)
|
||||
{
|
||||
const GLsizei shaderMaxCount = 20;
|
||||
GLsizei shadersCount;
|
||||
GLsizei shadersCount = 0;
|
||||
GLuint shaderObjectHandle[shaderMaxCount];
|
||||
_extensions->glGetAttachedShaders(_glProgramHandle, shaderMaxCount, &shadersCount, shaderObjectHandle);
|
||||
|
||||
@ -1035,6 +1045,8 @@ void Program::PerContextProgram::linkProgram(osg::State& state)
|
||||
|
||||
bool Program::PerContextProgram::validateProgram()
|
||||
{
|
||||
if (!_glProgramHandle) return false;
|
||||
|
||||
GLint validated = GL_FALSE;
|
||||
_extensions->glValidateProgram( _glProgramHandle );
|
||||
_extensions->glGetProgramiv( _glProgramHandle, GL_VALIDATE_STATUS, &validated );
|
||||
@ -1057,11 +1069,15 @@ bool Program::PerContextProgram::validateProgram()
|
||||
|
||||
bool Program::PerContextProgram::getInfoLog( std::string& infoLog ) const
|
||||
{
|
||||
if (!_glProgramHandle) return false;
|
||||
|
||||
return _extensions->getProgramInfoLog( _glProgramHandle, infoLog );
|
||||
}
|
||||
|
||||
Program::ProgramBinary* Program::PerContextProgram::compileProgramBinary(osg::State& state)
|
||||
{
|
||||
if (!_glProgramHandle) return 0;
|
||||
|
||||
linkProgram(state);
|
||||
GLint binaryLength = 0;
|
||||
_extensions->glGetProgramiv( _glProgramHandle, GL_PROGRAM_BINARY_LENGTH, &binaryLength );
|
||||
@ -1079,5 +1095,7 @@ Program::ProgramBinary* Program::PerContextProgram::compileProgramBinary(osg::St
|
||||
|
||||
void Program::PerContextProgram::useProgram() const
|
||||
{
|
||||
if (!_glProgramHandle) return;
|
||||
|
||||
_extensions->glUseProgram( _glProgramHandle );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user