Inheritance: IDisposable
示例#1
0
        /// <summary>
        /// Initializes the renderer.
        /// </summary>
        public void Initialize()
        {
            _renderContext.Initialize();
            _colorShader = new ShaderProgram();
            var vshader = new VertexShader();
            vshader.Compile(SimpleVertexShader.SourceCode);
            var fshader = new FragmentShader();
            fshader.Compile(SimpleFragmentShader.SourceCode);
            _colorShader.Link(vshader, fshader);
            OpenGLInterops.Enable(OpenGLInterops.GL_BLEND);
            OpenGLInterops.AlphaBlend();
            SetTransform(Matrix2x3.Identity);
            OpenGLColor clearColor = OpenGLHelper.ConvertColor(_graphicsDevice.ClearColor);
            OpenGLInterops.ClearColor(clearColor);
            _windowSize = _window.Size;
            OpenGLInterops.Viewport(0, 0, (int) _windowSize.X, (int) _windowSize.Y);
            _sourceVao = new VertexArray();
            _sourceVao.Bind();
            _colorShader.Bind();
            _sourceEbo = new IndexBuffer();

            var elements = new ushort[]
            {
                0, 1, 2,
                2, 3, 0
            };

            _sourceEbo.Bind();
            _sourceEbo.SetData(elements);

            _sourceVbo = new VertexBuffer();
            _sourceVbo.Bind();

            _graphicsDevice.ClearColorChanged += GraphicsDeviceClearColorChanged;
            _window.ScreenSizeChanged += WindowScreenSizeChanged;
        }