Home -> PlatformBindings -> GetRendererPlugin

Declaration

extern "C" bool GetRendererPlugin(unsigned int indexNo, IRendererPlugin& rendererPlugin);

Description

The GetRendererPlugin function is exported by renderer plugin libraries. It fills a RendererPlugin object with information about one renderer implementation provided by the plugin.

Callers that load plugin libraries directly should first resolve and call GetCobaltAPIVersion. Only call GetRendererPlugin after the plugin reports a compatible Cobalt Renderer API version.

The caller passes an index value. Plugins return true when a renderer exists at that index and false when no renderer exists at that index. Callers can enumerate all renderer implementations in a plugin by starting at index zero and incrementing until the function returns false.

ImportantImportant

Use RenderPluginEnumerator when you want the SDK helper to load plugin libraries, check API compatibility, locate this export, and manage plugin ownership for you.

Usage

using GetCobaltAPIVersionFunctionType = void(unsigned int& major, unsigned int& minor, unsigned int& patch);
using GetRendererPluginFunctionType = bool(unsigned int indexNo, IRendererPlugin& rendererPlugin);

auto getCobaltAPIVersion = reinterpret_cast<GetCobaltAPIVersionFunctionType*>(resolvedVersionSymbol);
unsigned int pluginMajor = 0;
unsigned int pluginMinor = 0;
unsigned int pluginPatch = 0;
getCobaltAPIVersion(pluginMajor, pluginMinor, pluginPatch);
if ((pluginMajor != COBALT_RENDERER_API_VERSION_MAJOR) || (pluginMinor != COBALT_RENDERER_API_VERSION_MINOR))
{
    // Reject the plugin before calling GetRendererPlugin.
}

RendererPlugin rendererPlugin;
auto getRendererPlugin = reinterpret_cast<GetRendererPluginFunctionType*>(resolvedRendererPluginSymbol);
if (getRendererPlugin(0, rendererPlugin))
{
    auto deviceEnumerator = rendererPlugin.CreateGraphicsDeviceEnumerator(log->CloneLogger());
}

See also