Exemplo n.º 1
0
        private void InitialiseRendering()
        {
            _dataSpecification = new BufferDataSpecification
            {
                Count              = 2,
                Name               = "in_position",
                Offset             = 0,
                ShouldBeNormalised = false,
                Stride             = 0,
                Type               = VertexAttribPointerType.Float,
                SizeInBytes        = sizeof(float)
            };

            _vertexArray = new VertexArray {
                DrawPrimitiveType = PrimitiveType.Triangles
            };
            _vertexArray.Bind();

            _vertexBuffer = new VertexBuffer
            {
                BufferUsage        = BufferUsageHint.StreamDraw,
                DrawableIndices    = _sides.Count(b => b) * 6 * 3,
                MaxDrawableIndices = _sides.Count(b => b) * 6 * 3
            };
            _vertexBuffer.AddSpec(_dataSpecification);
            _vertexBuffer.CalculateMaxSize();
            _vertexBuffer.Bind();
            _vertexBuffer.Initialise();

            _vertexArray.Load(_shaderProgram, _vertexBuffer);
            _vertexArray.UnBind();
        }
Exemplo n.º 2
0
        private void InitialiseRendering()
        {
            _dataSpecification = new BufferDataSpecification
            {
                Count              = 2,
                Name               = "in_position",
                Offset             = 0,
                ShouldBeNormalised = false,
                Stride             = 0,
                Type               = VertexAttribPointerType.Float,
                SizeInBytes        = sizeof(float)
            };

            _vertexArray = new VertexArray {
                DrawPrimitiveType = PrimitiveType.Triangles
            };
            _vertexArray.Bind();

            int totalVerticies = 0;

            for (int i = 0; i < DrawingCount; i++)
            {
                //Multiply by 6 because there are 6 vertices per quad (2 triangles with 3 vertices each)
                totalVerticies += _sides[i].Count(b => b) * 6;
            }

            _vertexBuffer = new VertexBuffer
            {
                BufferUsage        = BufferUsageHint.StreamDraw,
                DrawableIndices    = totalVerticies,
                MaxDrawableIndices = MAX_DRAWABLE_INDICIES
            };
            _vertexBuffer.AddSpec(_dataSpecification);
            _vertexBuffer.CalculateMaxSize();
            _vertexBuffer.Bind();
            _vertexBuffer.Initialise();
            _vertexArray.Load(_shaderProgram, _vertexBuffer);
            _vertexArray.UnBind();
        }