Refactor glsl-unit templates

This abuses the template system to allow both a single anonymous shader
and multiple named shaders to be defined in a namespace.
This commit is contained in:
Tom Payne
2013-03-25 15:49:58 +01:00
parent 24cfd8a9be
commit c6cd3e0227
5 changed files with 31 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
// This file is automatically generated, do not edit
goog.provide('{{namespace}}.shader');
goog.provide('{{namespace}}');
goog.require('ol.webgl.shader');
@@ -9,34 +9,34 @@ goog.require('ol.webgl.shader');
* @constructor
* @extends {ol.webgl.shader.Fragment}
*/
{{namespace}}.shader.Fragment = function() {
goog.base(this, {{namespace}}.shader.Fragment.SOURCE);
{{className}}Fragment = function() {
goog.base(this, {{className}}Fragment.SOURCE);
};
goog.inherits({{namespace}}.shader.Fragment, ol.webgl.shader.Fragment);
goog.addSingletonGetter({{namespace}}.shader.Fragment);
goog.inherits({{className}}Fragment, ol.webgl.shader.Fragment);
goog.addSingletonGetter({{className}}Fragment);
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Fragment.DEBUG_SOURCE = 'precision mediump float;\n{{getOriginalFragmentSource}}';
{{className}}Fragment.DEBUG_SOURCE = 'precision mediump float;\n{{getOriginalFragmentSource}}';
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;{{getFragmentSource}}';
{{className}}Fragment.OPTIMIZED_SOURCE = 'precision mediump float;{{getFragmentSource}}';
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Fragment.SOURCE = goog.DEBUG ?
{{namespace}}.shader.Fragment.DEBUG_SOURCE :
{{namespace}}.shader.Fragment.OPTIMIZED_SOURCE;
{{className}}Fragment.SOURCE = goog.DEBUG ?
{{className}}Fragment.DEBUG_SOURCE :
{{className}}Fragment.OPTIMIZED_SOURCE;
@@ -44,40 +44,40 @@ goog.addSingletonGetter({{namespace}}.shader.Fragment);
* @constructor
* @extends {ol.webgl.shader.Vertex}
*/
{{namespace}}.shader.Vertex = function() {
goog.base(this, {{namespace}}.shader.Vertex.SOURCE);
{{className}}Vertex = function() {
goog.base(this, {{className}}Vertex.SOURCE);
};
goog.inherits({{namespace}}.shader.Vertex, ol.webgl.shader.Vertex);
goog.addSingletonGetter({{namespace}}.shader.Vertex);
goog.inherits({{className}}Vertex, ol.webgl.shader.Vertex);
goog.addSingletonGetter({{className}}Vertex);
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Vertex.DEBUG_SOURCE = '{{getOriginalVertexSource}}';
{{className}}Vertex.DEBUG_SOURCE = '{{getOriginalVertexSource}}';
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Vertex.OPTIMIZED_SOURCE = '{{getVertexSource}}';
{{className}}Vertex.OPTIMIZED_SOURCE = '{{getVertexSource}}';
/**
* @const
* @type {string}
*/
{{namespace}}.shader.Vertex.SOURCE = goog.DEBUG ?
{{namespace}}.shader.Vertex.DEBUG_SOURCE :
{{namespace}}.shader.Vertex.OPTIMIZED_SOURCE;
{{className}}Vertex.SOURCE = goog.DEBUG ?
{{className}}Vertex.DEBUG_SOURCE :
{{className}}Vertex.OPTIMIZED_SOURCE;
/**
* @constructor
*/
{{namespace}}.shader.uniform = function() {};
{{namespace}}.uniform = function() {};
{{#getUniforms}}
@@ -85,7 +85,7 @@ goog.addSingletonGetter({{namespace}}.shader.Vertex);
* @const
* @type {string}
*/
{{namespace}}.shader.uniform.{{originalName}} =
{{namespace}}.uniform.{{originalName}} =
goog.DEBUG ? '{{originalName}}' : '{{shortName}}';
{{/getUniforms}}
@@ -93,7 +93,7 @@ goog.addSingletonGetter({{namespace}}.shader.Vertex);
/**
* @constructor
*/
{{namespace}}.shader.attribute = function() {};
{{namespace}}.attribute = function() {};
{{#getAttributes}}
@@ -101,6 +101,6 @@ goog.addSingletonGetter({{namespace}}.shader.Vertex);
* @const
* @type {string}
*/
{{namespace}}.shader.attribute.{{originalName}} =
{{namespace}}.attribute.{{originalName}} =
goog.DEBUG ? '{{originalName}}' : '{{shortName}}';
{{/getAttributes}}