gl-texture2d
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "gl-texture2d", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "WebGL texture wrapper", | ||
@@ -5,0 +5,0 @@ "main": "texture.js", |
@@ -9,2 +9,28 @@ "use strict" | ||
var linearTypes = null | ||
var filterTypes = null | ||
var wrapTypes = null | ||
function lazyInitLinearTypes(gl) { | ||
linearTypes = [ | ||
gl.LINEAR, | ||
gl.NEAREST_MIPMAP_LINEAR, | ||
gl.LINEAR_MIPMAP_NEAREST, | ||
gl.LINEAR_MIPMAP_NEAREST | ||
] | ||
filterTypes = [ | ||
gl.NEAREST, | ||
gl.LINEAR, | ||
gl.NEAREST_MIPMAP_NEAREST, | ||
gl.NEAREST_MIPMAP_LINEAR, | ||
gl.LINEAR_MIPMAP_NEAREST, | ||
gl.LINEAR_MIPMAP_LINEAR | ||
] | ||
wrapTypes = [ | ||
gl.REPEAT, | ||
gl.CLAMP_TO_EDGE, | ||
gl.MIRRORED_REPEAT | ||
] | ||
} | ||
var convertFloatToUint8 = makeOp({ | ||
@@ -37,3 +63,12 @@ args:["array", "array"], | ||
this.bind() | ||
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, v) | ||
var gl = this.gl | ||
if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { | ||
if(!webglew(gl).OES_texture_float_linear) { | ||
v = gl.NEAREST | ||
} | ||
} | ||
if(filterTypes.indexOf(v) < 0) { | ||
throw new Error("gl-texture2d: Unknown filter mode " + v) | ||
} | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, v) | ||
return this._minFilter = v | ||
@@ -51,3 +86,12 @@ } | ||
this.bind() | ||
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, v) | ||
var gl = this.gl | ||
if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { | ||
if(!webglew(gl).OES_texture_float_linear) { | ||
v = gl.NEAREST | ||
} | ||
} | ||
if(filterTypes.indexOf(v) < 0) { | ||
throw new Error("gl-texture2d: Unknown filter mode " + v) | ||
} | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, v) | ||
return this._magFilter = v | ||
@@ -63,2 +107,5 @@ } | ||
this.bind() | ||
if(wrapTypes.indexOf(v) < 0) { | ||
throw new Error("gl-texture2d: Unknown wrap mode " + v) | ||
} | ||
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, v) | ||
@@ -75,2 +122,5 @@ return this._wrapS = v | ||
this.bind() | ||
if(wrapTypes.indexOf(v) < 0) { | ||
throw new Error("gl-texture2d: Unknown wrap mode " + v) | ||
} | ||
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, v) | ||
@@ -363,2 +413,5 @@ return this._wrapT = v | ||
} | ||
if(!linearTypes) { | ||
linearTypes = lazyInitLinearTypes(gl) | ||
} | ||
if(typeof arguments[1] === "object") { | ||
@@ -365,0 +418,0 @@ var obj = arguments[1] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20431
401