From d2232e616b275d07583f5486b3bb0aed5a49f57e Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 2 May 2014 04:27:08 +0000 Subject: [PATCH] minimal implementation of AR correction. this isn't completely satisfying. we need to run the frontend 1x/2x/etc sizing through it, and I'm feeling like we need two tiers of AR suggestion strengths.. we may want a2600 fixing AR out of the box, but NES fixing AR by default is unacceptable --- BizHawk.Client.Common/config/Config.cs | 1 + .../DisplayManager/DisplayManager.cs | 11 ++++++++- .../DisplayManager/Filters/Gui.cs | 6 ++--- .../config/DisplayConfigLite.Designer.cs | 23 +++++++++++++++---- .../config/DisplayConfigLite.cs | 2 ++ .../BizHawk.Bizware.BizwareGL/GuiRenderer.cs | 5 ++++ 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index f0ae2093ef..a253e7e960 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -167,6 +167,7 @@ namespace BizHawk.Client.Common public bool DispBlurry = false; // make display look ugly public bool DispFixAspectRatio = true; public bool DispFixScaleInteger = false; + public bool DispObeyAR = false; // Sound options public bool SoundEnabled = true; diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index 0b0e2d57b6..d320345a59 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -259,6 +259,14 @@ namespace BizHawk.Client.EmuHawk /// public void UpdateSource(IVideoProvider videoProvider) { + int vw = videoProvider.BufferWidth; + int vh = videoProvider.BufferHeight; + if (Global.Config.DispObeyAR) + { + vw = videoProvider.VirtualWidth; + vh = videoProvider.VirtualHeight; + } + int[] videoBuffer = videoProvider.GetVideoBuffer(); TESTEROO: @@ -280,6 +288,7 @@ TESTEROO: //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): @@ -294,7 +303,7 @@ TESTEROO: currEmuHeight = bufferHeight; //build the default filter chain and set it up with services filters will need - Size chain_insize = new Size(bufferWidth, bufferHeight); + Size chain_insize = new Size(vw, vh); Size chain_outsize = GraphicsControl.Size; CurrentFilterProgram = BuildDefaultChain(chain_insize, chain_outsize); CurrentFilterProgram.GuiRenderer = Renderer; diff --git a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs index 4afd3a66aa..026bb02a35 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs @@ -152,8 +152,8 @@ namespace BizHawk.Client.EmuHawk.Filters GuiRenderer.Begin(OutputSize.Width, OutputSize.Height); GuiRenderer.SetBlendState(GL.BlendNone); GuiRenderer.Modelview.Push(); - GuiRenderer.Modelview.Translate(LL.vx, LL.vy); - GuiRenderer.Modelview.Scale(LL.WidthScale, LL.HeightScale); + //GuiRenderer.Modelview.Translate(LL.vx, LL.vy); + //GuiRenderer.Modelview.Scale(LL.WidthScale, LL.HeightScale); if(FilterOption != eFilterOption.None) InputTexture.SetFilterLinear(); else @@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk.Filters } - GuiRenderer.Draw(InputTexture); + GuiRenderer.Draw(InputTexture,LL.vx,LL.vy,LL.vw,LL.vh); GuiRenderer.End(); } diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs index 6d9a2d3cc9..6bc0ed4b00 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs @@ -45,6 +45,7 @@ this.rbFinalFilterBicubic = new System.Windows.Forms.RadioButton(); this.rbFinalFilterNone = new System.Windows.Forms.RadioButton(); this.rbFinalFilterBilinear = new System.Windows.Forms.RadioButton(); + this.checkObeyAR = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit(); this.groupBox2.SuspendLayout(); @@ -54,7 +55,7 @@ // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(289, 190); + this.btnCancel.Location = new System.Drawing.Point(289, 221); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 5; @@ -64,7 +65,7 @@ // btnOk // this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOk.Location = new System.Drawing.Point(208, 190); + this.btnOk.Location = new System.Drawing.Point(208, 221); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(75, 23); this.btnOk.TabIndex = 4; @@ -132,7 +133,7 @@ this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55); this.tbScanlineIntensity.Maximum = 255; this.tbScanlineIntensity.Name = "tbScanlineIntensity"; - this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 45); + this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42); this.tbScanlineIntensity.TabIndex = 3; this.tbScanlineIntensity.TickFrequency = 32; this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft; @@ -183,7 +184,7 @@ // checkPadInteger // this.checkPadInteger.AutoSize = true; - this.checkPadInteger.Location = new System.Drawing.Point(12, 195); + this.checkPadInteger.Location = new System.Drawing.Point(12, 218); this.checkPadInteger.Name = "checkPadInteger"; this.checkPadInteger.Size = new System.Drawing.Size(120, 17); this.checkPadInteger.TabIndex = 9; @@ -235,13 +236,24 @@ this.rbFinalFilterBilinear.Text = "Bilinear"; this.rbFinalFilterBilinear.UseVisualStyleBackColor = true; // + // checkObeyAR + // + this.checkObeyAR.AutoSize = true; + this.checkObeyAR.Location = new System.Drawing.Point(12, 195); + this.checkObeyAR.Name = "checkObeyAR"; + this.checkObeyAR.Size = new System.Drawing.Size(211, 17); + this.checkObeyAR.TabIndex = 10; + this.checkObeyAR.Text = "Obey system\'s Aspect Ratio suggestion"; + this.checkObeyAR.UseVisualStyleBackColor = true; + // // DisplayConfigLite // this.AcceptButton = this.btnOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(376, 225); + this.ClientSize = new System.Drawing.Size(376, 256); + this.Controls.Add(this.checkObeyAR); this.Controls.Add(this.groupBox2); this.Controls.Add(this.checkPadInteger); this.Controls.Add(this.checkLetterbox); @@ -282,5 +294,6 @@ private System.Windows.Forms.Button btnSelectUserFilter; private System.Windows.Forms.RadioButton rbUser; private System.Windows.Forms.Label lblUserFilterName; + private System.Windows.Forms.CheckBox checkObeyAR; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs index e47b35d7a8..fe64c4e745 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs @@ -35,6 +35,7 @@ namespace BizHawk.Client.EmuHawk.config tbScanlineIntensity.Value = Global.Config.TargetScanlineFilterIntensity; checkLetterbox.Checked = Global.Config.DispFixAspectRatio; checkPadInteger.Checked = Global.Config.DispFixScaleInteger; + checkObeyAR.Checked = Global.Config.DispObeyAR; } private void btnOk_Click(object sender, EventArgs e) @@ -58,6 +59,7 @@ namespace BizHawk.Client.EmuHawk.config Global.Config.TargetScanlineFilterIntensity = tbScanlineIntensity.Value; Global.Config.DispFixAspectRatio = checkLetterbox.Checked; Global.Config.DispFixScaleInteger = checkPadInteger.Checked; + Global.Config.DispObeyAR = checkObeyAR.Checked; Global.Config.DispUserFilterPath = PathSelection; GlobalWin.DisplayManager.RefreshUserShader(); diff --git a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs index 93149db30c..ae34a12ff3 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs @@ -249,6 +249,11 @@ namespace BizHawk.Bizware.BizwareGL /// public void DrawFlipped(Art art, bool xflip, bool yflip) { DrawInternal(art, 0, 0, art.Width, art.Height, xflip, yflip); } + public void Draw(Texture2d art, float x, float y, float width, float height) + { + DrawInternal(art, x, y, width, height); + } + unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h) { Art art = new Art(null);