Exemple #1
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());
            }
        }
Exemple #2
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());
            }
        }
Exemple #3
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();
        }
        protected void InitializeVAO()
        {
            IModel model = this.model;

            this.positionBufferRenderer = model.GetPositionBufferRenderer(strin_Position);
            //this.colorBufferRenderer = model.GetColorBufferRenderer(strin_Color);
            using (var colorBuffer = new ColorBuffer(strin_Color))
            {
                colorBuffer.Alloc(4 * 6);
                for (int i = 0; i < 6; i++)
                {
                    colorBuffer[i * 4 + 0] = new vec2(0, 0);
                    colorBuffer[i * 4 + 1] = new vec2(0, 1);
                    colorBuffer[i * 4 + 2] = new vec2(1, 1);
                    colorBuffer[i * 4 + 3] = new vec2(1, 0);
                }

                this.colorBufferRenderer = colorBuffer.GetRenderer();
            }
            //this.normalBufferRenderer = model.GetNormalBufferRenderer(strin_Normal);
            this.indexBufferRenderer = model.GetIndexes();

            {
                IndexBufferRenderer renderer = this.indexBufferRenderer as IndexBufferRenderer;
                if (renderer != null)
                {
                    this.elementCount = renderer.ElementCount;
                }
            }
            {
                ZeroIndexBufferRenderer renderer = this.indexBufferRenderer as ZeroIndexBufferRenderer;
                if (renderer != null)
                {
                    this.elementCount = renderer.VertexCount;
                }
            }
        }