Ejemplo n.º 1
0
		public Texture2d(IGL owner, IntPtr id, int width, int height)
		{
			Owner = owner;
			Id = id;
			Width = width;
			Height = height;
		}
Ejemplo n.º 2
0
		public RenderTarget(IGL owner, object opaque, Texture2d tex)
		{
			Owner = owner;
			Opaque = opaque;
			Texture2d = tex;
			tex.IsUpsideDown = true;
		}
Ejemplo n.º 3
0
		public Texture2d(IGL owner, object opaque, int width, int height)
		{
			Owner = owner;
			Opaque = opaque;
			Width = width;
			Height = height;
		}
Ejemplo n.º 4
0
        public DisplayManager(PresentationPanel presentationPanel)
        {
            GL = GlobalWin.GL;
            this.presentationPanel = presentationPanel;
            GraphicsControl = this.presentationPanel.GraphicsControl;
            CR_GraphicsControl = GlobalWin.GLManager.GetContextForGraphicsControl(GraphicsControl);

            //it's sort of important for these to be initialized to something nonzero
            currEmuWidth = currEmuHeight = 1;

            if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)
                Renderer = new GuiRenderer(GL);
            else if (GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
                Renderer = new GuiRenderer(GL);
            else
                Renderer = new GDIPlusGuiRenderer((BizHawk.Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus)GL);

            VideoTextureFrugalizer = new TextureFrugalizer(GL);

            ShaderChainFrugalizers = new RenderTargetFrugalizer[16]; //hacky hardcoded limit.. need some other way to manage these
            for (int i = 0; i < 16; i++)
            {
                ShaderChainFrugalizers[i] = new RenderTargetFrugalizer(GL);
            }

            using (var xml = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px.fnt"))
            using (var tex = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px_0.png"))
                TheOneFont = new StringRenderer(GL, xml, tex);

            using (var gens = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.gens.ttf"))
                LoadCustomFont(gens);
            using (var fceux = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.fceux.ttf"))
                LoadCustomFont(fceux);

            if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK || GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
            {
                var fiHq2x = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/hq2x.cgp"));
                if (fiHq2x.Exists)
                    using (var stream = fiHq2x.OpenRead())
                        ShaderChain_hq2x = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
                var fiScanlines = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/BizScanlines.cgp"));
                if (fiScanlines.Exists)
                    using (var stream = fiScanlines.OpenRead())
                        ShaderChain_scanlines = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
                string bicubic_path = "Shaders/BizHawk/bicubic-fast.cgp";
                if(GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
                    bicubic_path = "Shaders/BizHawk/bicubic-normal.cgp";
                var fiBicubic = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), bicubic_path));
                if (fiBicubic.Exists)
                    using (var stream = fiBicubic.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
                        ShaderChain_bicubic = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
            }

            LuaSurfaceSets["emu"] = new SwappableDisplaySurfaceSet();
            LuaSurfaceSets["native"] = new SwappableDisplaySurfaceSet();
            LuaSurfaceFrugalizers["emu"] = new TextureFrugalizer(GL);
            LuaSurfaceFrugalizers["native"] = new TextureFrugalizer(GL);

            RefreshUserShader();
        }
Ejemplo n.º 5
0
		public Shader(IGL owner, object opaque, bool available)
		{
			Owner = owner;
			Opaque = opaque;
			Available = available;
			Errors = "";
		}
Ejemplo n.º 6
0
 public RenderTarget(IGL owner, IntPtr handle, Texture2d tex)
 {
     Owner = owner;
     Id = handle;
     Texture2d = tex;
     tex.IsUpsideDown = true;
 }
Ejemplo n.º 7
0
        public GuiRenderer(IGL owner)
        {
            Owner = owner;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("aPosition", 0, 2, VertexAttribPointerType.Float, AttributeUsage.Position, false, 32, 0);
            VertexLayout.DefineVertexAttribute("aTexcoord", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 32, 8);
            VertexLayout.DefineVertexAttribute("aColor", 2, 4, VertexAttribPointerType.Float, AttributeUsage.Texcoord1, false, 32, 16);
            VertexLayout.Close();

            _Projection = new MatrixStack();
            _Modelview  = new MatrixStack();

            string psProgram, vsProgram;

            if (owner.API == "D3D9")
            {
                vsProgram = DefaultShader_d3d9;
                psProgram = DefaultShader_d3d9;
            }
            else
            {
                vsProgram = DefaultVertexShader_gl;
                psProgram = DefaultPixelShader_gl;
            }

            var vs = Owner.CreateVertexShader(false, vsProgram, "vsmain", true);
            var ps = Owner.CreateFragmentShader(false, psProgram, "psmain", true);

            CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true, "xgui");
        }
Ejemplo n.º 8
0
		public GuiRenderer(IGL owner)
		{
			Owner = owner;

			VertexLayout = owner.CreateVertexLayout();
			VertexLayout.DefineVertexAttribute("aPosition", 0, 2, VertexAttribPointerType.Float, AttributeUsage.Position, false, 32, 0);
			VertexLayout.DefineVertexAttribute("aTexcoord", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 32, 8);
			VertexLayout.DefineVertexAttribute("aColor", 2, 4, VertexAttribPointerType.Float, AttributeUsage.Texcoord1, false, 32, 16);
			VertexLayout.Close();

			_Projection = new MatrixStack();
			_Modelview = new MatrixStack();

			string psProgram, vsProgram;

			if (owner.API == "D3D9")
			{
				vsProgram = DefaultShader_d3d9;
				psProgram = DefaultShader_d3d9;
			}
			else
			{
				vsProgram = DefaultVertexShader_gl;
				psProgram = DefaultPixelShader_gl;
			}

			var vs = Owner.CreateVertexShader(false, vsProgram, "vsmain", true);
			var ps = Owner.CreateFragmentShader(false, psProgram, "psmain", true);
			CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true, "xgui");
		}
Ejemplo n.º 9
0
		public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
		{
			Owner = owner;
			this.Preset = preset;
			Passes = preset.Passes.ToArray();

			bool ok = true;

			//load up the shaders
			Shaders = new RetroShader[preset.Passes.Count];
			for (int i = 0; i < preset.Passes.Count; i++)
			{
				RetroShaderPreset.ShaderPass pass = preset.Passes[i];

				//acquire content
				string path = Path.Combine(baseDirectory, pass.ShaderPath);
				if (!File.Exists(path))
				{
					ok = false;
					break;
				}
				string content = File.ReadAllText(path);

				var shader = new RetroShader(Owner, content, debug);
				Shaders[i] = shader;
				if (!shader.Pipeline.Available)
					ok = false;
				if (!shader.Available)
					ok = false;
			}

			Available = ok;
		}
Ejemplo n.º 10
0
		public DisplayManager(PresentationPanel presentationPanel, IGL gl, GLManager glManager)
		{
			GL = gl;
			this.presentationPanel = presentationPanel;
			GraphicsControl = this.presentationPanel.GraphicsControl;
			CR_GraphicsControl = glManager.GetContextForGraphicsControl(GraphicsControl);
			_glManager = glManager;

			//it's sort of important for these to be initialized to something nonzero
			currEmuWidth = currEmuHeight = 1;

			if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)
				Renderer = new GuiRenderer(GL);
			else if (GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
				Renderer = new GuiRenderer(GL);
			else
				Renderer = new GDIPlusGuiRenderer((BizHawk.Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus)GL);

			VideoTextureFrugalizer = new BizHawk.Client.EmuHawk.TextureFrugalizer(GL);

			ShaderChainFrugalizers = new RenderTargetFrugalizer[16]; //hacky hardcoded limit.. need some other way to manage these
			for (int i = 0; i < 16; i++)
			{
				ShaderChainFrugalizers[i] = new RenderTargetFrugalizer(GL);
			}

			RefreshUserShader();
		}
Ejemplo n.º 11
0
 /// <summary>
 /// This might not be a GL implementation. If it isnt GL, then setting it as active context is just NOP
 /// </summary>
 public ContextRef GetContextForIGL(IGL gl)
 {
     return new ContextRef
     {
         gl = gl
     };
 }
Ejemplo n.º 12
0
        public GraphicsControl(IGL owner)
        {
            SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserMouse, true);

            //in case we need it
            //GLControl.GetType().GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(GLControl, new object[] { System.Windows.Forms.ControlStyles.UserMouse, true });

            IGC = owner.Internal_CreateGraphicsControl();
            Managed = IGC as Control;
            Managed.Dock = DockStyle.Fill;
            Controls.Add(Managed);

            //pass through these events to the form. I tried really hard to find a better way, but there is none.
            //(dont use HTTRANSPARENT, it isnt portable, I would assume)
            Managed.MouseDoubleClick += (object sender, MouseEventArgs e) => OnMouseDoubleClick(e);
            Managed.MouseClick += (object sender, MouseEventArgs e) => OnMouseClick(e);
            Managed.MouseEnter += (object sender, EventArgs e) => OnMouseEnter(e);
            Managed.MouseLeave += (object sender, EventArgs e) => OnMouseLeave(e);
            Managed.MouseMove += (object sender, MouseEventArgs e) => OnMouseMove(e);

            //the GraphicsControl is occupying all of our area. So we pretty much never get paint events ourselves.
            //So lets capture its paint event and use it for ourselves (it doesnt know how to do anything, anyway)
            Managed.Paint += new PaintEventHandler(GraphicsControl_Paint);
        }
Ejemplo n.º 13
0
 public Texture2d(IGL owner, object opaque, int width, int height)
 {
     Owner  = owner;
     Opaque = opaque;
     Width  = width;
     Height = height;
 }
Ejemplo n.º 14
0
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner  = owner;
            Preset = preset;
            Passes = preset.Passes.ToArray();
            Errors = "";

            //load up the shaders
            var shaders = new RetroShader[preset.Passes.Count];

            for (var i = 0; i < preset.Passes.Count; i++)
            {
                //acquire content. we look for it in any reasonable filename so that one preset can bind to multiple shaders
                string content;
                var    path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
                if (!File.Exists(path))
                {
                    if (!Path.HasExtension(path))
                    {
                        path += ".cg";
                    }
                    if (!File.Exists(path))
                    {
                        if (owner.API == "OPENGL")
                        {
                            path = Path.ChangeExtension(path, ".glsl");
                        }
                        else
                        {
                            path = Path.ChangeExtension(path, ".hlsl");
                        }
                    }
                }
                try
                {
                    content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
                }
                catch (DirectoryNotFoundException e)
                {
                    Errors += $"caught {nameof(DirectoryNotFoundException)}: {e.Message}\n";
                    return;
                }
                catch (FileNotFoundException e)
                {
                    Errors += $"could not read file {e.FileName}\n";
                    return;
                }

                var shader = shaders[i] = new RetroShader(Owner, content, debug);
                if (!shader.Available)
                {
                    Errors += $"===================\r\nPass {i}:\r\n{(shader.Errors??"").Replace("\n","\r\n")}\n";
                    return;
                }
            }

            Shaders   = shaders;
            Available = true;
        }
Ejemplo n.º 15
0
 public Video(IGL gl)
 {
     _gl                       = gl;
     _mediaPlayer              = new MediaPlayer();
     _mediaPlayer.MediaOpened += OnMediaOpened;
     _mediaPlayer.MediaFailed += OnMediaFailed;
     _drawingVisual            = new DrawingVisual();
 }
Ejemplo n.º 16
0
 internal static IGL GetSystem()
 {
     if (m_GLSystem == null)
     {
         m_GLSystem = new GLSystem();
     }
     return(m_GLSystem);
 }
Ejemplo n.º 17
0
        public static void SetOpenGL(IGL gl)
        {
#if CONFIG_MAC
            Mono.MonoImpl.SetOpenGL(gl);
#else
            WPF.VideoImpl.SetOpenGL(gl);
#endif
        }
Ejemplo n.º 18
0
 public MyGameWindow()
     : base(256, 256, new GraphicsMode(new ColorFormat(32), 24, 8, 4), "Object.GL Tester",
            GameWindowFlags.Default, DisplayDevice.Default)
 {
     gl                   = new DefaultGL();
     contextInfra         = new ContextInfra(Context);
     VSync                = VSyncMode.On;
     Context.SwapInterval = 1;
 }
Ejemplo n.º 19
0
 private void DrawQuad(IGL gl)
 {
     gl.Begin(PrimitiveType.Quads);
     SetQuadVertex(gl, 0.0f, 0.0f);
     SetQuadVertex(gl, 1.0f, 0.0f);
     SetQuadVertex(gl, 1.0f, 1.0f);
     SetQuadVertex(gl, 0.0f, 1.0f);
     gl.End();
 }
Ejemplo n.º 20
0
 public PixelBuffer(IGL gl, IntPtr handle)
 {
     _gl     = gl;
     _handle = handle;
     if (_handle == IntPtr.Zero)
     {
         throw new ArgumentNullException();
     }
 }
Ejemplo n.º 21
0
 private void DrawQuad(IGL gl)
 {
     gl.Begin(PrimitiveType.Quads);
     SetQuadVertex(gl, 0.0f, 0.0f);
     SetQuadVertex(gl, 1.0f, 0.0f);
     SetQuadVertex(gl, 1.0f, 1.0f);
     SetQuadVertex(gl, 0.0f, 1.0f);
     gl.End();
 }
Ejemplo n.º 22
0
        public void Add(IGL gl)
        {
            if (m_renderObjects.Contains(gl))
            {
                return;
            }

            m_renderObjects.Add(gl);
        }
Ejemplo n.º 23
0
        public GLView1(Context context, IClientSettings settings)
            : base(context)
        {
            this.settings = settings;

            gl = new AndroidGL();
            nativeGraphicsContext = new GameViewContext(this);
            assetManager = context.Assets;
            KeepScreenOn = true;
        }
Ejemplo n.º 24
0
 public static void Clear(this IGL gl, System.Windows.Media.Color color, float depth)
 {
     gl.ClearColor(
         ((float)color.R) / 255,
         ((float)color.G) / 255,
         ((float)color.B) / 255,
         ((float)color.A) / 255);
     gl.ClearDepth(depth);
     gl.Clear(GLClearBufferMask.ColorBufferBit | GLClearBufferMask.DepthBufferBit);
 }
Ejemplo n.º 25
0
 public MyGameWindow(string fileName = null)
     : base(1280, 720, new GraphicsMode(new ColorFormat(32), 24, 8, 4), "Object.GL Tester",
     GameWindowFlags.Default, DisplayDevice.Default, 4, 2, GraphicsContextFlags.Default)
 {
     this.fileName = fileName;
     gl = new GL4();
     nativeGraphicsContext = new GL4NativeGraphicsContextWrapper(Context);
     VSync = VSyncMode.On;
     Context.SwapInterval = 1;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 调度
        /// </summary>
        static public void Dispatcher(string jsonText)
        {
            string om = DNTRequest.GetString("om");

            if (string.IsNullOrEmpty(om))
            {
                om = JsonRequest.GetJsonKeyVal(jsonText, "om");
            }
            if (!string.IsNullOrEmpty(om))
            {
                #region 实现

                switch (om)
                {
                case "test":
                    ITest.Implementation(jsonText);
                    break;

                case "gl":
                    IGL.Implementation(jsonText);
                    break;

                case "func":
                    IFunction.Implementation(jsonText);
                    break;

                case "netloan":
                    INetLoan.Implementation(jsonText);
                    break;

                case "newnetloan":
                    INewNetLoan.Implementation(jsonText);
                    break;

                case "menu":
                    ILeftMenu.Implementation(jsonText);
                    break;

                case "heartbeat":
                    IHeartbeat.Implementation(jsonText);
                    break;

                case "settlement":
                    ISettlement.Implementation(jsonText);
                    break;

                case "product":
                    IProduct.Implementation(jsonText);
                    break;
                }

                #endregion
            }
        }
Ejemplo n.º 27
0
        public Context(IGL gl, IContextInfra infra)
        {
            GL = gl;
            Infra = infra;
            Caps = new ContextCaps(gl);

            Create = new ContextObjectFactory(this);
            Bindings = new ContextBindings(this, Caps);
            States = new ContextStates(this, Caps);
            Actions = new ContextActions(this);
        }
Ejemplo n.º 28
0
		public StringRenderer(IGL owner, Stream xml, params Stream[] textures)
		{
			Owner = owner;
			FontInfo = Cyotek.Drawing.BitmapFont.BitmapFontLoader.LoadFontFromXmlFile(xml);
			
			//load textures
			for(int i=0;i<FontInfo.Pages.Length;i++)
			{
				TexturePages.Add(owner.LoadTexture(textures[i]));
			}
		}
Ejemplo n.º 29
0
        public Context(IGL gl, IContextInfra infra)
        {
            GL    = gl;
            Infra = infra;
            Caps  = new ContextCaps(gl);

            Create   = new ContextObjectFactory(this);
            Bindings = new ContextBindings(this, Caps);
            States   = new ContextStates(this, Caps);
            Actions  = new ContextActions(this);
        }
Ejemplo n.º 30
0
        public StringRenderer(IGL owner, Stream xml, params Stream[] textures)
        {
            Owner    = owner;
            FontInfo = Cyotek.Drawing.BitmapFont.BitmapFontLoader.LoadFontFromXmlFile(xml);

            //load textures
            for (int i = 0; i < FontInfo.Pages.Length; i++)
            {
                TexturePages.Add(owner.LoadTexture(textures[i]));
            }
        }
        public StringRenderer(IGL owner, Stream xml, params Stream[] textures)
        {
            Owner    = owner;
            FontInfo = new();
            FontInfo.LoadXml(xml);

            // load textures
            for (int i = 0; i < FontInfo.Pages.Length; i++)
            {
                TexturePages.Add(owner.LoadTexture(textures[i]));
            }
        }
Ejemplo n.º 32
0
        public void Draw()
        {
            if (m_renderObjects == null)
            {
                return;
            }

            for (int i = 0; i < m_renderObjects.Count; ++i)
            {
                IGL line = m_renderObjects[i];
                line.Draw();
            }
        }
Ejemplo n.º 33
0
        public static IGuiRenderer CreateRenderer(this IGL gl)
        {
            if (gl is IGL_Vulkan || gl is IGL_TK || gl is IGL_SlimDX9)
            {
                return(new GuiRenderer(gl));
            }

            if (gl is IGL_GdiPlus)
            {
                return(new GDIPlusGuiRenderer((IGL_GdiPlus)gl));
            }

            throw new NotSupportedException();
        }
Ejemplo n.º 34
0
        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);
            GraphicsControl.MouseMove += (o, e) => GlobalWin.MainForm.MainForm_MouseMove(o, e);
        }
Ejemplo n.º 35
0
        public PresentationPanel(Form parent, IGL gl)
        {
            GL = 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)

            // TODO
            //GraphicsControl.MouseClick += (o, e) => GlobalWin.MainForm.MainForm_MouseClick(o, e);
        }
Ejemplo n.º 36
0
        public Pipeline(IGL owner, IntPtr id, bool available, VertexLayout vertexLayout, IEnumerable <UniformInfo> uniforms)
        {
            Owner        = owner;
            Id           = id;
            VertexLayout = vertexLayout;
            Available    = available;

            //create the uniforms from the info list we got
            UniformsDictionary = new SpecialWorkingDictionary(this);
            foreach (var ui in uniforms)
            {
                UniformsDictionary[ui.Name] = new PipelineUniform(this, ui);
            }
        }
Ejemplo n.º 37
0
        // NOTE: we may need to overhaul uniform-setting infrastructure later.
        // maybe samplers will need to be set by index and not by name (I think the specs don't dictate what the sampler must be named)
        public RetroShader(IGL owner, string source, bool debug = false)
        {
            Owner = owner;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 40, 0);
            VertexLayout.DefineVertexAttribute("color", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Color0, false, 40, 16);             //just dead weight, i have no idea why this is here. but some old HLSL compilers (used in bizhawk for various reasons) will want it to exist here since it exists in the vertex shader
            VertexLayout.DefineVertexAttribute("tex", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 40, 32);
            VertexLayout.Close();

            string defines  = "";
            string vsSource = $"#define VERTEX\r\n{defines}{source}";
            string psSource = $"#define FRAGMENT\r\n{defines}{source}";
            var    vs       = owner.CreateVertexShader(vsSource, "main_vertex", debug);
            var    ps       = owner.CreateFragmentShader(psSource, "main_fragment", debug);

            Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");

            if (!Pipeline.Available)
            {
                Available = false;
                return;
            }

            // retroarch shaders will sometimes not have the right sampler name
            // it's unclear whether we should bind to s_p or sampler0
            // lets bind to sampler0 in case we don't have s_p
            sampler0 = Pipeline.TryGetUniform("s_p");
            if (sampler0 == null)
            {
                //sampler wasn't named correctly. this can happen on some retroarch shaders
                foreach (var u in Pipeline.GetUniforms())
                {
                    if (u.Sole.IsSampler && u.Sole.SamplerIndex == 0)
                    {
                        sampler0 = u;
                        break;
                    }
                }
            }

            //if a sampler isn't available, we can't do much, although this does interfere with debugging (shaders just returning colors will malfunction)
            if (sampler0 == null)
            {
                return;
            }

            Available = true;
        }
Ejemplo n.º 38
0
        public void Draw()
        {
            if (m_renderObjects == null)
            {
                return;
            }

            GL.PushMatrix();
            for (int i = 0; i < m_renderObjects.Count; ++i)
            {
                IGL line = m_renderObjects[i];
                line.Draw();
            }
            GL.PopMatrix();
        }
Ejemplo n.º 39
0
        public RetroShader(IGL owner, string source, bool debug = false)
        {
            Owner = owner as IGL_TK;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("VertexCoord", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 0); //VertexCoord
            VertexLayout.DefineVertexAttribute("ColorShit", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 16); //COLOR
            VertexLayout.DefineVertexAttribute("TexCoord", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 32); //TexCoord (is this vec2 or vec4? the glsl converted from cg had vec4 but the cg had vec2...)
            VertexLayout.Close();

            string vsSource = "#define VERTEX\r\n" + source;
            string psSource = "#define FRAGMENT\r\n" + source;
            var vs = Owner.CreateVertexShader(vsSource, debug);
            var ps = Owner.CreateFragmentShader(psSource, debug);
            Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug);
        }
Ejemplo n.º 40
0
		//NOTE: we may need to overhaul uniform-setting infrastructure later. 
		//maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named)

		public RetroShader(IGL owner, string source, bool debug = false)
		{
			Owner = owner;

			VertexLayout = owner.CreateVertexLayout();
			VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 24, 0);
			VertexLayout.DefineVertexAttribute("texCoord1", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 24, 16);
			VertexLayout.Close();

			string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
			string vsSource = "#define VERTEX\r\n" + defines + source;
			string psSource = "#define FRAGMENT\r\n" + defines + source;
			var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
			var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
			Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");
		}
Ejemplo n.º 41
0
        public RetroShader(IGL owner, string source, bool debug = false)
        {
            Owner = owner as IGL_TK;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("VertexCoord", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 0);           //VertexCoord
            VertexLayout.DefineVertexAttribute("ColorShit", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 16);            //COLOR
            VertexLayout.DefineVertexAttribute("TexCoord", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Unspecified, false, 40, 32);             //TexCoord (is this vec2 or vec4? the glsl converted from cg had vec4 but the cg had vec2...)
            VertexLayout.Close();

            string vsSource = "#define VERTEX\r\n" + source;
            string psSource = "#define FRAGMENT\r\n" + source;
            var    vs       = Owner.CreateVertexShader(vsSource, debug);
            var    ps       = Owner.CreateFragmentShader(psSource, debug);

            Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug);
        }
Ejemplo n.º 42
0
		public GuiRenderer(IGL owner)
		{
			Owner = owner;

			VertexLayout = owner.CreateVertexLayout();
			VertexLayout.DefineVertexAttribute("aPosition", 0, 2, VertexAttribPointerType.Float, false, 32, 0);
			VertexLayout.DefineVertexAttribute("aTexcoord", 1, 2, VertexAttribPointerType.Float, false, 32, 8);
			VertexLayout.DefineVertexAttribute("aColor", 2, 4, VertexAttribPointerType.Float, false, 32, 16);
			VertexLayout.Close();

			_Projection = new MatrixStack();
			_Modelview = new MatrixStack();

			var vs = Owner.CreateVertexShader(DefaultVertexShader,true);
			var ps = Owner.CreateFragmentShader(DefaultPixelShader, true);
			CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true);
		}
Ejemplo n.º 43
0
        //NOTE: we may need to overhaul uniform-setting infrastructure later.
        //maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named)

        public RetroShader(IGL owner, string source, bool debug = false)
        {
            Owner = owner;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 24, 0);
            VertexLayout.DefineVertexAttribute("texCoord1", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 24, 16);
            VertexLayout.Close();

            string defines  = "#define TEXCOORD TEXCOORD0\r\n";            //maybe not safe..
            string vsSource = "#define VERTEX\r\n" + defines + source;
            string psSource = "#define FRAGMENT\r\n" + defines + source;
            var    vs       = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
            var    ps       = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);

            Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");
        }
Ejemplo n.º 44
0
		//NOTE: we may need to overhaul uniform-setting infrastructure later. 
		//maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named)

		public RetroShader(IGL owner, string source, bool debug = false)
		{
			Owner = owner;

			VertexLayout = owner.CreateVertexLayout();
			VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 40, 0);
			VertexLayout.DefineVertexAttribute("color", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Color0, false, 40, 16); //just dead weight, i have no idea why this is here. but some old HLSL compilers (used in bizhawk for various reasons) will want it to exist here since it exists in the vertex shader
			VertexLayout.DefineVertexAttribute("texCoord1", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 40, 32);
			VertexLayout.Close();

			string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
			string vsSource = "#define VERTEX\r\n" + defines + source;
			string psSource = "#define FRAGMENT\r\n" + defines + source;
			var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
			var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
			Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");

			if (!Pipeline.Available)
			{
				Available = false;
				return;
			}

			//retroarch shaders will sometimes not have the right sampler name
			//it's unclear whether we should bind to s_p or sampler0
			//lets bind to sampler0 in case we dont have s_p
			sampler0 = Pipeline.TryGetUniform("s_p");
			if (sampler0 == null)
			{
				//sampler wasn't named correctly. this can happen on some retroarch shaders
				foreach (var u in Pipeline.GetUniforms())
				{
					if (u.Sole.IsSampler && u.Sole.SamplerIndex == 0)
					{
						sampler0 = u;
						break;
					}
				}
			}

			if (sampler0 == null)
				return;

			Available = true;
		}
Ejemplo n.º 45
0
Archivo: GL.cs Proyecto: yongaru/uno
        public static void Initialize(IGL gl, bool debug)
        {
            GL._gl = debug ? (IGL) new GLDebugLayer(gl) : gl;
            string glVersion = gl.GetString(GLStringName.Version);

            if (glVersion.StartsWith("OpenGL ES"))
            {
                return;
            }

            if (((glVersion == null) || (glVersion.IndexOf('.') == -1)) || (int.Parse(glVersion.Substring(0, glVersion.IndexOf('.'))) < 2))
            {
                global::Uno.Diagnostics.Debug.Log("GL_VERSION: " + glVersion, global::Uno.Diagnostics.DebugMessageType.Debug);
                global::Uno.Diagnostics.Debug.Log("GL_VENDOR: " + gl.GetString(GLStringName.Vendor), global::Uno.Diagnostics.DebugMessageType.Debug);
                global::Uno.Diagnostics.Debug.Log("GL_RENDERER: " + gl.GetString(GLStringName.Renderer), global::Uno.Diagnostics.DebugMessageType.Debug);
                throw new global::System.NotSupportedException("OpenGL 2.0 is required to run this application");
            }
        }
Ejemplo n.º 46
0
        public DisplayManager(
            Config config,
            IEmulator emulator,
            InputManager inputManager,
            IMovieSession movieSession,
            IGL gl,
            PresentationPanel presentationPanel,
            Func <bool> getIsSecondaryThrottlingDisabled)
            : base(config, emulator, inputManager, movieSession, gl.DispMethodEnum(), gl, gl.CreateRenderer())
        {
            _presentationPanel = presentationPanel;
            _getIsSecondaryThrottlingDisabled = getIsSecondaryThrottlingDisabled;

            // setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
            // but is it tho? --yoshi
            // turns out it was, calling Instance getter here initialises it, and the encapsulated Activate call is necessary too --yoshi
            _crGraphicsControl = GLManager.Instance.GetContextForGraphicsControl(_graphicsControl);
        }
Ejemplo n.º 47
0
        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);
        }
Ejemplo n.º 48
0
        public GuiRenderer(IGL owner)
        {
            Owner = owner;

            VertexLayout = owner.CreateVertexLayout();
            VertexLayout.DefineVertexAttribute("aPosition", 0, 2, VertexAttribPointerType.Float, false, 32, 0);
            VertexLayout.DefineVertexAttribute("aTexcoord", 1, 2, VertexAttribPointerType.Float, false, 32, 8);
            VertexLayout.DefineVertexAttribute("aColor", 2, 4, VertexAttribPointerType.Float, false, 32, 16);
            VertexLayout.Close();

            _Projection = new MatrixStack();
            _Modelview  = new MatrixStack();

            var vs = Owner.CreateVertexShader(DefaultVertexShader, true);
            var ps = Owner.CreateFragmentShader(DefaultPixelShader, true);

            CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true);
        }
Ejemplo n.º 49
0
        private void DrawTile(IGL gl, Vector3d textureFragmentPosition, Vector3d position)
        {
            gl.MatrixMode(MatrixMode.Texture);
            gl.PushMatrix();

            gl.Translate(textureFragmentPosition);

            gl.MatrixMode(MatrixMode.Modelview);
            gl.PushMatrix();
            gl.Translate(position);

            DrawQuad(gl);

            gl.PopMatrix();

            gl.MatrixMode(MatrixMode.Texture);
            gl.PopMatrix();

            gl.MatrixMode(MatrixMode.Modelview);
        }
Ejemplo n.º 50
0
        private void DrawTile(IGL gl, Vector3d textureFragmentPosition, Vector3d position)
        {
            gl.MatrixMode(MatrixMode.Texture);
            gl.PushMatrix();

            gl.Translate(textureFragmentPosition);

            gl.MatrixMode(MatrixMode.Modelview);
            gl.PushMatrix();
            gl.Translate(position);

            DrawQuad(gl);

            gl.PopMatrix();

            gl.MatrixMode(MatrixMode.Texture);
            gl.PopMatrix();

            gl.MatrixMode(MatrixMode.Modelview);
        }
Ejemplo n.º 51
0
        public void Draw(int cullingMask)
        {
            if (m_renderObjects == null)
            {
                return;
            }

            GL.PushMatrix();
            try
            {
                for (int i = 0; i < m_renderObjects.Count; ++i)
                {
                    IGL line = m_renderObjects[i];
                    line.Draw(cullingMask);
                }
            }
            finally
            {
                GL.PopMatrix();
            }
        }
Ejemplo n.º 52
0
        public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
        {
            Owner       = owner;
            this.Preset = preset;
            Passes      = preset.Passes.ToArray();
            Errors      = "";

            //load up the shaders
            Shaders = new RetroShader[preset.Passes.Count];
            for (var i = 0; i < preset.Passes.Count; i++)
            {
                //acquire content
                var    path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
                string content;
                try
                {
                    content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
                }
                catch (DirectoryNotFoundException e)
                {
                    Errors += $"caught {nameof(DirectoryNotFoundException)}: {e.Message}\n";
                    return;
                }
                catch (FileNotFoundException e)
                {
                    Errors += $"could not read file {e.FileName}\n";
                    return;
                }

                var shader = Shaders[i] = new RetroShader(Owner, content, debug);
                if (!shader.Available)
                {
                    Errors += $"===================\r\nPass {i}:\r\n{shader.Errors}\n";
                    return;
                }
            }

            Available = true;
        }
Ejemplo n.º 53
0
		//NOTE: we may need to overhaul uniform-setting infrastructure later. 
		//maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named)

		public RetroShader(IGL owner, string source, bool debug = false)
		{
			Owner = owner;

			VertexLayout = owner.CreateVertexLayout();
			VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 24, 0);
			VertexLayout.DefineVertexAttribute("texCoord1", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 24, 16);
			VertexLayout.Close();

			string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
			string vsSource = "#define VERTEX\r\n" + defines + source;
			string psSource = "#define FRAGMENT\r\n" + defines + source;
			var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
			var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
			Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");

			//retroarch shaders will sometimes not have the right sampler name
			//it's unclear whether we should bind to s_p or sampler0
			//lets bind to sampler0 in case we dont have s_p
			sampler0 = Pipeline.TryGetUniform("s_p");
			if (sampler0 == null)
			{
				//sampler wasn't named correctly. this can happen on some retroarch shaders
				foreach (var u in Pipeline.GetUniforms())
				{
					if (u.Sole.IsSampler && u.Sole.Index == 0)
					{
						sampler0 = u;
						break;
					}
				}
			}

			if (sampler0 == null)
				return;

			Available = true;
		}
Ejemplo n.º 54
0
		public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirectory, bool debug = false)
		{
			Owner = owner;
			this.Preset = preset;
			Passes = preset.Passes.ToArray();

			bool ok = true;
			Errors = "";

			//load up the shaders
			Shaders = new RetroShader[preset.Passes.Count];
			for (int i = 0; i < preset.Passes.Count; i++)
			{
				RetroShaderPreset.ShaderPass pass = preset.Passes[i];

				//acquire content
				string path = Path.Combine(baseDirectory, pass.ShaderPath);
				if (!File.Exists(path))
				{
					ok = false;
					break;
				}
				string content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));


				var shader = new RetroShader(Owner, content, debug);
				Shaders[i] = shader;
				if (!shader.Available)
				{
					Errors += string.Format("===================\r\nPass {0}:\r\n{1}",i,shader.Errors);
					ok = false;
				}
			}

			Available = ok;
		}
Ejemplo n.º 55
0
 private TesselationEvaluationShader(IGL gl, uint handle)
     : base(gl, handle, ShaderType.TessEvaluationShader)
 {
 }
Ejemplo n.º 56
0
 public static bool TryCompile(IGL gl, string source, out TesselationControlShader shader, out string errors)
 {
     return TryCompile(gl, source, ShaderType.TessControlShader, (g, h) => new TesselationControlShader(g, h), out shader, out errors);
 }
Ejemplo n.º 57
0
 private TesselationControlShader(IGL gl, uint handle)
     : base(gl, handle, ShaderType.TessControlShader)
 {
 }
Ejemplo n.º 58
0
 public static bool TryCompile(IGL gl, string source, out TesselationEvaluationShader shader, out string errors)
 {
     return TryCompile(gl, source, ShaderType.TessEvaluationShader, (h, g) => new TesselationEvaluationShader(h, g), out shader, out errors);
 }
Ejemplo n.º 59
0
 public RetainedGraphicsControl(IGL gl)
     : base(gl)
 {
     GL = gl;
     GuiRenderer = new GuiRenderer(gl);
 }
Ejemplo n.º 60
0
		public RenderTargetFrugalizer(IGL gl)
		{
			GL = gl;
			ResetList();
		}