Exemplo n.º 1
0
        public void Attach(ShaderObject shaderObj)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }
            if (shaderObj.Disposed)
            {
                throw new ObjectDisposedException(shaderObj.GetType().FullName);
            }

            if (shaderObj is VertexShader)
            {
                m_VertexShader = (VertexShader)shaderObj;
            }
            else if (shaderObj is FragmentShader)
            {
                m_FragmentShader = (FragmentShader)shaderObj;
            }

            GL.AttachObject(m_Id, shaderObj.Id);

            if (m_UniformLocations != null)
            {
                m_UniformLocations.Clear();
            }

            // TODO: optimize so that there would not be more than one uniform with the same name in the list
            if (shaderObj.StaticAutoUniforms != null)
            {
                if (StaticAutoUniforms == null)
                {
                    StaticAutoUniforms = new List <ShaderAutoUniformInfo>();
                }
                StaticAutoUniforms.AddRange(shaderObj.StaticAutoUniforms);
            }
            if (shaderObj.DynamicAutoUniforms != null)
            {
                if (DynamicAutoUniforms == null)
                {
                    DynamicAutoUniforms = new List <ShaderAutoUniformInfo>();
                }
                DynamicAutoUniforms.AddRange(shaderObj.DynamicAutoUniforms);
            }
            if (m_Version == null || m_Version < shaderObj.Version)
            {
                m_Version = shaderObj.Version;
            }
        }