Esempio n. 1
0
        public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
        {
            if (bufferName == position)
            {
                using (var buffer = new PropertyBuffer <vec3>(
                           varNameInShader, 3, GL.GL_FLOAT, BufferUsage.StaticDraw))
                {
                    buffer.Alloc(model.Positions.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < model.Positions.Length; i++)
                        {
                            array[i] = model.Positions[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == color)
            {
                using (var buffer = new PropertyBuffer <vec3>(
                           varNameInShader, 3, GL.GL_FLOAT, BufferUsage.StaticDraw))
                {
                    buffer.Alloc(model.Colors.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < model.Colors.Length; i++)
                        {
                            array[i] = model.Colors[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }