33 lines
931 B
JavaScript
33 lines
931 B
JavaScript
|
/**
|
||
|
* R3.D3.API.Shader
|
||
|
* @param apiComponent
|
||
|
* @param code
|
||
|
* @constructor
|
||
|
*/
|
||
|
R3.D3.API.Shader = function(
|
||
|
apiComponent,
|
||
|
code
|
||
|
) {
|
||
|
|
||
|
__API_COMPONENT__;
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(apiComponent.code)) {
|
||
|
switch (this.componentType) {
|
||
|
case R3.Component.SHADER_VERTEX:
|
||
|
apiComponent.code = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
|
||
|
break;
|
||
|
case R3.Component.SHADER_FRAGMENT:
|
||
|
apiComponent.code = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
|
||
|
break;
|
||
|
default :
|
||
|
apiComponent.code = '//shader type not detected';
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
this.code = apiComponent.code;
|
||
|
|
||
|
};
|
||
|
|
||
|
R3.D3.API.Shader.prototype = Object.create(R3.API.Component.prototype);
|
||
|
R3.D3.API.Shader.prototype.constructor = R3.D3.API.Shader;
|