コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.state = null;
     }
     PsmShaderProgram.Delete(this.handle);
     this.handle = 0;
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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);
     }
 }
コード例 #21
0
 public ShaderProgramState(int handle)
 {
     PsmShaderProgram.GetUniformCount(handle, out this.uniformCount);
     PsmShaderProgram.GetAttributeCount(handle, out this.attributeCount);
 }