Ejemplo n.º 1
0
        FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize, bool includeOSD)
        {
            //select user special FX shader chain
            Dictionary <string, object> selectedChainProperties = new Dictionary <string, object>();

            BizHawk.Client.EmuHawk.Filters.RetroShaderChain selectedChain = null;

            if (Global.Config.TargetDisplayFilter == 3 && ShaderChain_user != null && ShaderChain_user.Available)
            {
                selectedChain = ShaderChain_user;
            }

            BizHawk.Client.EmuHawk.Filters.FinalPresentation fPresent = new BizHawk.Client.EmuHawk.Filters.FinalPresentation(chain_outsize);
            BizHawk.Client.EmuHawk.Filters.SourceImage       fInput   = new BizHawk.Client.EmuHawk.Filters.SourceImage(chain_insize);
            BizHawk.Client.EmuHawk.Filters.OSD fOSD = new BizHawk.Client.EmuHawk.Filters.OSD();
            fOSD.RenderCallback = () =>
            {
                if (!includeOSD)
                {
                    return;
                }
                var size = fOSD.FindInput().SurfaceFormat.Size;
                Renderer.Begin(size.Width, size.Height);
                Renderer.SetBlendState(GL.BlendNormal);
                Renderer.End();
            };

            var chain = new FilterProgram();

            //add the first filter, encompassing output from the emulator core
            chain.AddFilter(fInput, "input");

            //choose final filter
            BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.None;
            if (Global.Config.DispFinalFilter == 1)
            {
                finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.Bilinear;
            }
            if (Global.Config.DispFinalFilter == 2)
            {
                finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.Bicubic;
            }

            finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.None;

            fPresent.FilterOption = finalFilter;

            //add final presentation
            chain.AddFilter(fPresent, "presentation");

            return(chain);
        }
Ejemplo n.º 2
0
        FilterProgram UpdateSourceInternal(JobInfo job)
        {
            _glManager.Activate(CR_GraphicsControl);

            IVideoProvider videoProvider = job.videoProvider;
            bool           simulate      = job.simulate;
            Size           chain_outsize = job.chain_outsize;

            int vw = videoProvider.BufferWidth;
            int vh = videoProvider.BufferHeight;

            if (Global.Config.DispFixAspectRatio)
            {
                if (Global.Config.DispManagerAR == Config.EDispManagerAR.System)
                {
                    vw = videoProvider.VirtualWidth;
                    vh = videoProvider.VirtualHeight;
                }
                if (Global.Config.DispManagerAR == Config.EDispManagerAR.Custom)
                {
                    vw = Global.Config.DispCustomUserARWidth;
                    vh = Global.Config.DispCustomUserARHeight;
                }
            }

            int[] videoBuffer = videoProvider.GetVideoBuffer();

            int  bufferWidth   = videoProvider.BufferWidth;
            int  bufferHeight  = videoProvider.BufferHeight;
            bool isGlTextureId = videoBuffer.Length == 1;

            //TODO - need to do some work here for GDI+ to repair gl texture ID importing
            BitmapBuffer bb           = null;
            Texture2d    videoTexture = null;

            if (!simulate)
            {
                if (isGlTextureId)
                {
                    videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
                }
                else
                {
                    //wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders)
                    bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer);

                    //now, acquire the data sent from the videoProvider into a texture
                    videoTexture = VideoTextureFrugalizer.Get(bb);
                    GL.SetTextureWrapMode(videoTexture, true);
                }

                //TEST (to be removed once we have an actual example of bring in a texture ID from opengl emu core):
                //if (!isGlTextureId)
                //{
                //  videoBuffer = new int[1] { videoTexture.Id.ToInt32() };
                //  goto TESTEROO;
                //}
            }

            //record the size of what we received, since lua and stuff is gonna want to draw onto it
            currEmuWidth  = bufferWidth;
            currEmuHeight = bufferHeight;

            //build the default filter chain and set it up with services filters will need
            Size chain_insize = new Size(bufferWidth, bufferHeight);

            var filterProgram = BuildDefaultChain(chain_insize, chain_outsize, job.includeOSD);

            filterProgram.GuiRenderer = Renderer;
            filterProgram.GL          = GL;

            //setup the source image filter
            BizHawk.Client.EmuHawk.Filters.SourceImage fInput = filterProgram["input"] as BizHawk.Client.EmuHawk.Filters.SourceImage;
            fInput.Texture = videoTexture;

            //setup the final presentation filter
            BizHawk.Client.EmuHawk.Filters.FinalPresentation fPresent = filterProgram["presentation"] as BizHawk.Client.EmuHawk.Filters.FinalPresentation;
            fPresent.VirtualTextureSize = new Size(vw, vh);
            fPresent.TextureSize        = new Size(bufferWidth, bufferHeight);
            fPresent.BackgroundColor    = videoProvider.BackgroundColor;
            fPresent.GuiRenderer        = Renderer;
            fPresent.GL = GL;

            filterProgram.Compile("default", chain_insize, chain_outsize, !job.offscreen);

            if (simulate)
            {
            }
            else
            {
                CurrentFilterProgram = filterProgram;
                UpdateSourceDrawingWork(job);
            }

            //cleanup:
            if (bb != null)
            {
                bb.Dispose();
            }

            return(filterProgram);
        }
Ejemplo n.º 3
0
		FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize, bool includeOSD)
		{
			//select user special FX shader chain
			Dictionary<string, object> selectedChainProperties = new Dictionary<string, object>();
			BizHawk.Client.EmuHawk.Filters.RetroShaderChain selectedChain = null;

			if (Global.Config.TargetDisplayFilter == 3 && ShaderChain_user != null && ShaderChain_user.Available)
				selectedChain = ShaderChain_user;

			BizHawk.Client.EmuHawk.Filters.FinalPresentation fPresent = new BizHawk.Client.EmuHawk.Filters.FinalPresentation(chain_outsize);
			BizHawk.Client.EmuHawk.Filters.SourceImage fInput = new BizHawk.Client.EmuHawk.Filters.SourceImage(chain_insize);
			BizHawk.Client.EmuHawk.Filters.OSD fOSD = new BizHawk.Client.EmuHawk.Filters.OSD();
			fOSD.RenderCallback = () =>
			{
				if (!includeOSD)
					return;
				var size = fOSD.FindInput().SurfaceFormat.Size;
				Renderer.Begin(size.Width, size.Height);
				Renderer.SetBlendState(GL.BlendNormal);
				Renderer.End();
			};

			var chain = new FilterProgram();

			//add the first filter, encompassing output from the emulator core
			chain.AddFilter(fInput, "input");

			//choose final filter
			BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.None;
			if (Global.Config.DispFinalFilter == 1) finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.Bilinear;
			if (Global.Config.DispFinalFilter == 2) finalFilter = BizHawk.Client.EmuHawk.Filters.FinalPresentation.eFilterOption.Bicubic;

			fPresent.FilterOption = finalFilter;

			//add final presentation 
			chain.AddFilter(fPresent, "presentation");

			return chain;
		}