Skip to content

Commit

Permalink
Expose GraphicsAPI (#565)
Browse files Browse the repository at this point in the history
* Add RenderEngine::CurrentGraphicsAPI

Signed-off-by: Matias N. Goldberg <[email protected]>

* Fix bad merge errors

Signed-off-by: Matias N. Goldberg <[email protected]>

* Rename CurrentGraphicsAPI to GraphicsAPI

Signed-off-by: Matias N. Goldberg <[email protected]>

Co-authored-by: Ian Chen <[email protected]>
  • Loading branch information
darksylinc and iche033 authored Feb 28, 2022
1 parent 1baa935 commit 5e67f41
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 11 deletions.
5 changes: 5 additions & 0 deletions include/ignition/rendering/RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <map>
#include <string>
#include "ignition/rendering/config.hh"
#include "ignition/rendering/GraphicsAPI.hh"
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/Export.hh"

Expand Down Expand Up @@ -163,6 +164,10 @@ namespace ignition
public: virtual ScenePtr CreateScene(unsigned int _id,
const std::string &_name) = 0;

/// \brief Returns the GraphicsAPI currently in use
/// \return GraphicsAPI currently in use
public: virtual rendering::GraphicsAPI GraphicsAPI() const = 0;

/// \brief Set headless mode
/// Only available in OGRE 2.2, which makes use of EGL
/// \param[in] _headless Set to true to enable headless mode.
Expand Down
6 changes: 6 additions & 0 deletions include/ignition/rendering/base/BaseRenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ namespace ignition
// Documentation Inherited
public: virtual void AddResourcePath(const std::string &_path) override;

// Documentation Inherited
public: virtual rendering::GraphicsAPI GraphicsAPI() const override
{
return GraphicsAPI::UNKNOWN;
}

// Documentation Inherited
public: virtual void SetHeadless(bool _headless) override;

Expand Down
3 changes: 3 additions & 0 deletions ogre/include/ignition/rendering/ogre/OgreRenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ namespace ignition

public: void AddResourcePath(const std::string &_uri) override;

// Documentation Inherited
public: virtual rendering::GraphicsAPI GraphicsAPI() const override;

public: virtual Ogre::Root *OgreRoot() const;

public: std::string CreateRenderWindow(const std::string &_handle,
Expand Down
6 changes: 6 additions & 0 deletions ogre/src/OgreRenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ void OgreRenderEngine::AddResourcePath(const std::string &_uri)
}
}

//////////////////////////////////////////////////
GraphicsAPI OgreRenderEngine::GraphicsAPI() const
{
return GraphicsAPI::OPENGL;
}

//////////////////////////////////////////////////
Ogre::Root *OgreRenderEngine::OgreRoot() const
{
Expand Down
7 changes: 3 additions & 4 deletions ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ namespace ignition
const unsigned int _width, const unsigned int _height,
const double _ratio, const unsigned int _antiAliasing);

// Documentation Inherited
public: virtual rendering::GraphicsAPI GraphicsAPI() const override;

/// \brief Create a scene
/// \param[in] _id Unique scene Id
/// \param[in] _name Name of scene
Expand Down Expand Up @@ -214,10 +217,6 @@ namespace ignition
public: Ogre::CompositorWorkspaceListener
*TerraWorkspaceListener() const;

/// \brief Get the render engine's graphics API
/// \return The graphics API enum class
public: rendering::GraphicsAPI GraphicsAPI() const;

/// \brief Pointer to the ogre's overlay system
private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;

Expand Down
3 changes: 2 additions & 1 deletion ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,8 @@ void Ogre2Material::UpdateShaderParams(ConstShaderParamsPtr _params,
<< name_param.first << std::endl;
continue;
}
if (Ogre2RenderEngine::Instance()->GraphicsAPI() == GraphicsAPI::OPENGL)
if (Ogre2RenderEngine::Instance()->GraphicsAPI() ==
GraphicsAPI::OPENGL)
{
// set the texture map index
_ogreParams->setNamedConstant(name_param.first, &texIndex, 1, 1);
Expand Down
12 changes: 6 additions & 6 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,12 @@ std::string Ogre2RenderEngine::CreateRenderWindow(const std::string &_handle,
return stream.str();
}

//////////////////////////////////////////////////
GraphicsAPI Ogre2RenderEngine::GraphicsAPI() const
{
return this->dataPtr->graphicsAPI;
}

//////////////////////////////////////////////////
void Ogre2RenderEngine::InitAttempt()
{
Expand Down Expand Up @@ -1063,12 +1069,6 @@ Ogre::CompositorWorkspaceListener *Ogre2RenderEngine::TerraWorkspaceListener()
return this->dataPtr->terraWorkspaceListener.get();
}

/////////////////////////////////////////////////
GraphicsAPI Ogre2RenderEngine::GraphicsAPI() const
{
return this->dataPtr->graphicsAPI;
}

// Register this plugin
IGNITION_ADD_PLUGIN(ignition::rendering::Ogre2RenderEnginePlugin,
ignition::rendering::RenderEnginePlugin)

0 comments on commit 5e67f41

Please sign in to comment.