diff --git a/src/core/const.js b/src/core/const.js index 6b640ee..81ab15c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -149,6 +149,28 @@ NEAREST: 1 }, + /** + * The wrap modes that are supported by pixi. + * + * The DEFAULT wrap mode affects the default wraping mode of future operations. + * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. + * If the texture is non power of two then clamp will be used regardless as webGL can only use REPEAT if the texture is po2 + * This property only affects WebGL + * @static + * @constant + * @property {object} WRAP_MODES + * @property {number} WRAP_MODES.DEFAULT=CLAMP + * @property {number} WRAP_MODES.CLAMP The textures uvs are clamped + * @property {number} WRAP_MODES.REPEAT The texture uvs tile and repeat + * @property {number} WRAP_MODES.MIRRORED_REPEAT The texture uvs tile and repeat with mirroring + */ + WRAP_MODES: { + DEFAULT: 0, + CLAMP: 0, + REPEAT: 1, + MIRRORED_REPEAT:2 + }, + MIPMAP_TEXTURES:true, /** diff --git a/src/core/const.js b/src/core/const.js index 6b640ee..81ab15c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -149,6 +149,28 @@ NEAREST: 1 }, + /** + * The wrap modes that are supported by pixi. + * + * The DEFAULT wrap mode affects the default wraping mode of future operations. + * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. + * If the texture is non power of two then clamp will be used regardless as webGL can only use REPEAT if the texture is po2 + * This property only affects WebGL + * @static + * @constant + * @property {object} WRAP_MODES + * @property {number} WRAP_MODES.DEFAULT=CLAMP + * @property {number} WRAP_MODES.CLAMP The textures uvs are clamped + * @property {number} WRAP_MODES.REPEAT The texture uvs tile and repeat + * @property {number} WRAP_MODES.MIRRORED_REPEAT The texture uvs tile and repeat with mirroring + */ + WRAP_MODES: { + DEFAULT: 0, + CLAMP: 0, + REPEAT: 1, + MIRRORED_REPEAT:2 + }, + MIPMAP_TEXTURES:true, /** diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 51cc899..038338b 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -71,12 +71,32 @@ this._managedTextures.push(texture); - //TODO check is power of two.. - glTexture.enableWrapClamp(); + + - if(texture.mipmap && texture.isPowerOfTwo) + if(texture.isPowerOfTwo) + { + if(texture.mipmap) + { + glTexture.enableMipmap(); + } + + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) + { + glTexture.enableWrapClamp(); + } + else if(texture.wrapMode === CONST.WRAP_MODES.REPEAT) + { + glTexture.enableWrapRepeat(); + } + else + { + glTexture.enableWrapMirrorRepeat(); + } + } + else { - glTexture.enableMipmap(); + glTexture.enableWrapClamp(); } if(texture.scaleMode === CONST.SCALE_MODES.NEAREST) diff --git a/src/core/const.js b/src/core/const.js index 6b640ee..81ab15c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -149,6 +149,28 @@ NEAREST: 1 }, + /** + * The wrap modes that are supported by pixi. + * + * The DEFAULT wrap mode affects the default wraping mode of future operations. + * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. + * If the texture is non power of two then clamp will be used regardless as webGL can only use REPEAT if the texture is po2 + * This property only affects WebGL + * @static + * @constant + * @property {object} WRAP_MODES + * @property {number} WRAP_MODES.DEFAULT=CLAMP + * @property {number} WRAP_MODES.CLAMP The textures uvs are clamped + * @property {number} WRAP_MODES.REPEAT The texture uvs tile and repeat + * @property {number} WRAP_MODES.MIRRORED_REPEAT The texture uvs tile and repeat with mirroring + */ + WRAP_MODES: { + DEFAULT: 0, + CLAMP: 0, + REPEAT: 1, + MIRRORED_REPEAT:2 + }, + MIPMAP_TEXTURES:true, /** diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 51cc899..038338b 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -71,12 +71,32 @@ this._managedTextures.push(texture); - //TODO check is power of two.. - glTexture.enableWrapClamp(); + + - if(texture.mipmap && texture.isPowerOfTwo) + if(texture.isPowerOfTwo) + { + if(texture.mipmap) + { + glTexture.enableMipmap(); + } + + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) + { + glTexture.enableWrapClamp(); + } + else if(texture.wrapMode === CONST.WRAP_MODES.REPEAT) + { + glTexture.enableWrapRepeat(); + } + else + { + glTexture.enableWrapMirrorRepeat(); + } + } + else { - glTexture.enableMipmap(); + glTexture.enableWrapClamp(); } if(texture.scaleMode === CONST.SCALE_MODES.NEAREST) diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index a6adeef..bd767e6 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -131,6 +131,16 @@ */ this.mipmap = CONST.MIPMAP_TEXTURES; + + /** + * + * Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used + * Also the texture must be a power of two size to work + * + * @member {boolean} + */ + this.wrap = CONST.MIPMAP_TEXTURES; + /** * A map of renderer IDs to webgl textures *