示例#1
0
        public override void InitializeRenderer()
        {
            // First take exclusivity on the OpenGL context.
            ((Renderer)Renderer).InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext(_openGLContext));

            _openGLContext.MakeCurrent(_nativeWindow);

            GL.ClearColor(0, 0, 0, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();
        }
示例#2
0
        public void Render()
        {
            // First take exclusivity on the OpenGL context.
            _renderer.InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext(OpenGLContext));

            Gtk.Window parent = Toplevel as Gtk.Window;
            parent.Present();

            OpenGLContext.MakeCurrent(NativeWindow);

            _device.Gpu.Renderer.Initialize(_glLogLevel);

            // Make sure the first frame is not transparent.
            GL.ClearColor(0, 0, 0, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();

            _device.Gpu.InitializeShaderCache();
            Translator.IsReadyForTranslation.Set();

            while (_isActive)
            {
                if (_isStopped)
                {
                    return;
                }

                _ticks += _chrono.ElapsedTicks;

                _chrono.Restart();

                if (_device.WaitFifo())
                {
                    _device.Statistics.RecordFifoStart();
                    _device.ProcessFrame();
                    _device.Statistics.RecordFifoEnd();
                }

                while (_device.ConsumeFrameAvailable())
                {
                    _device.PresentFrame(SwapBuffers);
                }

                if (_ticks >= _ticksPerFrame)
                {
                    string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld";
                    float  scale      = Graphics.Gpu.GraphicsConfig.ResScale;
                    if (scale != 1)
                    {
                        dockedMode += $" ({scale}x)";
                    }

                    StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                   _device.EnableDeviceVsync,
                                                   dockedMode,
                                                   ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
                                                   $"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS",
                                                   $"FIFO: {_device.Statistics.GetFifoPercent():0.00} %",
                                                   $"GPU:  {_renderer.GpuVendor}"));

                    _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                }
            }
        }