Beispiel #1
0
        public IUniformValue GetUninitialized()
        {
            UInts clone = new UInts(Elements, Dimension);

            for (int i = 0; i < Value.Length; ++i)
            {
                clone.Value[i] = uint.MaxValue;
            }
            return(clone);
        }
        public unsafe void UInts(int offset, UInts param)
        {
            fixed(byte *bptr = &data[offset])
            {
                uint *ptr = (uint *)bptr;

                for (int i = 0; i < param.Value.Length; ++i)
                {
                    ptr[i] = param.Value[i];
                }
            }

            needsUpload = true;
        }
        public UniformBufferData(IUniformBlock uniformBlock /*, IBufferRange bufferRange*/)
        {
            this.uniformBlock = uniformBlock;
            //this.uniformBufferRange = bufferRange;
            parameterArray = new IUniformValue[uniformBlock.Uniforms.Count];

            int i = 0;

            foreach (var uniform in uniformBlock.Uniforms)
            {
#if DEBUG_UNIFORM_BUFFER
                System.Diagnostics.Debug.WriteLine(
                    uniform.Type.ToString() + " " + uniform.Name +
                    ", index = " + uniform.Index +
                    ", i = " + i +
                    ", offset = " + uniform.Offset +
                    ", stride = " + uniform.Stride
                    );
#endif
                switch (uniform.Type)
                {
                case ActiveUniformType.Float:       parameterArray[i] = new Floats(1, uniform.Count); break;

                case ActiveUniformType.FloatVec2:   parameterArray[i] = new Floats(2, uniform.Count); break;

                case ActiveUniformType.FloatVec3:   parameterArray[i] = new Floats(3, uniform.Count); break;

                case ActiveUniformType.FloatVec4:   parameterArray[i] = new Floats(4, uniform.Count); break;

                case ActiveUniformType.FloatMat4:   parameterArray[i] = new Floats(16, uniform.Count); break;

                case ActiveUniformType.Int:         parameterArray[i] = new Ints(1, uniform.Count); break;

                case ActiveUniformType.UnsignedInt: parameterArray[i] = new UInts(1, uniform.Count); break;

                case ActiveUniformType.Sampler1D: break;

                case ActiveUniformType.Sampler1DArray: break;

                case ActiveUniformType.Sampler1DArrayShadow: break;

                case ActiveUniformType.Sampler1DShadow: break;

                case ActiveUniformType.Sampler2D: break;

                case ActiveUniformType.Sampler2DArray: break;

                case ActiveUniformType.Sampler2DArrayShadow: break;

                case ActiveUniformType.Sampler2DMultisample: break;

                case ActiveUniformType.Sampler2DMultisampleArray: break;

                case ActiveUniformType.Sampler2DRect: break;

                case ActiveUniformType.Sampler2DRectShadow: break;

                case ActiveUniformType.Sampler2DShadow: break;

                case ActiveUniformType.Sampler3D: break;

                case ActiveUniformType.SamplerBuffer: break;

                case ActiveUniformType.SamplerCube: break;

                case ActiveUniformType.SamplerCubeMapArray: break;

                case ActiveUniformType.SamplerCubeMapArrayShadow: break;

                case ActiveUniformType.SamplerCubeShadow: break;

                default:
                {
                    throw new System.Exception("Unsupported uniform type");
                }
                }
                if (parameterArray[i] != null)
                {
                    parameterArray[i].Index  = i;//uniform.Index;
                    parameters[uniform.Name] = parameterArray[i];
                    if (uniform.Default != null)
                    {
                        parameterArray[i].CopyFrom(uniform.Default);
                    }
                }
                i++;
            }
        }
Beispiel #4
0
 public void UInts(int offset, UInts param)
 {
     bufferRangeGL.UInts(offset, param);
     bufferRangeRL.UInts(offset, param);
 }