You can now specify all of the renderer config options within a render object in the config. If no render object is found, it will scan the config object directly for the properties.

This commit is contained in:
Richard Davey 2018-03-16 13:22:52 +00:00
parent bce89313c1
commit fbec8f978c
2 changed files with 31 additions and 22 deletions

View file

@ -78,8 +78,9 @@ var ValueToColor = require('../display/color/ValueToColor');
* @property {boolean} [pixelArt=false] - [description]
* @property {boolean} [autoResize=false] - [description]
* @property {boolean} [roundPixels=false] - [description]
* @property {boolean} [transparent=true] - [description]
* @property {boolean} [transparent=false] - [description]
* @property {boolean} [clearBeforeRender=true] - [description]
* @property {boolean} [premultipliedAlpha=true] - [description]
* @property {boolean} [preserveDrawingBuffer=false] - [description]
* @property {boolean} [failIfMajorPerformanceCaveat=false] - [description]
* @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default"
@ -186,15 +187,20 @@ var Config = new Class({
this.fps = GetValue(config, 'fps', null);
// Renderer Settings
this.antialias = GetValue(config, 'antialias', true);
this.pixelArt = GetValue(config, 'pixelArt', false);
this.autoResize = GetValue(config, 'autoResize', false);
this.roundPixels = GetValue(config, 'roundPixels', false);
this.transparent = GetValue(config, 'transparent', true);
this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true);
this.preserveDrawingBuffer = GetValue(config, 'preserveDrawingBuffer', false);
this.failIfMajorPerformanceCaveat = GetValue(config, 'failIfMajorPerformanceCaveat', false);
this.powerPreference = GetValue(config, 'powerPreference', 'default');
// These can either be in a `render` object within the Config, or specified on their own
var renderConfig = GetValue(config, 'render', config);
this.antialias = GetValue(renderConfig, 'antialias', true);
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
this.autoResize = GetValue(renderConfig, 'autoResize', false);
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
this.transparent = GetValue(renderConfig, 'transparent', false);
this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true);
this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true);
this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false);
this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false);
this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default');
var bgc = GetValue(config, 'backgroundColor', 0);
@ -216,6 +222,7 @@ var Config = new Class({
// gravity: 0,
// cellSize: 64
// }
this.physics = GetValue(config, 'physics', {});
this.defaultPhysicsSystem = GetValue(this.physics, 'default', false);

View file

@ -36,15 +36,17 @@ var WebGLRenderer = new Class({
// eslint-disable-next-line consistent-this
var renderer = this;
var gameConfig = game.config;
var contextCreationConfig = {
alpha: game.config.transparent,
alpha: gameConfig.transparent,
depth: false, // enable when 3D is added in the future
antialias: game.config.antialias,
premultipliedAlpha: game.config.transparent,
antialias: gameConfig.antialias,
premultipliedAlpha: gameConfig.premultipliedAlpha,
stencil: true,
preserveDrawingBuffer: game.config.preserveDrawingBuffer,
failIfMajorPerformanceCaveat: game.config.failIfMajorPerformanceCaveat,
powerPreference: game.config.powerPreference
preserveDrawingBuffer: gameConfig.preserveDrawingBuffer,
failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat,
powerPreference: gameConfig.powerPreference
};
/**
@ -55,13 +57,13 @@ var WebGLRenderer = new Class({
* @since 3.0.0
*/
this.config = {
clearBeforeRender: game.config.clearBeforeRender,
pixelArt: game.config.pixelArt,
backgroundColor: game.config.backgroundColor,
clearBeforeRender: gameConfig.clearBeforeRender,
pixelArt: gameConfig.pixelArt,
backgroundColor: gameConfig.backgroundColor,
contextCreation: contextCreationConfig,
resolution: game.config.resolution,
autoResize: game.config.autoResize,
roundPixels: game.config.roundPixels
resolution: gameConfig.resolution,
autoResize: gameConfig.autoResize,
roundPixels: gameConfig.roundPixels
};
/**