Skip to content

Commit fbec8f9

Browse files
committed
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.
1 parent bce8931 commit fbec8f9

2 files changed

Lines changed: 31 additions & 22 deletions

File tree

src/boot/Config.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ var ValueToColor = require('../display/color/ValueToColor');
7878
* @property {boolean} [pixelArt=false] - [description]
7979
* @property {boolean} [autoResize=false] - [description]
8080
* @property {boolean} [roundPixels=false] - [description]
81-
* @property {boolean} [transparent=true] - [description]
81+
* @property {boolean} [transparent=false] - [description]
8282
* @property {boolean} [clearBeforeRender=true] - [description]
83+
* @property {boolean} [premultipliedAlpha=true] - [description]
8384
* @property {boolean} [preserveDrawingBuffer=false] - [description]
8485
* @property {boolean} [failIfMajorPerformanceCaveat=false] - [description]
8586
* @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default"
@@ -186,15 +187,20 @@ var Config = new Class({
186187
this.fps = GetValue(config, 'fps', null);
187188

188189
// Renderer Settings
189-
this.antialias = GetValue(config, 'antialias', true);
190-
this.pixelArt = GetValue(config, 'pixelArt', false);
191-
this.autoResize = GetValue(config, 'autoResize', false);
192-
this.roundPixels = GetValue(config, 'roundPixels', false);
193-
this.transparent = GetValue(config, 'transparent', true);
194-
this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true);
195-
this.preserveDrawingBuffer = GetValue(config, 'preserveDrawingBuffer', false);
196-
this.failIfMajorPerformanceCaveat = GetValue(config, 'failIfMajorPerformanceCaveat', false);
197-
this.powerPreference = GetValue(config, 'powerPreference', 'default');
190+
// These can either be in a `render` object within the Config, or specified on their own
191+
192+
var renderConfig = GetValue(config, 'render', config);
193+
194+
this.antialias = GetValue(renderConfig, 'antialias', true);
195+
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
196+
this.autoResize = GetValue(renderConfig, 'autoResize', false);
197+
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
198+
this.transparent = GetValue(renderConfig, 'transparent', false);
199+
this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true);
200+
this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true);
201+
this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false);
202+
this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false);
203+
this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default');
198204

199205
var bgc = GetValue(config, 'backgroundColor', 0);
200206

@@ -216,6 +222,7 @@ var Config = new Class({
216222
// gravity: 0,
217223
// cellSize: 64
218224
// }
225+
219226
this.physics = GetValue(config, 'physics', {});
220227
this.defaultPhysicsSystem = GetValue(this.physics, 'default', false);
221228

src/renderer/webgl/WebGLRenderer.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ var WebGLRenderer = new Class({
3636
// eslint-disable-next-line consistent-this
3737
var renderer = this;
3838

39+
var gameConfig = game.config;
40+
3941
var contextCreationConfig = {
40-
alpha: game.config.transparent,
42+
alpha: gameConfig.transparent,
4143
depth: false, // enable when 3D is added in the future
42-
antialias: game.config.antialias,
43-
premultipliedAlpha: game.config.transparent,
44+
antialias: gameConfig.antialias,
45+
premultipliedAlpha: gameConfig.premultipliedAlpha,
4446
stencil: true,
45-
preserveDrawingBuffer: game.config.preserveDrawingBuffer,
46-
failIfMajorPerformanceCaveat: game.config.failIfMajorPerformanceCaveat,
47-
powerPreference: game.config.powerPreference
47+
preserveDrawingBuffer: gameConfig.preserveDrawingBuffer,
48+
failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat,
49+
powerPreference: gameConfig.powerPreference
4850
};
4951

5052
/**
@@ -55,13 +57,13 @@ var WebGLRenderer = new Class({
5557
* @since 3.0.0
5658
*/
5759
this.config = {
58-
clearBeforeRender: game.config.clearBeforeRender,
59-
pixelArt: game.config.pixelArt,
60-
backgroundColor: game.config.backgroundColor,
60+
clearBeforeRender: gameConfig.clearBeforeRender,
61+
pixelArt: gameConfig.pixelArt,
62+
backgroundColor: gameConfig.backgroundColor,
6163
contextCreation: contextCreationConfig,
62-
resolution: game.config.resolution,
63-
autoResize: game.config.autoResize,
64-
roundPixels: game.config.roundPixels
64+
resolution: gameConfig.resolution,
65+
autoResize: gameConfig.autoResize,
66+
roundPixels: gameConfig.roundPixels
6567
};
6668

6769
/**

0 commit comments

Comments
 (0)