public PresentationPanel(
            Config config,
            IGL gl,
            Action <bool> fullscreenToggleCallback,
            MouseEventHandler onClick,
            MouseEventHandler onMove,
            MouseEventHandler onWheel)
        {
            _config = config;

            _fullscreenToggleCallback = fullscreenToggleCallback;

            GraphicsControl = new GraphicsControl(gl)
            {
                Dock      = DockStyle.Fill,
                BackColor = Color.Black
            };

            // pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
            // http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
            GraphicsControl.MouseClick       += onClick;
            GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
            GraphicsControl.MouseMove        += onMove;
            GraphicsControl.MouseWheel       += onWheel;
        }
Example #2
0
 public ContextRef GetContextForGraphicsControl(GraphicsControl gc)
 {
     return(new ContextRef
     {
         Gc = gc,
         GL = gc.IGL
     });
 }
Example #3
0
		public ContextRef GetContextForGraphicsControl(GraphicsControl gc)
		{
			return new ContextRef
			{
				gc = gc,
				gl = gc.IGL
			};
		}
Example #4
0
 public void Dispose()
 {
     if (IsDisposed)
     {
         return;
     }
     IsDisposed = true;
     GraphicsControl.Dispose();
 }
        public PresentationPanel()
        {
            GL = GlobalWin.GL;

            GraphicsControl           = new GraphicsControl(GL);
            GraphicsControl.Dock      = DockStyle.Fill;
            GraphicsControl.BackColor = Color.Black;

            //pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
            //http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
            GraphicsControl.MouseDoubleClick += (o, e) => HandleFullscreenToggle(o, e);
            GraphicsControl.MouseClick       += (o, e) => GlobalWin.MainForm.MainForm_MouseClick(o, e);
        }
        public PresentationPanel(MainForm mainForm, Config config, IGL gl)
        {
            _mainForm = mainForm;
            _config   = config;

            GraphicsControl = new GraphicsControl(gl)
            {
                Dock      = DockStyle.Fill,
                BackColor = Color.Black
            };

            // pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
            // http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
            GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
            GraphicsControl.MouseClick       += (o, e) => _mainForm.MainForm_MouseClick(o, e);
            GraphicsControl.MouseMove        += (o, e) => _mainForm.MainForm_MouseMove(o, e);
            GraphicsControl.MouseWheel       += (o, e) => _mainForm.MainForm_MouseWheel(o, e);
        }
Example #7
0
        protected override void UpdateSourceDrawingWork(JobInfo job)
        {
            bool alternateVsync = false;

            // only used by alternate vsync
            IGL_SlimDX9 dx9 = null;

            if (!job.Offscreen)
            {
                //apply the vsync setting (should probably try to avoid repeating this)
                var vsync = GlobalConfig.VSyncThrottle || GlobalConfig.VSync;

                //ok, now this is a bit undesirable.
                //maybe the user wants vsync, but not vsync throttle.
                //this makes sense... but we don't have the infrastructure to support it now (we'd have to enable triple buffering or something like that)
                //so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice.
                //update 26-mar-2016: this upsets me. When fast-forwarding and skipping frames, vsync should still work. But I'm not changing it yet
                if (_getIsSecondaryThrottlingDisabled())
                {
                    vsync = false;
                }

                //for now, it's assumed that the presentation panel is the main window, but that may not always be true
                if (vsync && GlobalConfig.DispAlternateVsync && GlobalConfig.VSyncThrottle)
                {
                    dx9 = _gl as IGL_SlimDX9;
                    if (dx9 != null)
                    {
                        alternateVsync = true;
                        //unset normal vsync if we've chosen the alternate vsync
                        vsync = false;
                    }
                }

                //TODO - whats so hard about triple buffering anyway? just enable it always, and change api to SetVsync(enable,throttle)
                //maybe even SetVsync(enable,throttlemethod) or just SetVsync(enable,throttle,advanced)

                if (_lastVsyncSetting != vsync || _lastVsyncSettingGraphicsControl != _graphicsControl)
                {
                    if (_lastVsyncSetting == null && vsync)
                    {
                        // Workaround for vsync not taking effect at startup (Intel graphics related?)
                        _graphicsControl.SetVsync(false);
                    }
                    _graphicsControl.SetVsync(vsync);
                    _lastVsyncSettingGraphicsControl = _graphicsControl;
                    _lastVsyncSetting = vsync;
                }
            }

            // begin rendering on this context
            // should this have been done earlier?
            // do i need to check this on an intel video card to see if running excessively is a problem? (it used to be in the FinalTarget command below, shouldn't be a problem)
            //GraphicsControl.Begin(); // CRITICAL POINT for yabause+GL

            //TODO - auto-create and age these (and dispose when old)
            int rtCounter = 0;

            _currentFilterProgram.RenderTargetProvider = new DisplayManagerRenderTargetProvider(size => _shaderChainFrugalizers[rtCounter++].Get(size));

            _gl.BeginScene();
            RunFilterChainSteps(ref rtCounter, out var rtCurr, out var inFinalTarget);
            _gl.EndScene();

            if (job.Offscreen)
            {
                job.OffscreenBb = rtCurr.Texture2d.Resolve();
                job.OffscreenBb.DiscardAlpha();
                return;
            }

            Debug.Assert(inFinalTarget);

            // wait for vsync to begin
            if (alternateVsync)
            {
                dx9.AlternateVsyncPass(0);
            }

            // present and conclude drawing
            _graphicsControl.SwapBuffers();

            // wait for vsync to end
            if (alternateVsync)
            {
                dx9.AlternateVsyncPass(1);
            }

            // nope. don't do this. workaround for slow context switching on intel GPUs. just switch to another context when necessary before doing anything
            // presentationPanel.GraphicsControl.End();
        }