示例#1
0
        internal void UniformMatrix4fv(WebGLUniformLocation location, bool transpose, ref Matrix4 value)
        {
            int transposeInt = transpose ? 1 : 0;

            InvokeCanvasMethodUnmarshalled <object>(UnmarshalledCanvasMethod.UniformMatrix4fv, location.Program.Id, location.Name, transpose, value.ToArray());
            //InvokeCanvasMethod("uniformMatrix4fv", new object[] { location, transpose, new ContextObject(ContextType.WrapIntoFloat32Array, value.ToArray()) });
        }
示例#2
0
        internal void SetProgramUniform(WebGLUniformLocation location, int dimensions, string type, object value)
        {
            if (currentlyUsedShaderProgram != location.Program)
            {
                throw new WebGLException("Program of this location is not bound.");
            }

            if (dimensions < 1 || dimensions > 4)
            {
                throw new ArgumentOutOfRangeException("dimensions");
            }

            object[] args = new object[4 + dimensions];
            args[0] = location.Program.Id;
            args[1] = location.Name;
            args[2] = dimensions;
            args[3] = type;

            if (type == "f" || type == "fv")
            {
                if (value is float[] && ((float[])value).Length == dimensions)
                {
                    Array.Copy((float[])value, 0, args, 4, dimensions);
                }
                else if (value is float)
                {
                    args[4] = value;
                }
                else
                {
                    throw new ArgumentException("Values is invalid for the specified type and dimensions", "value");
                }
            }
            else if (type == "i" || type == "iv")
            {
                if (value is int[] && ((int[])value).Length == dimensions)
                {
                    Array.Copy((int[])value, 0, args, 4, dimensions);
                }
                else if (value is int)
                {
                    args[4] = value;
                }
                else
                {
                    throw new ArgumentException("Values is invalid for the specified type and dimensions", "value");
                }
            }
            else
            {
                throw new ArgumentException("Type is invalid", "type");
            }

            InvokeCanvasMethodUnmarshalled <object>(UnmarshalledCanvasMethod.Uniform1234fiv, args);
        }