// Class: openfl._internal.renderer.opengl.GLShape

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;
var $import = require("./../../../../import_stub").default;
function openfl__$internal_renderer_opengl_GLGraphics() {return require("./../../../../openfl/_internal/renderer/opengl/GLGraphics");}
function lime_utils__$DataPointer_DataPointer_$Impl_$() {return require("./../../../../lime/utils/_DataPointer/DataPointer_Impl_");}

// Constructor

var GLShape = function(){}

// Meta

GLShape.__name__ = ["openfl","_internal","renderer","opengl","GLShape"];
GLShape.prototype = {
	
};
GLShape.prototype.__class__ = $hxClasses["openfl._internal.renderer.opengl.GLShape"] = GLShape;

// Init



// Statics

GLShape.render = function(shape,renderer) {
	if(!shape.__renderable || shape.__worldAlpha <= 0) {
		return;
	}
	var graphics = shape.__graphics;
	if(graphics != null) {
		renderer.__setBlendMode(shape.__worldBlendMode);
		renderer.__pushMaskObject(shape);
		(openfl__$internal_renderer_opengl_GLGraphics().default).render(graphics,renderer);
		var bounds = graphics.__bounds;
		if(graphics.__bitmap != null && graphics.__visible) {
			var gl = renderer.__gl;
			var shader = renderer.__initDisplayShader(shape.__worldShader);
			renderer.setShader(shader);
			renderer.applyBitmapData(graphics.__bitmap,renderer.__allowSmoothing);
			renderer.applyMatrix(renderer.__getMatrix(graphics.__worldTransform));
			renderer.applyAlpha(shape.__worldAlpha);
			renderer.applyColorTransform(shape.__worldColorTransform);
			renderer.updateShader();
			gl.bindBuffer(gl.ARRAY_BUFFER,graphics.__bitmap.getBuffer(gl));
			if(shader.__position != null) {
				gl.vertexAttribPointer(shader.__position.index,3,gl.FLOAT,false,56,(lime_utils__$DataPointer_DataPointer_$Impl_$().default).fromInt(0));
			}
			if(shader.__textureCoord != null) {
				gl.vertexAttribPointer(shader.__textureCoord.index,2,gl.FLOAT,false,56,(lime_utils__$DataPointer_DataPointer_$Impl_$().default).fromInt(12));
			}
			gl.drawArrays(gl.TRIANGLE_STRIP,0,4);
			renderer.__clearShader();
		}
		renderer.__popMaskObject(shape);
	}
}
GLShape.renderMask = function(shape,renderer) {
	var graphics = shape.__graphics;
	if(graphics != null) {
		(openfl__$internal_renderer_opengl_GLGraphics().default).renderMask(graphics,renderer);
		var bounds = graphics.__bounds;
		if(graphics.__bitmap != null) {
			var gl = renderer.__gl;
			var shader = renderer.__maskShader;
			renderer.setShader(shader);
			renderer.applyBitmapData(graphics.__bitmap,renderer.__allowSmoothing);
			renderer.applyMatrix(renderer.__getMatrix(graphics.__worldTransform));
			renderer.updateShader();
			gl.bindBuffer(gl.ARRAY_BUFFER,graphics.__bitmap.getBuffer(gl));
			gl.vertexAttribPointer(shader.__position.index,3,gl.FLOAT,false,56,(lime_utils__$DataPointer_DataPointer_$Impl_$().default).fromInt(0));
			gl.vertexAttribPointer(shader.__textureCoord.index,2,gl.FLOAT,false,56,(lime_utils__$DataPointer_DataPointer_$Impl_$().default).fromInt(12));
			gl.drawArrays(gl.TRIANGLE_STRIP,0,4);
			renderer.__clearShader();
		}
	}
}


// Export

exports.default = GLShape;