Processor

Description

sealed class Tinman.Engine.API.Processor

A simple pre-processor for assembling OpenGL shader source code.

Where applicable, ahead-of-time compilation with SPIR/V is preferred. This class is used when this is not applicable, for example if GL.GL_ARB_gl_spirv is not available or when using GLES.

Public / Constructors

Processor


public constructor Processor → ()

Creates a new instance of Processor.

Public / Methods

Preprocess


public method Preprocess → (2)

file in : Path

[not-null]
Path to the file to pre-process.

define opt : string = null

The initial define or null for none.

returns → string

The resulting file content.

Pre-processes the given file.

The following pre-processor directives are recognized:

  • Include the given file, interpreting file-path as a path relative to the directory that contains the file being processed:

    #include <file-path>
    #include "file-path"
  • Add a pre-processor TOKEN with an optional single-line VALUE to the scope of the file being processed:

    #define TOKEN VALUE?

    All subsequent occurrences of TOKEN will be replaced with the whitespace-trimmed VALUE or removed if there is no value.

  • Include the subsequent code only if TOKEN is defined:

    #ifdef TOKEN
    ...
    #else
    ...
    #endif
  • Include the subsequent code only if TOKEN is not defined:

    #ifndef TOKEN
    ...
    #else
    ...
    #endif

The following content is removed:

  • Single-line comments:

    float value; // This is a single-line comment.
  • Multi-line comments:

    /* Start of a multi-line comment.
     * End of a multi-line comment. */
  • Blank lines

IOException

If an I/O exception has occurred while reading the file(s).

Public / Attributes

Encoding


public attribute Encoding → (get,set)

value : CharacterEncoding

[not-null]
The character encoding.

The character encoding to use.