diff --git a/src/BizHawk.Bizware.BizwareGL/GDIPTextureWrapper.cs b/src/BizHawk.Bizware.BizwareGL/GDIPTextureWrapper.cs index 5aa7c8dc64..4c22333f13 100644 --- a/src/BizHawk.Bizware.BizwareGL/GDIPTextureWrapper.cs +++ b/src/BizHawk.Bizware.BizwareGL/GDIPTextureWrapper.cs @@ -1,7 +1,5 @@ using System; -using OpenTK.Graphics.OpenGL; - namespace BizHawk.Bizware.BizwareGL { public class GDIPTextureWrapper : IDisposable diff --git a/src/BizHawk.Bizware.BizwareGL/GDIPlusGuiRenderer.cs b/src/BizHawk.Bizware.BizwareGL/GDIPlusGuiRenderer.cs index b80ed33ae2..2241985478 100644 --- a/src/BizHawk.Bizware.BizwareGL/GDIPlusGuiRenderer.cs +++ b/src/BizHawk.Bizware.BizwareGL/GDIPlusGuiRenderer.cs @@ -4,7 +4,6 @@ using System; using System.Drawing.Imaging; using OpenTK; -using OpenTK.Graphics.OpenGL; using sd = System.Drawing; diff --git a/src/BizHawk.Bizware.BizwareGL/GuiRenderer.cs b/src/BizHawk.Bizware.BizwareGL/GuiRenderer.cs index 156bc49368..77027e8b4f 100644 --- a/src/BizHawk.Bizware.BizwareGL/GuiRenderer.cs +++ b/src/BizHawk.Bizware.BizwareGL/GuiRenderer.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics; using OpenTK; -using OpenTK.Graphics.OpenGL; using sd = System.Drawing; diff --git a/src/BizHawk.Bizware.BizwareGL/IGL.cs b/src/BizHawk.Bizware.BizwareGL/IGL.cs index 1fe49740ae..023c5ef300 100644 --- a/src/BizHawk.Bizware.BizwareGL/IGL.cs +++ b/src/BizHawk.Bizware.BizwareGL/IGL.cs @@ -3,7 +3,6 @@ using System.IO; using System.Drawing; using OpenTK; -using OpenTK.Graphics.OpenGL; namespace BizHawk.Bizware.BizwareGL { diff --git a/src/BizHawk.Bizware.BizwareGL/RenderStates.cs b/src/BizHawk.Bizware.BizwareGL/RenderStates.cs index 2df69d0888..1636b5c39a 100644 --- a/src/BizHawk.Bizware.BizwareGL/RenderStates.cs +++ b/src/BizHawk.Bizware.BizwareGL/RenderStates.cs @@ -7,29 +7,36 @@ namespace BizHawk.Bizware.BizwareGL /// public class CacheBlendState : IBlendState { - public bool Enabled; - public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource; - public global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation; - public global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest; - public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource; - public global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation; - public global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest; + public readonly bool Enabled; - public CacheBlendState(bool enabled, - global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource, - global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation, - global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest, - global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource, - global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation, - global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest) + public readonly BlendingFactorSrc colorSource; + + public readonly BlendEquationMode colorEquation; + + public readonly BlendingFactorDest colorDest; + + public readonly BlendingFactorSrc alphaSource; + + public readonly BlendEquationMode alphaEquation; + + public readonly BlendingFactorDest alphaDest; + + public CacheBlendState( + bool enabled, + BlendingFactorSrc colorSource, + BlendEquationMode colorEquation, + BlendingFactorDest colorDest, + BlendingFactorSrc alphaSource, + BlendEquationMode alphaEquation, + BlendingFactorDest alphaDest) { this.Enabled = enabled; - this.colorSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource; - this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation; - this.colorDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest; - this.alphaSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource; - this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation; - this.alphaDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest; + this.colorSource = colorSource; + this.colorEquation = colorEquation; + this.colorDest = colorDest; + this.alphaSource = alphaSource; + this.alphaEquation = alphaEquation; + this.alphaDest = alphaDest; } } } \ No newline at end of file diff --git a/src/BizHawk.Bizware.BizwareGL/RetroShader.cs b/src/BizHawk.Bizware.BizwareGL/RetroShader.cs index b6a314cd71..ae905ad129 100644 --- a/src/BizHawk.Bizware.BizwareGL/RetroShader.cs +++ b/src/BizHawk.Bizware.BizwareGL/RetroShader.cs @@ -2,7 +2,6 @@ using System; using System.Drawing; using OpenTK; -using OpenTK.Graphics.OpenGL; namespace BizHawk.Bizware.BizwareGL { diff --git a/src/BizHawk.Bizware.BizwareGL/Texture2d.cs b/src/BizHawk.Bizware.BizwareGL/Texture2d.cs index ad62d61569..c27548c649 100644 --- a/src/BizHawk.Bizware.BizwareGL/Texture2d.cs +++ b/src/BizHawk.Bizware.BizwareGL/Texture2d.cs @@ -1,6 +1,5 @@ using System; using System.Drawing; -using OpenTK.Graphics.OpenGL; namespace BizHawk.Bizware.BizwareGL { diff --git a/src/BizHawk.Bizware.BizwareGL/VertexLayout.cs b/src/BizHawk.Bizware.BizwareGL/VertexLayout.cs index 1b0ba4dbb5..52f918a988 100644 --- a/src/BizHawk.Bizware.BizwareGL/VertexLayout.cs +++ b/src/BizHawk.Bizware.BizwareGL/VertexLayout.cs @@ -1,8 +1,6 @@ using System; using BizHawk.Common; -using OpenTK.Graphics.OpenGL; - namespace BizHawk.Bizware.BizwareGL { /// diff --git a/src/BizHawk.Bizware.BizwareGL/enums/BlendEquationMode.cs b/src/BizHawk.Bizware.BizwareGL/enums/BlendEquationMode.cs new file mode 100644 index 0000000000..41e008e0f8 --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/BlendEquationMode.cs @@ -0,0 +1,11 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum BlendEquationMode + { + FuncAdd = 0x8006, + Min = 0x8007, + Max = 0x8008, + FuncSubtract = 0x800A, + FuncReverseSubtract = 0x800B, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorDest.cs b/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorDest.cs new file mode 100644 index 0000000000..b6c9f98f0a --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorDest.cs @@ -0,0 +1,25 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum BlendingFactorDest + { + Zero = 0x0000, + One = 0x0001, + SrcColor = 0x0300, + OneMinusSrcColor = 0x0301, + SrcAlpha = 0x0302, + OneMinusSrcAlpha = 0x0303, + DstAlpha = 0x0304, + OneMinusDstAlpha = 0x0305, + DstColor = 0x0306, + OneMinusDstColor = 0x0307, + SrcAlphaSaturate = 0x0308, + ConstantColor = 0x8001, + OneMinusConstantColor = 0x8002, + ConstantAlpha = 0x8003, + OneMinusConstantAlpha = 0x8004, + Src1Alpha = 0x8589, + Src1Color = 0x88F9, + OneMinusSrc1Color = 0x88FA, + OneMinusSrc1Alpha = 0x88FB, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorSrc.cs b/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorSrc.cs new file mode 100644 index 0000000000..2df5c6ecde --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/BlendingFactorSrc.cs @@ -0,0 +1,25 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum BlendingFactorSrc + { + Zero = 0x0000, + One = 0x0001, + SrcColor = 0x0300, + OneMinusSrcColor = 0x0301, + SrcAlpha = 0x0302, + OneMinusSrcAlpha = 0x0303, + DstAlpha = 0x0304, + OneMinusDstAlpha = 0x0305, + DstColor = 0x0306, + OneMinusDstColor = 0x0307, + SrcAlphaSaturate = 0x0308, + ConstantColor = 0x8001, + OneMinusConstantColor = 0x8002, + ConstantAlpha = 0x8003, + OneMinusConstantAlpha = 0x8004, + Src1Alpha = 0x8589, + Src1Color = 0x88F9, + OneMinusSrc1Color = 0x88FA, + OneMinusSrc1Alpha = 0x88FB, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/ClearBufferMask.cs b/src/BizHawk.Bizware.BizwareGL/enums/ClearBufferMask.cs new file mode 100644 index 0000000000..3ef984c999 --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/ClearBufferMask.cs @@ -0,0 +1,15 @@ +using System; + +namespace BizHawk.Bizware.BizwareGL +{ + [Flags] + public enum ClearBufferMask + { + None = 0x0000, + DepthBufferBit = 0x0100, + AccumBufferBit = 0x0200, + StencilBufferBit = 0x0400, + ColorBufferBit = 0x4000, + CoverageBufferBitNv = 0x8000, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/PrimitiveType.cs b/src/BizHawk.Bizware.BizwareGL/enums/PrimitiveType.cs new file mode 100644 index 0000000000..23643f8ee0 --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/PrimitiveType.cs @@ -0,0 +1,31 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum PrimitiveType + { + Points = 0x0000, + Lines = 0x0001, + LineLoop = 0x0002, + LineStrip = 0x0003, + Triangles = 0x0004, + TriangleStrip = 0x0005, + TriangleFan = 0x0006, + Quads = 0x0007, + QuadsExt = 0x0007, + QuadStrip = 0x0008, + Polygon = 0x0009, + LinesAdjacency = 0x000A, + LinesAdjacencyArb = 0x000A, + LinesAdjacencyExt = 0x000A, + LineStripAdjacency = 0x000B, + LineStripAdjacencyArb = 0x000B, + LineStripAdjacencyExt = 0x000B, + TrianglesAdjacency = 0x000C, + TrianglesAdjacencyArb = 0x000C, + TrianglesAdjacencyExt = 0x000C, + TriangleStripAdjacency = 0x000D, + TriangleStripAdjacencyArb = 0x000D, + TriangleStripAdjacencyExt = 0x000D, + Patches = 0x000E, + PatchesExt = 0x000E, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/TextureMagFilter.cs b/src/BizHawk.Bizware.BizwareGL/enums/TextureMagFilter.cs new file mode 100644 index 0000000000..73ddfedc61 --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/TextureMagFilter.cs @@ -0,0 +1,18 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum TextureMagFilter + { + Nearest = 0x2600, + Linear = 0x2601, + LinearDetailSgis = 0x8097, + LinearDetailAlphaSgis = 0x8098, + LinearDetailColorSgis = 0x8099, + LinearSharpenSgis = 0x80AD, + LinearSharpenAlphaSgis = 0x80AE, + LinearSharpenColorSgis = 0x80AF, + Filter4Sgis = 0x8146, + PixelTexGenQCeilingSgix = 0x8184, + PixelTexGenQRoundSgix = 0x8185, + PixelTexGenQFloorSgix = 0x8186, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/TextureMinFilter.cs b/src/BizHawk.Bizware.BizwareGL/enums/TextureMinFilter.cs new file mode 100644 index 0000000000..749a9f238e --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/TextureMinFilter.cs @@ -0,0 +1,20 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum TextureMinFilter + { + Nearest = 0x2600, + Linear = 0x2601, + NearestMipmapNearest = 0x2700, + LinearMipmapNearest = 0x2701, + NearestMipmapLinear = 0x2702, + LinearMipmapLinear = 0x2703, + Filter4Sgis = 0x8146, + LinearClipmapLinearSgix = 0x8170, + PixelTexGenQCeilingSgix = 0x8184, + PixelTexGenQRoundSgix = 0x8185, + PixelTexGenQFloorSgix = 0x8186, + NearestClipmapNearestSgix = 0x844D, + NearestClipmapLinearSgix = 0x844E, + LinearClipmapNearestSgix = 0x844F, + } +} diff --git a/src/BizHawk.Bizware.BizwareGL/enums/VertexAttribPointerType.cs b/src/BizHawk.Bizware.BizwareGL/enums/VertexAttribPointerType.cs new file mode 100644 index 0000000000..af3794fe09 --- /dev/null +++ b/src/BizHawk.Bizware.BizwareGL/enums/VertexAttribPointerType.cs @@ -0,0 +1,19 @@ +namespace BizHawk.Bizware.BizwareGL +{ + public enum VertexAttribPointerType + { + Byte = 0x1400, + UnsignedByte = 0x1401, + Short = 0x1402, + UnsignedShort = 0x1403, + Int = 0x1404, + UnsignedInt = 0x1405, + Float = 0x1406, + Double = 0x140A, + HalfFloat = 0x140B, + Fixed = 0x140C, + UnsignedInt2101010Rev = 0x8368, + UnsignedInt10F11F11FRev = 0x8C3B, + Int2101010Rev = 0x8D9F, + } +} diff --git a/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs b/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs index 774e95c201..5077b0ff3e 100644 --- a/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs +++ b/src/BizHawk.Bizware.DirectX/IGL_SlimDX9.cs @@ -7,7 +7,8 @@ using BizHawk.Bizware.BizwareGL; using SlimDX.Direct3D9; using OpenTK; -using gl = OpenTK.Graphics.OpenGL; + +using PrimitiveType = SlimDX.Direct3D9.PrimitiveType; using sd = System.Drawing; using sdi = System.Drawing.Imaging; using swf = System.Windows.Forms; @@ -130,12 +131,12 @@ namespace BizHawk.Bizware.DirectX _d3d.Dispose(); } - public void Clear(OpenTK.Graphics.OpenGL.ClearBufferMask mask) + public void Clear(ClearBufferMask mask) { ClearFlags flags = ClearFlags.None; - if ((mask & gl.ClearBufferMask.ColorBufferBit) != 0) flags |= ClearFlags.Target; - if ((mask & gl.ClearBufferMask.DepthBufferBit) != 0) flags |= ClearFlags.ZBuffer; - if ((mask & gl.ClearBufferMask.StencilBufferBit) != 0) flags |= ClearFlags.Stencil; + if ((mask & ClearBufferMask.ColorBufferBit) != 0) flags |= ClearFlags.Target; + if ((mask & ClearBufferMask.DepthBufferBit) != 0) flags |= ClearFlags.ZBuffer; + if ((mask & ClearBufferMask.StencilBufferBit) != 0) flags |= ClearFlags.Stencil; Dev.Clear(flags, _clearColor, 0.0f, 0); } @@ -145,8 +146,13 @@ namespace BizHawk.Bizware.DirectX _clearColor = color.ToArgb(); } - public IBlendState CreateBlendState(gl.BlendingFactorSrc colorSource, gl.BlendEquationMode colorEquation, gl.BlendingFactorDest colorDest, - gl.BlendingFactorSrc alphaSource, gl.BlendEquationMode alphaEquation, gl.BlendingFactorDest alphaDest) + public IBlendState CreateBlendState( + BlendingFactorSrc colorSource, + BlendEquationMode colorEquation, + BlendingFactorDest colorDest, + BlendingFactorSrc alphaSource, + BlendEquationMode alphaEquation, + BlendingFactorDest alphaDest) { return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest); } @@ -238,42 +244,42 @@ namespace BizHawk.Bizware.DirectX } } - private BlendOperation ConvertBlendOp(gl.BlendEquationMode glMode) + private BlendOperation ConvertBlendOp(BlendEquationMode glMode) { return glMode switch { - gl.BlendEquationMode.FuncAdd => BlendOperation.Add, - gl.BlendEquationMode.FuncSubtract => BlendOperation.Subtract, - gl.BlendEquationMode.Max => BlendOperation.Maximum, - gl.BlendEquationMode.Min => BlendOperation.Minimum, - gl.BlendEquationMode.FuncReverseSubtract => BlendOperation.ReverseSubtract, + BlendEquationMode.FuncAdd => BlendOperation.Add, + BlendEquationMode.FuncSubtract => BlendOperation.Subtract, + BlendEquationMode.Max => BlendOperation.Maximum, + BlendEquationMode.Min => BlendOperation.Minimum, + BlendEquationMode.FuncReverseSubtract => BlendOperation.ReverseSubtract, _ => throw new ArgumentOutOfRangeException() }; } - private Blend ConvertBlendArg(gl.BlendingFactorDest glMode) => ConvertBlendArg((gl.BlendingFactorSrc)glMode); + private Blend ConvertBlendArg(BlendingFactorDest glMode) => ConvertBlendArg((BlendingFactorSrc) glMode); - private Blend ConvertBlendArg(gl.BlendingFactorSrc glMode) => glMode switch + private Blend ConvertBlendArg(BlendingFactorSrc glMode) => glMode switch { - gl.BlendingFactorSrc.Zero => Blend.Zero, - gl.BlendingFactorSrc.One => Blend.One, - gl.BlendingFactorSrc.SrcColor => Blend.SourceColor, - gl.BlendingFactorSrc.OneMinusSrcColor => Blend.InverseSourceColor, - gl.BlendingFactorSrc.SrcAlpha => Blend.SourceAlpha, - gl.BlendingFactorSrc.OneMinusSrcAlpha => Blend.InverseSourceAlpha, - gl.BlendingFactorSrc.DstAlpha => Blend.DestinationAlpha, - gl.BlendingFactorSrc.OneMinusDstAlpha => Blend.InverseDestinationAlpha, - gl.BlendingFactorSrc.DstColor => Blend.DestinationColor, - gl.BlendingFactorSrc.OneMinusDstColor => Blend.InverseDestinationColor, - gl.BlendingFactorSrc.SrcAlphaSaturate => Blend.SourceAlphaSaturated, - gl.BlendingFactorSrc.ConstantColor => Blend.BlendFactor, - gl.BlendingFactorSrc.OneMinusConstantColor => Blend.InverseBlendFactor, - gl.BlendingFactorSrc.ConstantAlpha => throw new NotSupportedException(), - gl.BlendingFactorSrc.OneMinusConstantAlpha => throw new NotSupportedException(), - gl.BlendingFactorSrc.Src1Alpha => throw new NotSupportedException(), - gl.BlendingFactorSrc.Src1Color => throw new NotSupportedException(), - gl.BlendingFactorSrc.OneMinusSrc1Color => throw new NotSupportedException(), - gl.BlendingFactorSrc.OneMinusSrc1Alpha => throw new NotSupportedException(), + BlendingFactorSrc.Zero => Blend.Zero, + BlendingFactorSrc.One => Blend.One, + BlendingFactorSrc.SrcColor => Blend.SourceColor, + BlendingFactorSrc.OneMinusSrcColor => Blend.InverseSourceColor, + BlendingFactorSrc.SrcAlpha => Blend.SourceAlpha, + BlendingFactorSrc.OneMinusSrcAlpha => Blend.InverseSourceAlpha, + BlendingFactorSrc.DstAlpha => Blend.DestinationAlpha, + BlendingFactorSrc.OneMinusDstAlpha => Blend.InverseDestinationAlpha, + BlendingFactorSrc.DstColor => Blend.DestinationColor, + BlendingFactorSrc.OneMinusDstColor => Blend.InverseDestinationColor, + BlendingFactorSrc.SrcAlphaSaturate => Blend.SourceAlphaSaturated, + BlendingFactorSrc.ConstantColor => Blend.BlendFactor, + BlendingFactorSrc.OneMinusConstantColor => Blend.InverseBlendFactor, + BlendingFactorSrc.ConstantAlpha => throw new NotSupportedException(), + BlendingFactorSrc.OneMinusConstantAlpha => throw new NotSupportedException(), + BlendingFactorSrc.Src1Alpha => throw new NotSupportedException(), + BlendingFactorSrc.Src1Color => throw new NotSupportedException(), + BlendingFactorSrc.OneMinusSrc1Color => throw new NotSupportedException(), + BlendingFactorSrc.OneMinusSrc1Alpha => throw new NotSupportedException(), _ => throw new ArgumentOutOfRangeException() }; @@ -305,18 +311,18 @@ namespace BizHawk.Bizware.DirectX { _rsBlendNoneVerbatim = new CacheBlendState( false, - gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero, - gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); + BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, + BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); _rsBlendNoneOpaque = new CacheBlendState( false, - gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero, - gl.BlendingFactorSrc.ConstantAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); + BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, + BlendingFactorSrc.ConstantAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); _rsBlendNormal = new CacheBlendState( true, - gl.BlendingFactorSrc.SrcAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.OneMinusSrcAlpha, - gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); + BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha, + BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); } private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal; @@ -351,7 +357,7 @@ namespace BizHawk.Bizware.DirectX DeclarationType declType; switch (item.AttribType) { - case gl.VertexAttribPointerType.Float: + case VertexAttribPointerType.Float: if (item.Components == 1) declType = DeclarationType.Float1; else if (item.Components == 2) declType = DeclarationType.Float2; else if (item.Components == 3) declType = DeclarationType.Float3; @@ -649,13 +655,13 @@ namespace BizHawk.Bizware.DirectX tw.WrapClamp = clamp ? TextureAddress.Clamp : TextureAddress.Wrap; } - public void SetMinFilter(Texture2d texture, gl.TextureMinFilter minFilter) - => ((TextureWrapper) texture.Opaque).MinFilter = minFilter == gl.TextureMinFilter.Linear + public void SetMinFilter(Texture2d texture, TextureMinFilter minFilter) + => ((TextureWrapper) texture.Opaque).MinFilter = minFilter == TextureMinFilter.Linear ? TextureFilter.Linear : TextureFilter.Point; - public void SetMagFilter(Texture2d texture, gl.TextureMagFilter magFilter) - => ((TextureWrapper) texture.Opaque).MagFilter = magFilter == gl.TextureMagFilter.Linear + public void SetMagFilter(Texture2d texture, TextureMagFilter magFilter) + => ((TextureWrapper) texture.Opaque).MagFilter = magFilter == TextureMagFilter.Linear ? TextureFilter.Linear : TextureFilter.Point; @@ -924,12 +930,12 @@ namespace BizHawk.Bizware.DirectX return ret; } - /// is - public unsafe void DrawArrays(gl.PrimitiveType mode, int first, int count) + /// is not + public unsafe void DrawArrays(BizwareGL.PrimitiveType mode, int first, int count) { var pt = PrimitiveType.TriangleStrip; - if (mode != gl.PrimitiveType.TriangleStrip) + if (mode != BizwareGL.PrimitiveType.TriangleStrip) { throw new NotSupportedException(); } diff --git a/src/BizHawk.Client.Common/DisplayManager/Filters/Gui.cs b/src/BizHawk.Client.Common/DisplayManager/Filters/Gui.cs index ce9c992dbd..0231cf7260 100644 --- a/src/BizHawk.Client.Common/DisplayManager/Filters/Gui.cs +++ b/src/BizHawk.Client.Common/DisplayManager/Filters/Gui.cs @@ -375,7 +375,7 @@ namespace BizHawk.Client.Common.Filters //TODO: this could be more efficient (draw only in gap) GL.SetClearColor(Color.Black); - GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); + GL.Clear(ClearBufferMask.ColorBufferBit); FilterProgram.GuiRenderer.Begin(outputSize); GuiRenderer.SetBlendState(GL.BlendNoneCopy); @@ -558,7 +558,7 @@ namespace BizHawk.Client.Common.Filters return; GL.SetClearColor(Color.FromArgb(BackgroundColor)); - GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); + GL.Clear(ClearBufferMask.ColorBufferBit); GuiRenderer.Begin(OutputSize.Width, OutputSize.Height); GuiRenderer.SetBlendState(GL.BlendNoneCopy); diff --git a/src/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/src/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index 296fa87171..f56787b502 100644 --- a/src/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/src/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -952,7 +952,7 @@ namespace BizHawk.Client.EmuHawk _gl.BeginScene(); _gl.BindRenderTarget(null); _gl.SetClearColor(Color.Black); - _gl.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); + _gl.Clear(ClearBufferMask.ColorBufferBit); _gl.EndScene(); _presentationPanel.GraphicsControl.SwapBuffers(); } diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs index ad2b33bc71..6d9e5d5c9e 100644 --- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs +++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs @@ -2,7 +2,6 @@ using System; using System.IO; using System.Drawing; using OpenTK; -using OpenTK.Graphics.OpenGL; using BizHawk.Bizware.BizwareGL; @@ -135,10 +134,10 @@ namespace BizHawk.Client.EmuHawk } - public void SetMinFilter(Texture2d texture, TextureMinFilter minFilter) + public void SetMinFilter(Texture2d texture, Bizware.BizwareGL.TextureMinFilter minFilter) => ((GDIPTextureWrapper) texture.Opaque).MinFilter = minFilter; - public void SetMagFilter(Texture2d texture, TextureMagFilter magFilter) + public void SetMagFilter(Texture2d texture, Bizware.BizwareGL.TextureMagFilter magFilter) => ((GDIPTextureWrapper) texture.Opaque).MagFilter = magFilter; public Texture2d LoadTexture(Bitmap bitmap) diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs index 256f8a7835..0de7c20f3b 100644 --- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs +++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs @@ -17,9 +17,16 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; +using BizGL = BizHawk.Bizware.BizwareGL; +using BlendEquationMode = OpenTK.Graphics.OpenGL.BlendEquationMode; +using BlendingFactorDest = OpenTK.Graphics.OpenGL.BlendingFactorDest; +using BlendingFactorSrc = OpenTK.Graphics.OpenGL.BlendingFactorSrc; +using ClearBufferMask = OpenTK.Graphics.OpenGL.ClearBufferMask; +using PrimitiveType = OpenTK.Graphics.OpenGL.PrimitiveType; using sd = System.Drawing; using sdi = System.Drawing.Imaging; using swf = System.Windows.Forms; +using VertexAttribPointerType = OpenTK.Graphics.OpenGL.VertexAttribPointerType; namespace BizHawk.Client.EmuHawk { @@ -89,9 +96,9 @@ namespace BizHawk.Client.EmuHawk GraphicsContext.Dispose(); GraphicsContext = null; } - public void Clear(ClearBufferMask mask) + public void Clear(BizGL.ClearBufferMask mask) { - GL.Clear(mask); + GL.Clear((ClearBufferMask) (int) mask); // these are the same enum } public void SetClearColor(sd.Color color) { @@ -126,8 +133,13 @@ namespace BizHawk.Client.EmuHawk return CreateShader(ShaderType.VertexShader, source, entry, required); } - public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest, - BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest) + public IBlendState CreateBlendState( + BizGL.BlendingFactorSrc colorSource, + BizGL.BlendEquationMode colorEquation, + BizGL.BlendingFactorDest colorDest, + BizGL.BlendingFactorSrc alphaSource, + BizGL.BlendEquationMode alphaEquation, + BizGL.BlendingFactorDest alphaDest) { return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest); } @@ -138,8 +150,15 @@ namespace BizHawk.Client.EmuHawk if (mybs.Enabled) { GL.Enable(EnableCap.Blend); - GL.BlendEquationSeparate(mybs.colorEquation, mybs.alphaEquation); - GL.BlendFuncSeparate(mybs.colorSource, mybs.colorDest, mybs.alphaSource, mybs.alphaDest); + // these are all casts to copies of the same enum + GL.BlendEquationSeparate( + (BlendEquationMode) (int) mybs.colorEquation, + (BlendEquationMode) (int) mybs.alphaEquation); + GL.BlendFuncSeparate( + (BlendingFactorSrc) (int) mybs.colorSource, + (BlendingFactorDest) (int) mybs.colorDest, + (BlendingFactorSrc) (int) mybs.alphaSource, + (BlendingFactorDest) (int) mybs.alphaDest); } else GL.Disable(EnableCap.Blend); if (rsBlend == _rsBlendNoneOpaque) @@ -368,9 +387,9 @@ namespace BizHawk.Client.EmuHawk MyBindArrayData(sStatePendingVertexLayout, pData); } - public void DrawArrays(PrimitiveType mode, int first, int count) + public void DrawArrays(BizGL.PrimitiveType mode, int first, int count) { - GL.DrawArrays(mode, first, count); + GL.DrawArrays((PrimitiveType) (int) mode, first, count); // these are the same enum } public void SetPipelineUniform(PipelineUniform uniform, bool value) @@ -427,13 +446,13 @@ namespace BizHawk.Client.EmuHawk GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque); } - public void SetMinFilter(Texture2d texture, TextureMinFilter minFilter) + public void SetMinFilter(Texture2d texture, BizGL.TextureMinFilter minFilter) { BindTexture2d(texture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int) minFilter); } - public void SetMagFilter(Texture2d texture, TextureMagFilter magFilter) + public void SetMagFilter(Texture2d texture, BizGL.TextureMagFilter magFilter) { BindTexture2d(texture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) magFilter); @@ -490,8 +509,8 @@ namespace BizHawk.Client.EmuHawk Texture2d tex = new Texture2d(this, texId, w, h); GL.BindTexture(TextureTarget.Texture2D, texId); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, w, h, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - tex.SetMagFilter(TextureMagFilter.Nearest); - tex.SetMinFilter(TextureMinFilter.Nearest); + tex.SetMagFilter(BizGL.TextureMagFilter.Nearest); + tex.SetMinFilter(BizGL.TextureMinFilter.Nearest); // create the FBO int fbId = GL.Ext.GenFramebuffer(); @@ -752,7 +771,13 @@ namespace BizHawk.Client.EmuHawk { if(_currPipeline.Memo == "gui") { - GL.VertexAttribPointer(kvp.Key, kvp.Value.Components, (VertexAttribPointerType)kvp.Value.AttribType, kvp.Value.Normalized, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset); + GL.VertexAttribPointer( + kvp.Key, + kvp.Value.Components, + (VertexAttribPointerType) (int) kvp.Value.AttribType, // these are the same enum + kvp.Value.Normalized, + kvp.Value.Stride, + new IntPtr(pData) + kvp.Value.Offset); GL.EnableVertexAttribArray(kvp.Key); currBindings.Add(kvp.Key); } @@ -801,18 +826,18 @@ namespace BizHawk.Client.EmuHawk { _rsBlendNoneVerbatim = new CacheBlendState( false, - BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, - BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); + BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero, + BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero); _rsBlendNoneOpaque = new CacheBlendState( false, - BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, - BlendingFactorSrc.ConstantAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); + BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero, + BizGL.BlendingFactorSrc.ConstantAlpha, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero); _rsBlendNormal = new CacheBlendState( true, - BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha, - BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); + BizGL.BlendingFactorSrc.SrcAlpha, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.OneMinusSrcAlpha, + BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero); } private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;