Compile() public method

Compiles the ShaderProgram. This is done automatically when loading the ShaderProgram or when binding it.
public Compile ( ) : void
return void
Esempio n. 1
0
        /// <summary>
        /// Binds a ShaderProgram in order to use it.
        /// </summary>
        /// <param name="prog">The ShaderProgram to be bound.</param>
        public static void Bind(ContentRef <ShaderProgram> prog)
        {
            ShaderProgram progRes = prog.IsExplicitNull ? null : prog.Res;

            if (curBound == progRes)
            {
                return;
            }

            if (progRes == null)
            {
                GL.UseProgram(0);
                curBound = null;
            }
            else
            {
                if (!progRes.compiled)
                {
                    progRes.Compile();
                }

                if (progRes.glProgramId == 0)
                {
                    throw new ArgumentException("Specified shader program has no valid OpenGL program Id! Maybe it hasn't been loaded / initialized properly?", "prog");
                }
                if (progRes.Disposed)
                {
                    throw new ArgumentException("Specified shader program has already been deleted!", "prog");
                }

                GL.UseProgram(progRes.glProgramId);
                curBound = progRes;
            }
        }
Esempio n. 2
0
        protected override void OnCopyDataTo(object target, ICloneOperation operation)
        {
            base.OnCopyDataTo(target, operation);
            ShaderProgram targetShader = target as ShaderProgram;

            targetShader.Compile();
        }
Esempio n. 3
0
        protected override void OnCopyTo(Resource r, Duality.Cloning.CloneProvider provider)
        {
            base.OnCopyTo(r, provider);
            ShaderProgram c = r as ShaderProgram;

            c.AttachShaders(this.vert, this.frag);
            if (this.compiled)
            {
                c.Compile();
            }
        }