IShaderProgram


This interface has been removed in release 10.0.0. Use IProgram interface instead.

Describes custom shader program which could be used for custom drawing.

A shader program can have modifiable values which are called options. Option can be either simgle value of a set of same values. For example, 3D vector is a options containing 3 values. Each option can be one of 3 possible types. It can contain boolean values, integer values, and floating point values. The common usage of shader program is:

  1. Create shader program using either IRenderer::ShaderProgramCreate method
  2. Add all options using IShaderProgram::AddOption() method
  3. Set option values using IShaderProgram::setOptionValue()
  4. Activate using IRenderer::setShaderProgram()
  5. Call IShaderProgram::ApplyOption() to copy specific options to GPU or IShaderProgram::ApplyOptions() to copy all of them
  6. Render using IRenderer
  7. Activate previous shader program in IRenderer

You can find more information in comments below.

class IShaderProgram
    {
    public:
        enum OPTION_TYPE // Option data type
        {
            otBool, // Boolean
            otInteger, // int
            otFloat // float
        };
    public:
        virtual int getOptionCount() = 0; // Return option count
        virtual AnsiString getOptionName(const int index) = 0; // Return option name by index
        virtual OPTION_TYPE getOptionType(const int index) = 0; // Return option type by index
        virtual int getOptionSize(const int index) = 0; // Return option values count by index
        virtual bool getBoolOptionValue(const int option_index) = 0; // Return boolean option first value
        virtual bool getBoolOptionValue(const int option_index, const int value_index) = 0; // Return boolean option value
        virtual int getIntegerOptionValue(const int option_index) = 0; // Return integer option first value
        virtual int getIntegerOptionValue(const int option_index, const int value_index) = 0; // Return integer option value
        virtual float getFloatOptionValue(const int option_index) = 0; // Return float option first value
        virtual float getFloatOptionValue(const int option_index, const int value_index) = 0; // Return integer option first value

        virtual bool setOptionValue(const int index, const bool value) = 0; // Set boolean option first value
        virtual bool setOptionValue(const int index, const int value) = 0; // Set integer option first value
        virtual bool setOptionValue(const int index, const float value) = 0; // Set float option first value
        virtual bool setOptionValue(const int option_index, const int value_index, const bool value) = 0; // Set boolean option value
        virtual bool setOptionValue(const int option_index, const int value_index, const int value) = 0; // Set integer option value
        virtual bool setOptionValue(const int option_index, const int value_index, const float value) = 0; // Set float option value
        virtual bool setOptionValue(const AnsiString &name, const bool value) = 0; // Set boolean option first value
        virtual bool setOptionValue(const AnsiString &name, const int value) = 0; // Set integer option first value
        virtual bool setOptionValue(const AnsiString &name, const float value) = 0; // Set float option first value
        virtual bool setOptionValue(const AnsiString &name, const int value_index, const bool value) = 0; // Set boolean option value
        virtual bool setOptionValue(const AnsiString &name, const int value_index, const int value) = 0; // Set integer option value
        virtual bool setOptionValue(const AnsiString &name, const int value_index, const float value) = 0; // Set float option value

        virtual void Release() = 0; // Destroy itself

        virtual bool AddOption(const AnsiString &name, const OPTION_TYPE type, const int size = 1) = 0; // Assign new option. Should exists in GPU shader program. Return false if corresponding GPU shader uniform/variable is not found of size is invalid
        virtual bool ApplyOption(const int index) = 0; // Copy option value by index to GPU program. Should be called after program activation. Return false if option is not found
        virtual bool ApplyOption(const AnsiString &name) = 0; // Copy option value by name to GPU program. Should be called after program activation. Return false if option is not found
        virtual void ApplyOptions() = 0; // Copy all option values to GPU program. Should be called after program activation
    };
Namespace: nitisa
Include: Nitisa/Interfaces/IShaderProgram.h