Ejemplo n.º 1
0
        public static int BindVertexBuffer(Vertex[] vertexData, int vboID = -1)
        {
            if (vboID == -1)
            {
                GL.GenBuffers(1, out vboID);
            }

            GL.BindBuffer(BufferTarget.ArrayBuffer, vboID);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertexData.Length * VertexSize), vertexData, BufferUsageHint.StreamDraw);            
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            return vboID;
        }
Ejemplo n.º 2
0
        private void GenerateBaseVBO()
        {
            Vertex[] vertexData = new Vertex[12];
            Int32 color = new Color4(0.2f, 0.2f, 0.2f, 0.3f).ToAbgr();

            for (ushort i = 0; i < 6; i++)
            {
                //TODO: use the pair here as a line and shift the border perpendicular to this line in the direction of center, but not towards center itself
                // This should be more accurate then the current method
                vertexData[i * 2] = new Vertex()
                {
                    Position = polar(HexagonSize, i),
                    Color = color
                };
                vertexData[(i * 2) + 1] = new Vertex()
                {
                    Position = polar(HexagonSize, (i + 1) % 6),
                    Color = color
                };
            }

            baseVboID = VBOHelper.BindVertexBuffer(vertexData, baseVboID);
        }
Ejemplo n.º 3
0
        private void GenerateBorder()
        {
            ushort[] indexData = new ushort[12];
            Vertex[] vertexData = new Vertex[12];

            for (ushort i = 0, j = 0; i < 6; i++)
            {
                if (BorderDirection[i] != 0)
                {
                    vertexData[i * 2] = new Vertex()
                    {
                        Position = polar(HexagonSize, i),
                        Color = colorData[i * 2]
                    };
                    vertexData[(i * 2) + 1] = new Vertex()
                    {
                        Position = polar(HexagonSize, (i + 1) % 6),
                        Color = colorData[(i * 2) + 1]
                    };

                    indexData[j * 2] = (ushort)(i * 2);
                    indexData[(j * 2) + 1] = (ushort)((i * 2) + 1);
                    borderIndexLength += 2;
                    j++;
                }
            }

            borderIboID = VBOHelper.BindIndexBuffer(indexData, borderIboID);
            borderVboID = VBOHelper.BindVertexBuffer(vertexData, borderVboID);
            borderChanged = false;
        }