Shader Manager - Horizon-NTH/HorizonGUI GitHub Wiki

ShaderManager

Overview

The ShaderManager class, located in the hgui namespace, offers a dynamic way to manage Shader in your graphical application. The class can be found inside the header file ShaderManager.h.

Member Functions

  • std::shared_ptr<kernel::Shader> create(const std::string& vertexShaderCode, const std::string& fragmentShaderCode, const std::string& geometryShaderCode = ""): Creates a new shader by specifying vertex shader code, fragment shader code, and an optional geometry shader code.

Example Usage

#include <hgui/header/ShaderManager.h>

{ // Example Usage of ShaderManager
    std::string vertexShaderCode = R"(
        // Vertex shader code
        // ...
    )";

    std::string fragmentShaderCode = R"(
        // Fragment shader code
        // ...
    )";

    std::string geometryShaderCode = R"(
        // Geometry shader code
        // ...
    )";

    // Create a shader
    std::shared_ptr<hgui::kernel::Shader> customShader = hgui::ShaderManager::create(vertexShaderCode, fragmentShaderCode, geometryShaderCode);

    // Use the shader as needed
    // (Render objects using the custom shader here)
} // Here the custom shader is destroyed

Note: In the "Example Usage" section, we demonstrate how to create a custom shader with the ShaderManager class.