コード例 #1
0
ファイル: Texture2d.cs プロジェクト: ddugovic/RASuite
		public Texture2d(IGL owner, IntPtr id, int width, int height)
		{
			Owner = owner;
			Id = id;
			Width = width;
			Height = height;
		}
コード例 #2
0
ファイル: RenderTarget.cs プロジェクト: CadeLaRen/BizHawk
		public RenderTarget(IGL owner, object opaque, Texture2d tex)
		{
			Owner = owner;
			Opaque = opaque;
			Texture2d = tex;
			tex.IsUpsideDown = true;
		}
コード例 #3
0
ファイル: Texture2d.cs プロジェクト: CadeLaRen/BizHawk
		public Texture2d(IGL owner, object opaque, int width, int height)
		{
			Owner = owner;
			Opaque = opaque;
			Width = width;
			Height = height;
		}
コード例 #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();
        }
コード例 #5
0
ファイル: Shader.cs プロジェクト: CadeLaRen/BizHawk
		public Shader(IGL owner, object opaque, bool available)
		{
			Owner = owner;
			Opaque = opaque;
			Available = available;
			Errors = "";
		}
コード例 #6
0
ファイル: RenderTarget.cs プロジェクト: cas1993per/bizhawk
 public RenderTarget(IGL owner, IntPtr handle, Texture2d tex)
 {
     Owner = owner;
     Id = handle;
     Texture2d = tex;
     tex.IsUpsideDown = true;
 }
コード例 #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");
        }
コード例 #8
0
ファイル: GuiRenderer.cs プロジェクト: CadeLaRen/BizHawk
		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");
		}
コード例 #9
0
ファイル: Retro.cs プロジェクト: adituv/BizHawk
		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;
		}
コード例 #10
0
ファイル: DisplayManager.cs プロジェクト: Kabuto/BizHawk
		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();
		}
コード例 #11
0
ファイル: GLManager.cs プロジェクト: cas1993per/bizhawk
 /// <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
     };
 }
コード例 #12
0
ファイル: GraphicsControl.cs プロジェクト: raiscan/BizHawk
        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);
        }
コード例 #13
0
 public Texture2d(IGL owner, object opaque, int width, int height)
 {
     Owner  = owner;
     Opaque = opaque;
     Width  = width;
     Height = height;
 }
コード例 #14
0
ファイル: Retro.cs プロジェクト: xHailFirex/BizHawk
        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;
        }
コード例 #15
0
 public Video(IGL gl)
 {
     _gl                       = gl;
     _mediaPlayer              = new MediaPlayer();
     _mediaPlayer.MediaOpened += OnMediaOpened;
     _mediaPlayer.MediaFailed += OnMediaFailed;
     _drawingVisual            = new DrawingVisual();
 }
コード例 #16
0
ファイル: IGL.cs プロジェクト: gucheng0712/Unity-CS-Reference
 internal static IGL GetSystem()
 {
     if (m_GLSystem == null)
     {
         m_GLSystem = new GLSystem();
     }
     return(m_GLSystem);
 }
コード例 #17
0
        public static void SetOpenGL(IGL gl)
        {
#if CONFIG_MAC
            Mono.MonoImpl.SetOpenGL(gl);
#else
            WPF.VideoImpl.SetOpenGL(gl);
#endif
        }
コード例 #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;
 }
コード例 #19
0
ファイル: Quad.cs プロジェクト: Ziretech/Ubiq
 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();
 }
コード例 #20
0
 public PixelBuffer(IGL gl, IntPtr handle)
 {
     _gl     = gl;
     _handle = handle;
     if (_handle == IntPtr.Zero)
     {
         throw new ArgumentNullException();
     }
 }
コード例 #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();
 }
コード例 #22
0
ファイル: GLRenderer.cs プロジェクト: KanaHayama/3D-FFD
        public void Add(IGL gl)
        {
            if (m_renderObjects.Contains(gl))
            {
                return;
            }

            m_renderObjects.Add(gl);
        }
コード例 #23
0
ファイル: GLView1.cs プロジェクト: Zulkir/RAVC
        public GLView1(Context context, IClientSettings settings)
            : base(context)
        {
            this.settings = settings;

            gl = new AndroidGL();
            nativeGraphicsContext = new GameViewContext(this);
            assetManager = context.Assets;
            KeepScreenOn = true;
        }
コード例 #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);
 }
コード例 #25
0
ファイル: MyGameWindow.cs プロジェクト: Zulkir/RAVC
 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;
 }
コード例 #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
            }
        }
コード例 #27
0
ファイル: Context.cs プロジェクト: Zulkir/ObjectGL
        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);
        }
コード例 #28
0
ファイル: StringRenderer.cs プロジェクト: ddugovic/RASuite
		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]));
			}
		}
コード例 #29
0
ファイル: Context.cs プロジェクト: Zulkir/ClarityWorlds
        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);
        }
コード例 #30
0
ファイル: StringRenderer.cs プロジェクト: Gorialis/BizHawk
        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]));
            }
        }
コード例 #31
0
        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]));
            }
        }
コード例 #32
0
ファイル: GLRenderer.cs プロジェクト: TwelveAxes/Speed
        public void Draw()
        {
            if (m_renderObjects == null)
            {
                return;
            }

            for (int i = 0; i < m_renderObjects.Count; ++i)
            {
                IGL line = m_renderObjects[i];
                line.Draw();
            }
        }
コード例 #33
0
ファイル: Extensions.cs プロジェクト: Asnivor/BizHawk
        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();
        }
コード例 #34
0
ファイル: PresentationPanel.cs プロジェクト: raiscan/BizHawk
        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);
        }
コード例 #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);
        }
コード例 #36
0
ファイル: Pipeline.cs プロジェクト: metalloidSmashes/BizHawk
        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);
            }
        }
コード例 #37
0
ファイル: RetroShader.cs プロジェクト: xHailFirex/BizHawk
        // 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;
        }
コード例 #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();
        }
コード例 #39
0
ファイル: RetroShader.cs プロジェクト: cas1993per/bizhawk
        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);
        }
コード例 #40
0
ファイル: RetroShader.cs プロジェクト: Kabuto/BizHawk
		//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");
		}
コード例 #41
0
ファイル: RetroShader.cs プロジェクト: WolfpawGroup/RTC3
        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);
        }
コード例 #42
0
ファイル: GuiRenderer.cs プロジェクト: ddugovic/RASuite
		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);
		}
コード例 #43
0
ファイル: RetroShader.cs プロジェクト: TechnoTaff/BizHawk
        //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");
        }
コード例 #44
0
ファイル: RetroShader.cs プロジェクト: CadeLaRen/BizHawk
		//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;
		}
コード例 #45
0
ファイル: GL.cs プロジェクト: 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");
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #48
0
ファイル: GuiRenderer.cs プロジェクト: stuff2600/RAEmus
        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);
        }
コード例 #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);
        }
コード例 #50
0
ファイル: Quad.cs プロジェクト: Ziretech/Ubiq
        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);
        }
コード例 #51
0
ファイル: GLRenderer.cs プロジェクト: KanaHayama/3D-FFD
        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();
            }
        }
コード例 #52
0
ファイル: Retro.cs プロジェクト: xy2iii/BizHawk
        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;
        }
コード例 #53
0
ファイル: RetroShader.cs プロジェクト: adituv/BizHawk
		//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;
		}
コード例 #54
0
ファイル: Retro.cs プロジェクト: SaxxonPike/BizHawk
		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;
		}
コード例 #55
0
 private TesselationEvaluationShader(IGL gl, uint handle)
     : base(gl, handle, ShaderType.TessEvaluationShader)
 {
 }
コード例 #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);
 }
コード例 #57
0
 private TesselationControlShader(IGL gl, uint handle)
     : base(gl, handle, ShaderType.TessControlShader)
 {
 }
コード例 #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);
 }
コード例 #59
0
 public RetainedGraphicsControl(IGL gl)
     : base(gl)
 {
     GL = gl;
     GuiRenderer = new GuiRenderer(gl);
 }
コード例 #60
0
		public RenderTargetFrugalizer(IGL gl)
		{
			GL = gl;
			ResetList();
		}