Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose GraphicsAPI #565

Merged
merged 5 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)