Ejemplo n.º 1
0
        public void SetUniformValue(int index, int offset, float value)
        {
            int errorCode = PsmShaderProgram.SetUniformValue(this.handle, index, offset, ref value, ShaderUniformType.Float);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
Ejemplo n.º 2
0
        public void SetUniformValue(int index, int offset, int[] value)
        {
            int errorCode = PsmShaderProgram.SetUniformValue2(this.handle, index, value, ShaderUniformType.Int, offset, 0, -1);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
Ejemplo n.º 3
0
        public void SetUniformValue(int index, ref Matrix4 value)
        {
            int errorCode = PsmShaderProgram.SetUniformValue(this.handle, index, 0, ref value, ShaderUniformType.Float4x4);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
Ejemplo n.º 4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.state = null;
     }
     PsmShaderProgram.Delete(this.handle);
     this.handle = 0;
 }
Ejemplo n.º 5
0
        public void SetAttributeValue(int index, params float[] value)
        {
            int errorCode = PsmShaderProgram.SetAttributeValue2(this.handle, index, value);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            GraphicsContext.NotifyUpdate(GraphicsUpdate.VertexBuffer);
        }
Ejemplo n.º 6
0
        public void SetAttributeStream(int index, int stream)
        {
            int errorCode = PsmShaderProgram.SetAttributeStream(this.handle, index, stream);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            GraphicsContext.NotifyUpdate(GraphicsUpdate.VertexBuffer);
        }
Ejemplo n.º 7
0
        public void SetUniformBinding(int index, string name)
        {
            int errorCode = PsmShaderProgram.SetUniformBinding(this.handle, index, name);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            PsmShaderProgram.GetUniformCount(this.handle, out this.state.uniformCount);
        }
Ejemplo n.º 8
0
        public int GetUniformTexture(int index)
        {
            int result;
            int uniformTexture = PsmShaderProgram.GetUniformTexture(this.handle, index, out result);

            if (uniformTexture != 0)
            {
                Error.ThrowNativeException(uniformTexture);
            }
            return(result);
        }
Ejemplo n.º 9
0
        public string GetAttributeName(int index)
        {
            string result;
            int    attributeName = PsmShaderProgram.GetAttributeName(this.handle, index, out result);

            if (attributeName != 0)
            {
                Error.ThrowNativeException(attributeName);
            }
            return(result);
        }
Ejemplo n.º 10
0
        public ShaderAttributeType GetAttributeType(int index)
        {
            ShaderAttributeType result;
            int attributeType = PsmShaderProgram.GetAttributeType(this.handle, index, out result);

            if (attributeType != 0)
            {
                Error.ThrowNativeException(attributeType);
            }
            return(result);
        }
Ejemplo n.º 11
0
        public ShaderUniformType GetUniformType(int index)
        {
            ShaderUniformType result;
            int uniformType = PsmShaderProgram.GetUniformType(this.handle, index, out result);

            if (uniformType != 0)
            {
                Error.ThrowNativeException(uniformType);
            }
            return(result);
        }
Ejemplo n.º 12
0
        public void SetAttributeBinding(int index, string name)
        {
            int errorCode = PsmShaderProgram.SetAttributeBinding(this.handle, index, name);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            PsmShaderProgram.GetAttributeCount(this.handle, out this.state.attributeCount);
            GraphicsContext.NotifyUpdate(GraphicsUpdate.VertexBuffer);
        }
Ejemplo n.º 13
0
        public string GetUniformBinding(int index)
        {
            string uniformBinding;
            int    errorCode = PsmShaderProgram.GetUniformBinding(this.handle, index, out uniformBinding);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            return(uniformBinding);
        }
Ejemplo n.º 14
0
        public int FindAttribute(string name)
        {
            int attribute;
            int errorCode = PsmShaderProgram.FindAttribute(this.handle, name, out attribute);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            return(attribute);
        }
Ejemplo n.º 15
0
        public int FindUniform(string name)
        {
            int uniform;
            int errorCode = PsmShaderProgram.FindUniform(this.handle, name, out uniform);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            return(uniform);
        }
Ejemplo n.º 16
0
        public int GetAttributeStream(int index)
        {
            int result;
            int attributeStream = PsmShaderProgram.GetAttributeStream(this.handle, index, out result);

            if (attributeStream != 0)
            {
                Error.ThrowNativeException(attributeStream);
            }
            return(result);
        }
Ejemplo n.º 17
0
        protected ShaderProgram(ShaderProgram program)
        {
            int errorCode = PsmShaderProgram.AddRef(program.handle);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            this.handle = program.handle;
            this.state  = program.state;
        }
Ejemplo n.º 18
0
        public ShaderProgram(byte[] vpFileImage, byte[] fpFileImage, ShaderProgramOption option)
        {
            string[] constKeys = ShaderProgram.GetConstKeys(option);
            int[]    constVals = ShaderProgram.GetConstVals(option);
            int      errorCode = PsmShaderProgram.FromImage(vpFileImage, fpFileImage, constKeys, constVals, out this.handle);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
            this.state = new ShaderProgramState(this.handle);
        }
Ejemplo n.º 19
0
        public void SetUniformValue(int index, int[] value, int to, int from, int count)
        {
            if (count < 0)
            {
                count = int.MaxValue;
            }
            int errorCode = PsmShaderProgram.SetUniformValue2(this.handle, index, value, ShaderUniformType.Int, to, from, count);

            if (errorCode != 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
Ejemplo n.º 20
0
 protected void SwapShader(ShaderProgram program)
 {
     if (program.handle != this.handle)
     {
         int errorCode = PsmShaderProgram.AddRef(program.handle);
         if (errorCode != 0)
         {
             Error.ThrowNativeException(errorCode);
         }
         PsmShaderProgram.Delete(this.handle);
         this.handle = program.handle;
         this.state  = program.state;
         GraphicsContext.NotifyUpdate(GraphicsUpdate.ShaderProgram);
     }
 }
Ejemplo n.º 21
0
 public ShaderProgramState(int handle)
 {
     PsmShaderProgram.GetUniformCount(handle, out this.uniformCount);
     PsmShaderProgram.GetAttributeCount(handle, out this.attributeCount);
 }