// Class: openfl.display.ShaderInput

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../hxClasses_stub").default;

// Constructor

var ShaderInput = function() {
	this.channels = 0;
	this.filter = "nearest";
	this.height = 0;
	this.index = 0;
	this.mipFilter = "mipnone";
	this.width = 0;
	this.wrap = "clamp";
}

// Meta

ShaderInput.__name__ = ["openfl","display","ShaderInput"];
ShaderInput.prototype = {
	__updateGL: function(gl,id,overrideInput,overrideFilter,overrideMipFilter,overrideWrap) {
		var input = overrideInput != null ? overrideInput : this.input;
		var filter = overrideFilter != null ? overrideFilter : this.filter;
		var mipFilter = overrideMipFilter != null ? overrideMipFilter : this.mipFilter;
		var wrap = overrideWrap != null ? overrideWrap : this.wrap;
		if(input != null) {
			var bitmapData = input;
			gl.activeTexture(gl.TEXTURE0 + id);
			gl.bindTexture(gl.TEXTURE_2D,bitmapData.getTexture(gl));
			var smooth = filter == "linear";
			switch(mipFilter) {
			case "miplinear":
				gl.generateMipmap(gl.TEXTURE_2D);
				gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,smooth ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_LINEAR);
				break;
			case "mipnearest":
				gl.generateMipmap(gl.TEXTURE_2D);
				gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,smooth ? gl.LINEAR_MIPMAP_NEAREST : gl.NEAREST_MIPMAP_NEAREST);
				break;
			default:
				gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,smooth ? gl.LINEAR : gl.NEAREST);
			}
			gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,smooth ? gl.LINEAR : gl.NEAREST);
			var repeatS = wrap == "repeat" || wrap == "repeat_u_clamp_v";
			var repeatT = wrap == "repeat" || wrap == "clamp_u_repeat_v";
			gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,repeatS ? gl.REPEAT : gl.CLAMP_TO_EDGE);
			gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,repeatT ? gl.REPEAT : gl.CLAMP_TO_EDGE);
		} else {
			gl.activeTexture(gl.TEXTURE0 + id);
			gl.bindTexture(gl.TEXTURE_2D,null);
		}
	}
};
ShaderInput.prototype.__class__ = $hxClasses["openfl.display.ShaderInput"] = ShaderInput;

// Init



// Statics




// Export

exports.default = ShaderInput;