diff --git a/src/core/const.js b/src/core/const.js index 8abdbe7..f95a110 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -106,6 +106,31 @@ }, /** + * Various webgl draw modes. These can be used to specify which GL drawMode to use + * under certain situations and renderers. + * + * @static + * @constant + * @property {object} DRAW_MODES + * @property {number} DRAW_MODES.POINTS + * @property {number} DRAW_MODES.LINES + * @property {number} DRAW_MODES.LINE_LOOP + * @property {number} DRAW_MODES.LINE_STRIP + * @property {number} DRAW_MODES.TRIANGLES + * @property {number} DRAW_MODES.TRIANGLE_STRIP + * @property {number} DRAW_MODES.TRIANGLE_FAN + */ + DRAW_MODES: { + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6 + }, + + /** * The scale modes that are supported by pixi. * * The DEFAULT scale mode affects the default scaling mode of future operations. diff --git a/src/core/const.js b/src/core/const.js index 8abdbe7..f95a110 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -106,6 +106,31 @@ }, /** + * Various webgl draw modes. These can be used to specify which GL drawMode to use + * under certain situations and renderers. + * + * @static + * @constant + * @property {object} DRAW_MODES + * @property {number} DRAW_MODES.POINTS + * @property {number} DRAW_MODES.LINES + * @property {number} DRAW_MODES.LINE_LOOP + * @property {number} DRAW_MODES.LINE_STRIP + * @property {number} DRAW_MODES.TRIANGLES + * @property {number} DRAW_MODES.TRIANGLE_STRIP + * @property {number} DRAW_MODES.TRIANGLE_FAN + */ + DRAW_MODES: { + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6 + }, + + /** * The scale modes that are supported by pixi. * * The DEFAULT scale mode affects the default scaling mode of future operations. diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index c66fd8a..d94b696 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -145,7 +145,7 @@ this._initContext(); // map some webGL blend modes.. - this._mapBlendModes(); + this._mapGlModes(); /** * An array of render targets @@ -501,7 +501,7 @@ * * @private */ -WebGLRenderer.prototype._mapBlendModes = function () +WebGLRenderer.prototype._mapGlModes = function () { var gl = this.gl; @@ -527,4 +527,17 @@ this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } + + if (!this.drawModes) + { + this.drawModes = {}; + + this.drawModes[CONST.DRAW_MODES.POINTS] = gl.POINTS; + this.drawModes[CONST.DRAW_MODES.LINES] = gl.LINES; + this.drawModes[CONST.DRAW_MODES.LINE_LOOP] = gl.LINE_LOOP; + this.drawModes[CONST.DRAW_MODES.LINE_STRIP] = gl.LINE_STRIP; + this.drawModes[CONST.DRAW_MODES.TRIANGLES] = gl.TRIANGLES; + this.drawModes[CONST.DRAW_MODES.TRIANGLE_STRIP] = gl.TRIANGLE_STRIP; + this.drawModes[CONST.DRAW_MODES.TRIANGLE_FAN] = gl.TRIANGLE_FAN; + } };