示例#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();
        }
示例#2
0
        private void CreateBuffers()
        {
            _dataSpecification = new BufferDataSpecification
            {
                Count              = 2,
                Name               = "in_position",
                Offset             = 0,
                ShouldBeNormalised = false,
                Stride             = 0,
                Type               = VertexAttribPointerType.Float
            };

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

            var size = 3 * 2 * sizeof(float);

            _vertexBuffer = new VertexBuffer
            {
                BufferUsage     = BufferUsageHint.StreamDraw,
                DrawableIndices = 3,
                MaxSize         = size
            };
            _vertexBuffer.Bind();
            _vertexBuffer.Initialise();
            _vertexBuffer.DataSpecifications.Add(_dataSpecification);

            _vertexArray.Load(_shaderProgram, _vertexBuffer);
            _vertexArray.UnBind();
        }
示例#3
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();
        }