示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PreProcessor"/> class.
 /// </summary>
 public PreProcessor()
 {
     _buffer.Clear();
     _buffer.Triangle(0, 1, 2);
     _buffer.Triangle(0, 2, 3);
     _buffer.VertexFloat(-1, -1);
     _buffer.EndVertex();
     _buffer.VertexFloat(1, -1);
     _buffer.EndVertex();
     _buffer.VertexFloat(1, 1);
     _buffer.EndVertex();
     _buffer.VertexFloat(-1, 1);
     _buffer.EndVertex();
     _vertexArray.SetData(_buffer, BufferUsageHint.StaticDraw);
 }
示例#2
0
        /// <summary>
        /// Begins a new frame and sets the dimensions of the render area.
        /// </summary>
        /// <param name="width">The width in pixels.</param>
        /// <param name="height">The height in pixels.</param>
        internal void BeginFrame(int width, int height)
        {
            if (_width != width || _height != height)
            {
                _width  = width;
                _height = height;

                for (int i = 0; i < _blurFramebuffers.Length; ++i)
                {
                    _blurFramebuffers[i].SetSize(width * 2 / 3, height * 2 / 3);
                }

                float w, h;
                float a = (float)(width / GraphicsConstants.Width * GraphicsConstants.Height / height);
                if (a > 1)
                {
                    h = 1;
                    w = a;
                }
                else
                {
                    w = 1;
                    h = 1 / a;
                }

                _triangleBuffer.Clear();
                _triangleBuffer.Triangle(0, 1, 2);
                _triangleBuffer.Triangle(0, 2, 3);
                _triangleBuffer.VertexFloat(-1, -1);
                _triangleBuffer.VertexFloat(-w, -h);
                _triangleBuffer.EndVertex();
                _triangleBuffer.VertexFloat(1, -1);
                _triangleBuffer.VertexFloat(w, -h);
                _triangleBuffer.EndVertex();
                _triangleBuffer.VertexFloat(1, 1);
                _triangleBuffer.VertexFloat(w, h);
                _triangleBuffer.EndVertex();
                _triangleBuffer.VertexFloat(-1, 1);
                _triangleBuffer.VertexFloat(-w, h);
                _triangleBuffer.EndVertex();
                _vertexArray.SetData(_triangleBuffer, BufferUsageHint.StaticDraw);
            }
        }
示例#3
0
        /// <summary>
        /// Begins a new frame and sets the dimensions of the render area.
        /// </summary>
        /// <param name="width">The width in pixels.</param>
        /// <param name="height">The height in pixels.</param>
        public void BeginFrame(int width, int height)
        {
            _postProcessor.BeginFrame(width, height);

            if ((double)width / (double)height > GraphicsConstants.Width / GraphicsConstants.Height)
            {
                width = (int)Math.Ceiling(height / GraphicsConstants.Height * GraphicsConstants.Width);
            }
            else
            {
                height = (int)Math.Ceiling(width / GraphicsConstants.Width * GraphicsConstants.Height);
            }

            if (_width != width || _height != height)
            {
                _width  = width;
                _height = height;
                _framebuffer.SetSize(width, height);
            }

            _lineBuffer.Clear();
            _pointBuffer.Clear();

            float screenAspect   = (float)_width / (float)_height;
            float terminalAspect = (float)GraphicsConstants.Width / (float)GraphicsConstants.Height;

            if (terminalAspect > screenAspect)
            {
                _xScale  = 2f / (float)GraphicsConstants.Width;
                _xOffset = -1;
                _yScale  = 2f / (float)GraphicsConstants.Height * (screenAspect / terminalAspect);
                _yOffset = -1;
            }
            else
            {
                _xScale  = 2f / (float)GraphicsConstants.Width * (terminalAspect / screenAspect);
                _xOffset = -1;
                _yScale  = 2f / (float)GraphicsConstants.Height;
                _yOffset = -1;
            }
        }