public void GenerateBillboardTextures(IEnumerable <Texture> textures)
        {
            _logger.Information($"Generating billboard textures.");

            foreach (var tex in textures)
            {
                var word  = GenerateBillboardText();
                var color = _billboardColors[_random.Next(_billboardColors.Count)];

                using (var text = new Textbox("Consolas")
                                  .WithText(word, new Vector2(), 1.5f)
                                  .WithHue(color.X)
                                  .WithSaturation(color.Y)
                                  .WithValue(color.Z))
                    using (var renderer = new Renderer.Renderer())
                        using (var backbufferRenderer = new BackBufferRenderer(_logger, tex, tex.Width, tex.Height, false))
                        {
                            renderer.BeforeRender = () => { GL.Enable(EnableCap.Blend); };
                            renderer.AfterRender  = () => { GL.Disable(EnableCap.Blend); };
                            renderer.AddToScene(text.Text);
                            backbufferRenderer.RenderToTexture(renderer, _projectionMatrix, Matrix4.Identity);

                            if (text.CursorAdvance > tex.Width)
                            {
                                _logger.Warning($"The billboard text is wider than the texture width! ({word})");
                            }
                        }
            }
        }
예제 #2
0
        private void OnRenderFrame(FrameEventArgs e)
        {
            CountFps(e);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            var viewMatrix = _camera.Use();

            _worldRenderer.Clear();
            _worldRenderer.RenderToTexture(_skyboxRenderer, _projectionMatrix, new Matrix4(new Matrix3(viewMatrix)));
            _worldRenderer.RenderToTexture(_renderer, _projectionMatrix, viewMatrix);

            if (_isBloomEnabled)
            {
                _postprocessPipeline.RunPipeline();
            }

            GL.Viewport(0, 0, _context.ClientRectangle.Width, _context.ClientRectangle.Height);
            _ndcRenderer.RenderScene(_ndcRendererMatrix, Matrix4.Identity);
            _context.SwapBuffers();
        }