Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new shader.
        /// </summary>
        /// <param name="gl">GL interface containing shader entry points.</param>
        /// <param name="shaderType">Type of OpenGL shader to instantiate.</param>
        /// <param name="code">Shader code.</param>
        /// <exception cref="ArgumentNullException">Thrown if <see cref="gl"/> is null, or if <see cref="code"/> is null or empty.</exception>
        protected Shader(IOpenGL30 gl, ShaderType shaderType, string code)
        {
            if(gl == null)
                throw new ArgumentNullException("gl");
            if(string.IsNullOrEmpty(code))
                throw new ArgumentNullException("code");
            _gl = gl;
            Handle = gl.CreateShader((uint)shaderType);
            if(Handle == 0)
                throw new NoHandleCreatedException();

            _shaderType = shaderType;
            this._code = code;
        }