ProgramTemplate
class ProgramTemplate
Helper class to create and manage a program template.
Constructor
new ProgramTemplate(vertexTemplateSrc: string, fragmentTemplateSrc: string, name: string) → {}
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| vertexTemplateSrc | string |
<optional> |
vertex shader template |
|
| fragmentTemplateSrc | string |
<optional> |
fragment shader template |
|
| name | string | 'pixi-shader-template' |
name of the shader template. This is used to generate the names for generated programs. |
Summary
Properties from ProgramTemplate
|
The macros used in the fragment shader |
|
|
The fragment shader template |
|
|
The name for generated programs |
|
|
The cache of generated programs for each passed macro value. |
|
|
The macros used in the vertex shader |
|
|
The vertex shader template |
Methods from ProgramTemplate
| PIXI.Program |
Generates a shader program from this template and passed macro-data. |
| TemplateData |
Extracts the macros used in the template source. |
| string |
Evaluates the macros in the template and generates the shader's source. |
Public Properties
programCache
The cache of generated programs for each passed macro value.
Public Methods
generateProgram(data: MacroData, name: string) → {PIXI.Program}
Generates a shader program from this template and passed macro-data.
| Name | Type | Description |
|---|---|---|
| data | MacroData |
data providing the values of the macros in the shader template |
| name | string |
optional name, if another name is desired |
| Type | Description |
|---|---|
| PIXI.Program |
the generated shader program |
Protected Methods
protected extractData(templateSrc: string) → {TemplateData}
Extracts the macros used in the template source.
| Name | Type | Description |
|---|---|---|
| templateSrc | string |
the shader template source |
| Type | Description |
|---|---|
| TemplateData |
protected processData(templateSrc: string, macros: TemplateData, data: MacroData) → {string}
Evaluates the macros in the template and generates the shader's source.
| Name | Type | Description |
|---|---|---|
| templateSrc | string |
template source |
| macros | TemplateData |
data defining the macros in the template source |
| data | MacroData |
data providing the values for the macros |
| Type | Description |
|---|---|
| string |
the generated shader source |