Skip to content

Commit

Permalink
Rex DrawState: Fix crash from accessing possible null. (#2343)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Emminizer <[email protected]>
  • Loading branch information
emminizer and Daniel Emminizer authored Oct 6, 2023
1 parent c57e45c commit a1568db
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/osgEarthDrivers/engine_rex/DrawState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,28 @@ ProgramState::init(
// Size the sampler states property:
_samplerState._samplers.resize(bindings->size());

// for each sampler binding, initialize its state tracking structure
// for each sampler binding, initialize its state tracking structure
// and resolve its matrix uniform location:
for (unsigned i = 0; i < bindings->size(); ++i)
{
const SamplerBinding& binding = (*bindings)[i];
_samplerState._samplers[i]._name = binding.samplerName();
_samplerState._samplers[i]._matrixUL = _pcp->getUniformLocation(
osg::Uniform::getNameID(binding.matrixName()));
if (_pcp)
{
_samplerState._samplers[i]._matrixUL = _pcp->getUniformLocation(
osg::Uniform::getNameID(binding.matrixName()));
}
}

// resolve all the other uniform locations:
_tileKeyUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_tile_key_u"));
_parentTextureExistsUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_texParentExists"));
_layerUidUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_uid"));
_layerOrderUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_order"));
_morphConstantsUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_tile_morph"));
if (_pcp)
{
_tileKeyUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_tile_key_u"));
_parentTextureExistsUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_texParentExists"));
_layerUidUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_uid"));
_layerOrderUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_layer_order"));
_morphConstantsUL = _pcp->getUniformLocation(osg::Uniform::getNameID("oe_tile_morph"));
}

// Reset all optional states
reset();
Expand Down

0 comments on commit a1568db

Please sign in to comment.