Skip to content

Commit

Permalink
codecheck, more pointer checking
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Jan 23, 2021
1 parent b4c9674 commit 2e37769
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
10 changes: 8 additions & 2 deletions include/ignition/rendering/base/BaseGizmoVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,17 @@ namespace ignition

std::string rotFullMeshName = "gizmo_rotate_full";
if (!meshMgr->HasMesh(rotFullMeshName))
meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64, 2*IGN_PI);
{
meshMgr->CreateTube(rotFullMeshName, 1.0f, 1.02f, 0.02f, 1, 64,
2 * IGN_PI);
}

std::string rotHandleMeshName = "gizmo_rotate_handle";
if (!meshMgr->HasMesh(rotHandleMeshName))
meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64, IGN_PI);
{
meshMgr->CreateTube(rotHandleMeshName, 0.95f, 1.07f, 0.1f, 1, 64,
IGN_PI);
}

VisualPtr rotVis = this->Scene()->CreateVisual();

Expand Down
33 changes: 29 additions & 4 deletions ogre/src/OgreRenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,12 @@ void OgreRenderEngine::CreateResources()
void OgreRenderEngine::CreateRenderWindow()
{
// create dummy window
this->CreateRenderWindow(std::to_string(this->dummyWindowId), 1, 1, 1, 0);
auto res = this->CreateRenderWindow(std::to_string(this->dummyWindowId), 1, 1,
1, 0);
if (res.empty())
{
ignerr << "Failed to create dummy render window." << std::endl;
}
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -663,16 +668,18 @@ std::string OgreRenderEngine::CreateRenderWindow(const std::string &_handle,
window = this->ogreRoot->createRenderWindow(
stream.str(), _width, _height, false, &params);
}
catch(...)
catch(Ogre::Exception &_e)
{
ignerr << " Unable to create the rendering window\n";
ignerr << "Unable to create the rendering window. Attempt [" << attempts
<< "]. Exception [" << _e.what() << "]" << std::endl;
window = nullptr;
}
}

if (attempts >= 10)
{
ignerr << "Unable to create the rendering window\n" << std::endl;
ignerr << "Unable to create the rendering window after [" << attempts
<< "] attempts." << std::endl;
return std::string();
}

Expand All @@ -691,11 +698,23 @@ std::string OgreRenderEngine::CreateRenderWindow(const std::string &_handle,
//////////////////////////////////////////////////
void OgreRenderEngine::CheckCapabilities()
{
if (nullptr == this->ogreRoot ||nullptr == this->ogreRoot->getRenderSystem())
{
ignerr << "No ogreRoot or render system" << std::endl;
return;
}

const Ogre::RenderSystemCapabilities *capabilities;
Ogre::RenderSystemCapabilities::ShaderProfiles profiles;
Ogre::RenderSystemCapabilities::ShaderProfiles::const_iterator iter;

capabilities = this->ogreRoot->getRenderSystem()->getCapabilities();
if (nullptr == capabilities)
{
ignerr << "Failed to get capabilities" << std::endl;
return;
}

profiles = capabilities->getSupportedShaderProfiles();

bool hasFragmentPrograms =
Expand All @@ -717,17 +736,23 @@ void OgreRenderEngine::CheckCapabilities()
std::find(profiles.begin(), profiles.end(), "glsl") != profiles.end();

if (!hasFragmentPrograms || !hasVertexPrograms)
{
ignwarn << "Vertex and fragment shaders are missing. "
<< "Fixed function rendering will be used.\n";
}

if (!hasGLSL)
{
ignwarn << "GLSL is missing."
<< "Fixed function rendering will be used.\n";
}

// cppcheck-suppress knownConditionTrueFalse
if (!hasFBO)
{
ignwarn << "Frame Buffer Objects (FBO) is missing. "
<< "Rendering will be disabled.\n";
}

this->renderPathType = OgreRenderEngine::NONE;

Expand Down
1 change: 1 addition & 0 deletions src/Visual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ void VisualTest::UserData(const std::string &_renderEngine)
EXPECT_THROW(
{
auto res = std::get<int>(value);
igndbg << res << std::endl;
}, std::bad_variant_access);

// Clean up
Expand Down

0 comments on commit 2e37769

Please sign in to comment.