r3-legacy/src/r3-d3-api-shader-0.js

33 lines
931 B
JavaScript
Raw Normal View History

2018-04-09 09:35:04 +02:00
/**
* R3.D3.API.Shader
2019-07-24 14:45:42 +02:00
* @param apiComponent
2018-04-09 09:35:04 +02:00
* @param code
* @constructor
*/
R3.D3.API.Shader = function(
2019-07-24 14:45:42 +02:00
apiComponent,
2018-04-09 09:35:04 +02:00
code
) {
2019-10-06 21:11:18 +02:00
__API_COMPONENT__;
2018-04-09 09:35:04 +02:00
2019-10-06 21:11:18 +02:00
if (R3.Utils.UndefinedOrNull(apiComponent.code)) {
2019-07-24 14:45:42 +02:00
switch (this.componentType) {
case R3.Component.SHADER_VERTEX:
2019-10-06 21:11:18 +02:00
apiComponent.code = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
2018-04-09 09:35:04 +02:00
break;
2019-07-24 14:45:42 +02:00
case R3.Component.SHADER_FRAGMENT:
2019-10-06 21:11:18 +02:00
apiComponent.code = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
2018-04-09 09:35:04 +02:00
break;
default :
2019-10-06 21:11:18 +02:00
apiComponent.code = '//shader type not detected';
2018-04-09 09:35:04 +02:00
break;
}
}
2019-10-06 21:11:18 +02:00
this.code = apiComponent.code;
2018-04-09 09:35:04 +02:00
};
R3.D3.API.Shader.prototype = Object.create(R3.API.Component.prototype);
R3.D3.API.Shader.prototype.constructor = R3.D3.API.Shader;