예제 #1
0
        public BufferPointer GetBufferRenderer(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var buffer = new PositionBuffer(varNameInShader))
                {
                    buffer.Alloc(positions.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < positions.Count; i++)
                        {
                            array[i] = positions[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else if (bufferName == strColor)
            {
                using (var buffer = new ColorBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Count; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else if (bufferName == strNormal)
            {
                using (var buffer = new NormalBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Count; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var buffer = new PositionBuffer(varNameInShader))
                {
                    buffer.Alloc(positions.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < positions.Length; i++)
                        {
                            array[i] = positions[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strColor)
            {
                using (var buffer = new ColorBuffer(varNameInShader))
                {
                    buffer.Alloc(colors.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < colors.Length; i++)
                        {
                            array[i] = colors[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strNormal)
            {
                using (var buffer = new NormalBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Length; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var positionBuffer = new PositionBuffer(varNameInShader))
                {
                    positionBuffer.Alloc(1);
                    unsafe
                    {
                        var positionArray = (CubePosition *)positionBuffer.FirstElement();
                        positionArray[0] = this.position;
                    }

                    return(positionBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strColor)
            {
                using (var colorBuffer = new ColorBuffer(varNameInShader))
                {
                    colorBuffer.Alloc(1);
                    unsafe
                    {
                        var colorArray = (CubeColor *)colorBuffer.FirstElement();
                        colorArray[0] = this.color;
                    }

                    return(colorBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strNormal)
            {
                using (var normalBuffer = new NormalBuffer(varNameInShader))
                {
                    normalBuffer.Alloc(1);
                    unsafe
                    {
                        var normalArray = (CubeNormal *)normalBuffer.FirstElement();
                        normalArray[0] = this.normal;
                    }

                    return(normalBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        public Objects.VertexBuffers.BufferRenderer GetColorBufferRenderer(string varNameInShader)
        {
            using (var buffer = new ColorBuffer(varNameInShader))
            {
                buffer.Alloc(colors.Length);
                unsafe
                {
                    var array = (GlyphColor *)buffer.FirstElement();
                    for (int i = 0; i < colors.Length; i++)
                    {
                        array[i] = colors[i];
                    }
                }

                return(buffer.GetRenderer());
            }
        }
예제 #5
0
        public CSharpGL.Objects.VertexBuffers.BufferRenderer GetColorBufferRenderer(string varNameInShader)
        {
            using (var buffer = new ColorBuffer(varNameInShader))
            {
                vec3[] colors = this.model.colors;
                buffer.Alloc(colors.Length);
                unsafe
                {
                    vec3 *header = (vec3 *)buffer.FirstElement();
                    for (int i = 0; i < colors.Length; i++)
                    {
                        header[i] = colors[i];
                    }
                }

                return(buffer.GetRenderer());
            }
        }
예제 #6
0
        CSharpGL.Objects.VertexBuffers.BufferPointer IConvert2BufferPointer.GetBufferRenderer(string bufferName, string varNameInShader)
        {
            if (bufferName == strposition)
            {
                using (var buffer = new PositionBuffer(bufferName))
                {
                    buffer.Alloc(this.positionList.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < this.positionList.Count; i++)
                        {
                            array[i] = this.positionList[i];
                        }
                    }

                    return(buffer.GetRenderer());
                }
            }
            else if (bufferName == strcolor)
            {
                using (var buffer = new ColorBuffer(bufferName))
                {
                    buffer.Alloc(this.colorList.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < this.colorList.Count; i++)
                        {
                            array[i] = this.colorList[i];
                        }
                    }

                    return(buffer.GetRenderer());
                }
            }

            throw new NotImplementedException();
        }