// Class: lime.utils.GLUtils

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 lime_graphics_opengl_GL() {return require("./../../lime/graphics/opengl/GL");}
function lime_utils_Log() {return require("./../../lime/utils/Log");}

// Constructor

var GLUtils = function(){}

// Meta

GLUtils.__name__ = ["lime","utils","GLUtils"];
GLUtils.prototype = {
	
};
GLUtils.prototype.__class__ = $hxClasses["lime.utils.GLUtils"] = GLUtils;

// Init



// Statics

GLUtils.compileShader = function(source,type) {
	var shader = (lime_graphics_opengl_GL().default).createShader(type);
	(lime_graphics_opengl_GL().default).shaderSource(shader,source);
	(lime_graphics_opengl_GL().default).compileShader(shader);
	if((lime_graphics_opengl_GL().default).getShaderParameter(shader,35713) == 0) {
		var message;
		switch(type) {
		case 35632:
			message = "Error compiling fragment shader";
			break;
		case 35633:
			message = "Error compiling vertex shader";
			break;
		default:
			message = "Error compiling unknown shader type";
		}
		message += "\n" + (lime_graphics_opengl_GL().default).getShaderInfoLog(shader);
		(lime_utils_Log().default).error(message,{ fileName : "GLUtils.hx", lineNumber : 35, className : "lime.utils.GLUtils", methodName : "compileShader"});
	}
	return shader;
}
GLUtils.createProgram = function(vertexSource,fragmentSource) {
	var vertexShader = GLUtils.compileShader(vertexSource,35633);
	var fragmentShader = GLUtils.compileShader(fragmentSource,35632);
	var program = (lime_graphics_opengl_GL().default).createProgram();
	(lime_graphics_opengl_GL().default).attachShader(program,vertexShader);
	(lime_graphics_opengl_GL().default).attachShader(program,fragmentShader);
	(lime_graphics_opengl_GL().default).linkProgram(program);
	if((lime_graphics_opengl_GL().default).getProgramParameter(program,35714) == 0) {
		var message = "Unable to initialize the shader program";
		message += "\n" + (lime_graphics_opengl_GL().default).getProgramInfoLog(program);
		(lime_utils_Log().default).error(message,{ fileName : "GLUtils.hx", lineNumber : 58, className : "lime.utils.GLUtils", methodName : "createProgram"});
	}
	return program;
}


// Export

exports.default = GLUtils;