# TK_Custom_Shader_Definition

## Functions

| `TK_Custom_Shader_Definition`
| `~TK_Custom_Shader_Definition`
`TK_Status` | `Read`
`TK_Status` | `Write`
`TK_Status` | `Clone`
`TK_Status` | `ReadAscii`
`TK_Status` | `WriteAscii`
void | `Reset`
void | `SetName`
void | `SetName`
void | `SetShaderStage`
bool | `GetStageEnum`
bool | `GetStageString`
void | `SetSource`
void | `SetSource`
void | `SetVertexOutputs`
void | `SetVertexOutputs`
void | `SetInputs`
void | `SetInputs`
void | `SetUniforms`
void | `SetUniforms`
void | `SetTextures`

## Detailed Description

class TK_Custom_Shader_Definition : public BBaseOpcodeHandler

  Handles the TKE_Custom_Shader_Definition opcode.

  TK_Custom_Shader_Definition provides support for writing/reading the TKE_Custom_Shader_Definition opcode object to/from an HSF file.

  The HOOPS/3dGS scene-graph supports custom shader.

  Public Functions

  TK_Custom_Shader_Definition()

    constructor

  ~TK_Custom_Shader_Definition()
  virtual TK_Status Read(BStreamFileToolkit &tk)

    Reads data from the toolkit buffer, decodes/decompresses it, and maps it to the opcode handlers data members. User-defined classes which need to write out custom data should utilize one of the available GetData() methods.

    Parameters

      tk – A reference to the BStreamFileToolkit object.

    Returns

      The result of the function call.

  virtual TK_Status Write(BStreamFileToolkit &tk)

    Encodes/compresses data and writes data to the toolkit buffer. User-defined classes which need to write out custom data should utilize one of the available PutData() methods, and first write out the opcode associated with the group of binary data followed by the data itself.

    Parameters

      tk – A reference to the BStreamFileToolkit object.

    Returns

      The result of the function call.

  virtual TK_Status Clone(BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const

    Copies the opcode handler

    Parameters

      - tk – A reference to the BStreamFileToolkit object.

      - handler – A pointer to the opcode handler object. Passed by reference.

    Returns

      The result of the function call.

  TK_Status ReadAscii(BStreamFileToolkit &tk)

    Deprecated.

  TK_Status WriteAscii(BStreamFileToolkit &tk)

    Deprecated.

  virtual void Reset()

    Resets the current opcode handler. This is called by the toolkit when it is done processing an opcode. This method reinitializes any opcode handler variables and frees up temporary data.

  void SetName(char const *name)

    Sets the shader name. Allocates the buffer and copies the shader name string

  void SetName(int length)

    Sets the shader name buffer. Allocates a buffer large enough to hold a string of ‘length’ characters

  void SetShaderStage(int stage)

    Sets the shader stage

  bool GetStageEnum(char const *stage, TKO_Custom_Shader_Def_Stage &stage_enum)

    Gets the primitive enum

  bool GetStageString(TKO_Custom_Shader_Def_Stage stage_enum, char *stage)

    Gets the primitive string

  void SetSource(char const *source)

    Sets the shader source. Allocates the buffer and copies the shader source string

  void SetSource(int length)

    Sets the shader source buffer. Allocates a buffer large enough to hold a string of ‘length’ characters

  void SetVertexOutputs(char const *vertex_outputs)

    Sets the shader vertex outputs. Allocates the buffer and copies the shader vertex outputs string

  void SetVertexOutputs(int length)

    Sets the shader vertex outputs buffer. Allocates a buffer large enough to hold a string of ‘length’ characters

  void SetInputs(char const *vertex_inputs)

    Sets the shader inputs. Allocates the buffer and copies the shader inputs string

  void SetInputs(int length)

    Sets the shader inputs buffer. Allocates a buffer large enough to hold a string of ‘length’ characters

  void SetUniforms(char const *uniforms)

    Sets the shader uniforms. Allocates the buffer and copies the shader uniforms string

  void SetUniforms(int length)

    Sets the shader uniforms buffer. Allocates a buffer large enough to hold a string of ‘length’ characters

  virtual void SetTextures(int length)

    Sets the shader textures array size. Allocates an array large enough to hold an array of ‘length’ integer