Пример #1
0
        internal unsafe void Draw(BufferDrawMode mode)
        {
            if (_isDirty)
            {
                GL.BindBuffer(GL.ARRAY_BUFFER, _bufferId);

                fixed(TVertex *temp = &_vertices[0])
                GL.BufferData(GL.ARRAY_BUFFER, new IntPtr(sizeof(TVertex) * Count), new IntPtr((void *)temp), GL.STATIC_DRAW);

                GL.BindBuffer(GL.ARRAY_BUFFER, 0);
            }

            GL.BindVertexArray(_id);
            GL.DrawArrays((int)mode, 0, Count);
            GL.BindVertexArray(0);
        }
Пример #2
0
        /// <summary>
        /// Draws the contents of another buffer onto this buffer at the specified location.
        /// </summary>
        /// <param name="buffer">The buffer to draw.</param>
        /// <param name="x">The X position to begin drawing at.</param>
        /// <param name="y">The Y position to begin drawing at.</param>
        /// <param name="drawMode">Specified how the buffer should be drawn.</param>
        public void DrawBuffer(ConsoleBuffer buffer, int x, int y, BufferDrawMode drawMode)
        {
            var b = _buffer;
            var b2 = buffer.Buffer;
            int offx = 0;
            int offy = 0;
            int w = buffer._width;
            int h = buffer._height;
            if (x + w < 0 || y + h == 0 || y >= _height || x >= _width)
            {
                return;
            }
            if (w + x > _width)
            {
                w -= w + x - _width;
            }
            if (x < 0)
            {
                offx = -x;
            }
            if (h + y > _height)
            {
                h -= h + y - _height;
            }
            if (y < 0)
            {
                offy = -y;
            }

            switch (drawMode)
            {
                case BufferDrawMode.Additive:
                    {
                        for (int i = w - 1; i >= offx; i--)
                        for (int j = h - 1; j >= offy; j--)
                        {
                            b[j + y + offy, i + x + offx]._attrs |= b2[j, i]._attrs;
                            b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                        }
                    }
                    break;
                case BufferDrawMode.DrawOver:
                    {
                        for (int i = w - 1; i >= offx; i--)
                        for (int j = h - 1; j >= offy; j--)
                        {
                            b[j + y + offy, i + x + offx]._attrs = b2[j, i]._attrs;
                            b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                        }
                    }
                    break;
                case BufferDrawMode.IgnoreBlack:
                    {
                        for (int i = w - 1; i >= offx; i--)
                        for (int j = h - 1; j >= offy; j--)
                        {
                            if (b2[j, i].BackColor != BufferColor.Black)
                            {
                                b[j + y + offy, i + x + offx]._attrs = b2[j, i]._attrs;
                            }
                            b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                        }
                    }
                    break;
            }
        }
Пример #3
0
        /// <summary>
        /// Draws the contents of another buffer onto this buffer at the specified location.
        /// </summary>
        /// <param name="buffer">The buffer to draw.</param>
        /// <param name="x">The X position to begin drawing at.</param>
        /// <param name="y">The Y position to begin drawing at.</param>
        /// <param name="drawMode">Specified how the buffer should be drawn.</param>
        public void DrawBuffer(ConsoleBuffer buffer, int x, int y, BufferDrawMode drawMode)
        {
            var b    = _buffer;
            var b2   = buffer.Buffer;
            int offx = 0;
            int offy = 0;
            int w    = buffer._width;
            int h    = buffer._height;

            if (x + w < 0 || y + h == 0 || y >= _height || x >= _width)
            {
                return;
            }
            if (w + x > _width)
            {
                w -= w + x - _width;
            }
            if (x < 0)
            {
                offx = -x;
            }
            if (h + y > _height)
            {
                h -= h + y - _height;
            }
            if (y < 0)
            {
                offy = -y;
            }

            switch (drawMode)
            {
            case BufferDrawMode.Additive:
            {
                for (int i = w - 1; i >= offx; i--)
                {
                    for (int j = h - 1; j >= offy; j--)
                    {
                        b[j + y + offy, i + x + offx]._attrs  |= b2[j, i]._attrs;
                        b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                    }
                }
            }
            break;

            case BufferDrawMode.DrawOver:
            {
                for (int i = w - 1; i >= offx; i--)
                {
                    for (int j = h - 1; j >= offy; j--)
                    {
                        b[j + y + offy, i + x + offx]._attrs   = b2[j, i]._attrs;
                        b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                    }
                }
            }
            break;

            case BufferDrawMode.IgnoreBlack:
            {
                for (int i = w - 1; i >= offx; i--)
                {
                    for (int j = h - 1; j >= offy; j--)
                    {
                        if (b2[j, i].BackColor != BufferColor.Black)
                        {
                            b[j + y + offy, i + x + offx]._attrs = b2[j, i]._attrs;
                        }
                        b[j + y + offy, i + x + offx].CharData = b2[j, i].CharData;
                    }
                }
            }
            break;
            }
        }