2017-01-10 17:04:30 +01:00
|
|
|
/**
|
|
|
|
* This component renders a scene
|
|
|
|
* @param id String
|
|
|
|
* @param name String
|
|
|
|
* @param width
|
|
|
|
* @param height
|
|
|
|
* @param minFilter
|
|
|
|
* @param magFilter
|
|
|
|
* @param format
|
|
|
|
* @param stencilBuffer
|
2017-01-12 17:40:17 +01:00
|
|
|
* @param texture
|
2017-01-10 17:04:30 +01:00
|
|
|
* @param parentEntity
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.RenderTarget = function (
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
minFilter,
|
|
|
|
magFilter,
|
|
|
|
format,
|
|
|
|
stencilBuffer,
|
2017-01-12 17:40:17 +01:00
|
|
|
texture,
|
2017-01-10 17:04:30 +01:00
|
|
|
parentEntity
|
|
|
|
) {
|
|
|
|
|
|
|
|
GameLib.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.COMPONENT_RENDER_TARGET,
|
2017-01-12 17:40:17 +01:00
|
|
|
{
|
2017-01-19 17:50:11 +01:00
|
|
|
'texture' : GameLib.D3.Texture
|
2017-01-12 17:40:17 +01:00
|
|
|
},
|
2017-01-10 17:04:30 +01:00
|
|
|
parentEntity
|
|
|
|
);
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'Render Target (' + id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
|
|
width = 800;
|
|
|
|
}
|
|
|
|
this.width = width;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
|
|
height = 600;
|
|
|
|
}
|
|
|
|
this.height = height;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(minFilter)) {
|
|
|
|
minFilter = GameLib.D3.RenderTarget.LINEAR_FILTER;
|
|
|
|
}
|
|
|
|
this.minFilter = minFilter;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(magFilter)) {
|
|
|
|
magFilter = GameLib.D3.RenderTarget.LINEAR_FILTER;
|
|
|
|
}
|
|
|
|
this.magFilter = magFilter;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(format)) {
|
|
|
|
format = GameLib.D3.RenderTarget.RGB_FORMAT;
|
|
|
|
}
|
|
|
|
this.format = format;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(stencilBuffer)) {
|
|
|
|
stencilBuffer = false;
|
|
|
|
}
|
|
|
|
this.stencilBuffer = stencilBuffer;
|
|
|
|
|
2017-01-12 17:40:17 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(texture)) {
|
|
|
|
texture = null;
|
|
|
|
}
|
|
|
|
this.texture = texture;
|
|
|
|
|
2017-01-10 17:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.RenderTarget.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.RenderTarget.prototype.constructor = GameLib.D3.API.RenderTarget;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.RenderTarget
|
|
|
|
* @param objectComponent
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.RenderTarget.FromObjectComponent = function(objectComponent) {
|
|
|
|
return new GameLib.D3.API.RenderTarget(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
|
|
|
objectComponent.width,
|
|
|
|
objectComponent.height,
|
|
|
|
objectComponent.minFilter,
|
|
|
|
objectComponent.magFilter,
|
|
|
|
objectComponent.format,
|
|
|
|
objectComponent.stencilBuffer,
|
2017-01-12 17:40:17 +01:00
|
|
|
objectComponent.texture,
|
2017-01-10 17:04:30 +01:00
|
|
|
objectComponent.parentEntity
|
|
|
|
);
|
|
|
|
};
|