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

            for (int i = 0; i < Value.Length; ++i)
            {
                clone.Value[i] = float.MaxValue;
            }
            return(clone);
        }
        public unsafe void Floats(int offset, Floats param)
        {
            //System.Diagnostics.Debug.WriteLine("Offset " + offset);
            fixed(byte *bptr = &data[offset])
            {
                float *ptr = (float *)bptr;

                for (int i = 0; i < param.Value.Length; ++i)
                {
                    float v = param.Value[i];
                    ptr[i] = v;
                    //System.Diagnostics.Debug.WriteLine("index " + i + " value " + v);
                }
            }

            needsUpload = true;
        }
Example #3
0
 public MultiFloats(string name, Floats @default, params IUniformBuffer[] buffers)
 {
     if (buffers.Length > 0)
     {
         this.floats = new Floats[buffers.Length];
         for (int i = 0; i < buffers.Length; ++i)
         {
             floats[i] =
                 (buffers[i] != null) && (buffers[i].Contains(name))
                 ? buffers[i].Floats(name)
                 : @default;
         }
     }
     else
     {
         this.floats = new Floats[1];
         floats[0]   = @default;
     }
     first = floats[0];
 }
        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++;
            }
        }
 public void SetConstant(float x, float y, float z, float w)
 {
     Floats = new Floats(x, y, z, w);
 }
 public void SetConstant(float x)
 {
     Floats = new Floats(x);
 }
Example #7
0
 public Parameter(string name, Floats @default, IUniformBuffer bufferGL, IUniformBuffer bufferRL)
 {
     ValueGL = (bufferGL != null) && bufferGL.Contains(name) ? bufferGL.Floats(name) : @default;
     ValueRL = (bufferRL != null) && bufferRL.Contains(name) ? bufferRL.Floats(name) : @default;
 }
Example #8
0
 public void Floats(int offset, Floats param)
 {
     bufferRangeGL.Floats(offset, param);
     bufferRangeRL.Floats(offset, param);
 }