Copy enums from OpenTK

This commit is contained in:
YoshiRulz 2021-02-13 14:50:24 +10:00 committed by James Groom
parent 4a0e343c37
commit 3dd03495e2
21 changed files with 294 additions and 102 deletions

View File

@ -1,7 +1,5 @@
using System; using System;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {
public class GDIPTextureWrapper : IDisposable public class GDIPTextureWrapper : IDisposable

View File

@ -4,7 +4,6 @@ using System;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
using sd = System.Drawing; using sd = System.Drawing;

View File

@ -5,7 +5,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
using sd = System.Drawing; using sd = System.Drawing;

View File

@ -3,7 +3,6 @@ using System.IO;
using System.Drawing; using System.Drawing;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {

View File

@ -7,29 +7,36 @@ namespace BizHawk.Bizware.BizwareGL
/// </summary> /// </summary>
public class CacheBlendState : IBlendState public class CacheBlendState : IBlendState
{ {
public bool Enabled; public readonly 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 CacheBlendState(bool enabled, public readonly BlendingFactorSrc colorSource;
global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource,
global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation, public readonly BlendEquationMode colorEquation;
global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest,
global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource, public readonly BlendingFactorDest colorDest;
global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation,
global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest) 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.Enabled = enabled;
this.colorSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource; this.colorSource = colorSource;
this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation; this.colorEquation = colorEquation;
this.colorDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest; this.colorDest = colorDest;
this.alphaSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource; this.alphaSource = alphaSource;
this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation; this.alphaEquation = alphaEquation;
this.alphaDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest; this.alphaDest = alphaDest;
} }
} }
} }

View File

@ -2,7 +2,6 @@ using System;
using System.Drawing; using System.Drawing;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Drawing; using System.Drawing;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {

View File

@ -1,8 +1,6 @@
using System; using System;
using BizHawk.Common; using BizHawk.Common;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
{ {
/// <summary> /// <summary>

View File

@ -0,0 +1,11 @@
namespace BizHawk.Bizware.BizwareGL
{
public enum BlendEquationMode
{
FuncAdd = 0x8006,
Min = 0x8007,
Max = 0x8008,
FuncSubtract = 0x800A,
FuncReverseSubtract = 0x800B,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -7,7 +7,8 @@ using BizHawk.Bizware.BizwareGL;
using SlimDX.Direct3D9; using SlimDX.Direct3D9;
using OpenTK; using OpenTK;
using gl = OpenTK.Graphics.OpenGL;
using PrimitiveType = SlimDX.Direct3D9.PrimitiveType;
using sd = System.Drawing; using sd = System.Drawing;
using sdi = System.Drawing.Imaging; using sdi = System.Drawing.Imaging;
using swf = System.Windows.Forms; using swf = System.Windows.Forms;
@ -130,12 +131,12 @@ namespace BizHawk.Bizware.DirectX
_d3d.Dispose(); _d3d.Dispose();
} }
public void Clear(OpenTK.Graphics.OpenGL.ClearBufferMask mask) public void Clear(ClearBufferMask mask)
{ {
ClearFlags flags = ClearFlags.None; ClearFlags flags = ClearFlags.None;
if ((mask & gl.ClearBufferMask.ColorBufferBit) != 0) flags |= ClearFlags.Target; if ((mask & ClearBufferMask.ColorBufferBit) != 0) flags |= ClearFlags.Target;
if ((mask & gl.ClearBufferMask.DepthBufferBit) != 0) flags |= ClearFlags.ZBuffer; if ((mask & ClearBufferMask.DepthBufferBit) != 0) flags |= ClearFlags.ZBuffer;
if ((mask & gl.ClearBufferMask.StencilBufferBit) != 0) flags |= ClearFlags.Stencil; if ((mask & ClearBufferMask.StencilBufferBit) != 0) flags |= ClearFlags.Stencil;
Dev.Clear(flags, _clearColor, 0.0f, 0); Dev.Clear(flags, _clearColor, 0.0f, 0);
} }
@ -145,8 +146,13 @@ namespace BizHawk.Bizware.DirectX
_clearColor = color.ToArgb(); _clearColor = color.ToArgb();
} }
public IBlendState CreateBlendState(gl.BlendingFactorSrc colorSource, gl.BlendEquationMode colorEquation, gl.BlendingFactorDest colorDest, public IBlendState CreateBlendState(
gl.BlendingFactorSrc alphaSource, gl.BlendEquationMode alphaEquation, gl.BlendingFactorDest alphaDest) BlendingFactorSrc colorSource,
BlendEquationMode colorEquation,
BlendingFactorDest colorDest,
BlendingFactorSrc alphaSource,
BlendEquationMode alphaEquation,
BlendingFactorDest alphaDest)
{ {
return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, 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 return glMode switch
{ {
gl.BlendEquationMode.FuncAdd => BlendOperation.Add, BlendEquationMode.FuncAdd => BlendOperation.Add,
gl.BlendEquationMode.FuncSubtract => BlendOperation.Subtract, BlendEquationMode.FuncSubtract => BlendOperation.Subtract,
gl.BlendEquationMode.Max => BlendOperation.Maximum, BlendEquationMode.Max => BlendOperation.Maximum,
gl.BlendEquationMode.Min => BlendOperation.Minimum, BlendEquationMode.Min => BlendOperation.Minimum,
gl.BlendEquationMode.FuncReverseSubtract => BlendOperation.ReverseSubtract, BlendEquationMode.FuncReverseSubtract => BlendOperation.ReverseSubtract,
_ => throw new ArgumentOutOfRangeException() _ => 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, BlendingFactorSrc.Zero => Blend.Zero,
gl.BlendingFactorSrc.One => Blend.One, BlendingFactorSrc.One => Blend.One,
gl.BlendingFactorSrc.SrcColor => Blend.SourceColor, BlendingFactorSrc.SrcColor => Blend.SourceColor,
gl.BlendingFactorSrc.OneMinusSrcColor => Blend.InverseSourceColor, BlendingFactorSrc.OneMinusSrcColor => Blend.InverseSourceColor,
gl.BlendingFactorSrc.SrcAlpha => Blend.SourceAlpha, BlendingFactorSrc.SrcAlpha => Blend.SourceAlpha,
gl.BlendingFactorSrc.OneMinusSrcAlpha => Blend.InverseSourceAlpha, BlendingFactorSrc.OneMinusSrcAlpha => Blend.InverseSourceAlpha,
gl.BlendingFactorSrc.DstAlpha => Blend.DestinationAlpha, BlendingFactorSrc.DstAlpha => Blend.DestinationAlpha,
gl.BlendingFactorSrc.OneMinusDstAlpha => Blend.InverseDestinationAlpha, BlendingFactorSrc.OneMinusDstAlpha => Blend.InverseDestinationAlpha,
gl.BlendingFactorSrc.DstColor => Blend.DestinationColor, BlendingFactorSrc.DstColor => Blend.DestinationColor,
gl.BlendingFactorSrc.OneMinusDstColor => Blend.InverseDestinationColor, BlendingFactorSrc.OneMinusDstColor => Blend.InverseDestinationColor,
gl.BlendingFactorSrc.SrcAlphaSaturate => Blend.SourceAlphaSaturated, BlendingFactorSrc.SrcAlphaSaturate => Blend.SourceAlphaSaturated,
gl.BlendingFactorSrc.ConstantColor => Blend.BlendFactor, BlendingFactorSrc.ConstantColor => Blend.BlendFactor,
gl.BlendingFactorSrc.OneMinusConstantColor => Blend.InverseBlendFactor, BlendingFactorSrc.OneMinusConstantColor => Blend.InverseBlendFactor,
gl.BlendingFactorSrc.ConstantAlpha => throw new NotSupportedException(), BlendingFactorSrc.ConstantAlpha => throw new NotSupportedException(),
gl.BlendingFactorSrc.OneMinusConstantAlpha => throw new NotSupportedException(), BlendingFactorSrc.OneMinusConstantAlpha => throw new NotSupportedException(),
gl.BlendingFactorSrc.Src1Alpha => throw new NotSupportedException(), BlendingFactorSrc.Src1Alpha => throw new NotSupportedException(),
gl.BlendingFactorSrc.Src1Color => throw new NotSupportedException(), BlendingFactorSrc.Src1Color => throw new NotSupportedException(),
gl.BlendingFactorSrc.OneMinusSrc1Color => throw new NotSupportedException(), BlendingFactorSrc.OneMinusSrc1Color => throw new NotSupportedException(),
gl.BlendingFactorSrc.OneMinusSrc1Alpha => throw new NotSupportedException(), BlendingFactorSrc.OneMinusSrc1Alpha => throw new NotSupportedException(),
_ => throw new ArgumentOutOfRangeException() _ => throw new ArgumentOutOfRangeException()
}; };
@ -305,18 +311,18 @@ namespace BizHawk.Bizware.DirectX
{ {
_rsBlendNoneVerbatim = new CacheBlendState( _rsBlendNoneVerbatim = new CacheBlendState(
false, false,
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero, BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero,
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
_rsBlendNoneOpaque = new CacheBlendState( _rsBlendNoneOpaque = new CacheBlendState(
false, false,
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero, BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero,
gl.BlendingFactorSrc.ConstantAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); BlendingFactorSrc.ConstantAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
_rsBlendNormal = new CacheBlendState( _rsBlendNormal = new CacheBlendState(
true, true,
gl.BlendingFactorSrc.SrcAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.OneMinusSrcAlpha, BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha,
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
} }
private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal; private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;
@ -351,7 +357,7 @@ namespace BizHawk.Bizware.DirectX
DeclarationType declType; DeclarationType declType;
switch (item.AttribType) switch (item.AttribType)
{ {
case gl.VertexAttribPointerType.Float: case VertexAttribPointerType.Float:
if (item.Components == 1) declType = DeclarationType.Float1; if (item.Components == 1) declType = DeclarationType.Float1;
else if (item.Components == 2) declType = DeclarationType.Float2; else if (item.Components == 2) declType = DeclarationType.Float2;
else if (item.Components == 3) declType = DeclarationType.Float3; else if (item.Components == 3) declType = DeclarationType.Float3;
@ -649,13 +655,13 @@ namespace BizHawk.Bizware.DirectX
tw.WrapClamp = clamp ? TextureAddress.Clamp : TextureAddress.Wrap; tw.WrapClamp = clamp ? TextureAddress.Clamp : TextureAddress.Wrap;
} }
public void SetMinFilter(Texture2d texture, gl.TextureMinFilter minFilter) public void SetMinFilter(Texture2d texture, TextureMinFilter minFilter)
=> ((TextureWrapper) texture.Opaque).MinFilter = minFilter == gl.TextureMinFilter.Linear => ((TextureWrapper) texture.Opaque).MinFilter = minFilter == TextureMinFilter.Linear
? TextureFilter.Linear ? TextureFilter.Linear
: TextureFilter.Point; : TextureFilter.Point;
public void SetMagFilter(Texture2d texture, gl.TextureMagFilter magFilter) public void SetMagFilter(Texture2d texture, TextureMagFilter magFilter)
=> ((TextureWrapper) texture.Opaque).MagFilter = magFilter == gl.TextureMagFilter.Linear => ((TextureWrapper) texture.Opaque).MagFilter = magFilter == TextureMagFilter.Linear
? TextureFilter.Linear ? TextureFilter.Linear
: TextureFilter.Point; : TextureFilter.Point;
@ -924,12 +930,12 @@ namespace BizHawk.Bizware.DirectX
return ret; return ret;
} }
/// <exception cref="NotSupportedException"><paramref name="mode"/> is <see cref="gl.PrimitiveType.TriangleStrip"/></exception> /// <exception cref="NotSupportedException"><paramref name="mode"/> is not <see cref="BizwareGL.PrimitiveType.TriangleStrip"/></exception>
public unsafe void DrawArrays(gl.PrimitiveType mode, int first, int count) public unsafe void DrawArrays(BizwareGL.PrimitiveType mode, int first, int count)
{ {
var pt = PrimitiveType.TriangleStrip; var pt = PrimitiveType.TriangleStrip;
if (mode != gl.PrimitiveType.TriangleStrip) if (mode != BizwareGL.PrimitiveType.TriangleStrip)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }

View File

@ -375,7 +375,7 @@ namespace BizHawk.Client.Common.Filters
//TODO: this could be more efficient (draw only in gap) //TODO: this could be more efficient (draw only in gap)
GL.SetClearColor(Color.Black); GL.SetClearColor(Color.Black);
GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit);
FilterProgram.GuiRenderer.Begin(outputSize); FilterProgram.GuiRenderer.Begin(outputSize);
GuiRenderer.SetBlendState(GL.BlendNoneCopy); GuiRenderer.SetBlendState(GL.BlendNoneCopy);
@ -558,7 +558,7 @@ namespace BizHawk.Client.Common.Filters
return; return;
GL.SetClearColor(Color.FromArgb(BackgroundColor)); GL.SetClearColor(Color.FromArgb(BackgroundColor));
GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit);
GuiRenderer.Begin(OutputSize.Width, OutputSize.Height); GuiRenderer.Begin(OutputSize.Width, OutputSize.Height);
GuiRenderer.SetBlendState(GL.BlendNoneCopy); GuiRenderer.SetBlendState(GL.BlendNoneCopy);

View File

@ -952,7 +952,7 @@ namespace BizHawk.Client.EmuHawk
_gl.BeginScene(); _gl.BeginScene();
_gl.BindRenderTarget(null); _gl.BindRenderTarget(null);
_gl.SetClearColor(Color.Black); _gl.SetClearColor(Color.Black);
_gl.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); _gl.Clear(ClearBufferMask.ColorBufferBit);
_gl.EndScene(); _gl.EndScene();
_presentationPanel.GraphicsControl.SwapBuffers(); _presentationPanel.GraphicsControl.SwapBuffers();
} }

View File

@ -2,7 +2,6 @@ using System;
using System.IO; using System.IO;
using System.Drawing; using System.Drawing;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
using BizHawk.Bizware.BizwareGL; 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; => ((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; => ((GDIPTextureWrapper) texture.Opaque).MagFilter = magFilter;
public Texture2d LoadTexture(Bitmap bitmap) public Texture2d LoadTexture(Bitmap bitmap)

View File

@ -17,9 +17,16 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL; 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 sd = System.Drawing;
using sdi = System.Drawing.Imaging; using sdi = System.Drawing.Imaging;
using swf = System.Windows.Forms; using swf = System.Windows.Forms;
using VertexAttribPointerType = OpenTK.Graphics.OpenGL.VertexAttribPointerType;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -89,9 +96,9 @@ namespace BizHawk.Client.EmuHawk
GraphicsContext.Dispose(); GraphicsContext = null; 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) public void SetClearColor(sd.Color color)
{ {
@ -126,8 +133,13 @@ namespace BizHawk.Client.EmuHawk
return CreateShader(ShaderType.VertexShader, source, entry, required); return CreateShader(ShaderType.VertexShader, source, entry, required);
} }
public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest, public IBlendState CreateBlendState(
BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest) 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); return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest);
} }
@ -138,8 +150,15 @@ namespace BizHawk.Client.EmuHawk
if (mybs.Enabled) if (mybs.Enabled)
{ {
GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Blend);
GL.BlendEquationSeparate(mybs.colorEquation, mybs.alphaEquation); // these are all casts to copies of the same enum
GL.BlendFuncSeparate(mybs.colorSource, mybs.colorDest, mybs.alphaSource, mybs.alphaDest); 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); else GL.Disable(EnableCap.Blend);
if (rsBlend == _rsBlendNoneOpaque) if (rsBlend == _rsBlendNoneOpaque)
@ -368,9 +387,9 @@ namespace BizHawk.Client.EmuHawk
MyBindArrayData(sStatePendingVertexLayout, pData); 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) public void SetPipelineUniform(PipelineUniform uniform, bool value)
@ -427,13 +446,13 @@ namespace BizHawk.Client.EmuHawk
GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque); GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
} }
public void SetMinFilter(Texture2d texture, TextureMinFilter minFilter) public void SetMinFilter(Texture2d texture, BizGL.TextureMinFilter minFilter)
{ {
BindTexture2d(texture); BindTexture2d(texture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int) minFilter); 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); BindTexture2d(texture);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) magFilter); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) magFilter);
@ -490,8 +509,8 @@ namespace BizHawk.Client.EmuHawk
Texture2d tex = new Texture2d(this, texId, w, h); Texture2d tex = new Texture2d(this, texId, w, h);
GL.BindTexture(TextureTarget.Texture2D, texId); GL.BindTexture(TextureTarget.Texture2D, texId);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, w, h, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, w, h, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
tex.SetMagFilter(TextureMagFilter.Nearest); tex.SetMagFilter(BizGL.TextureMagFilter.Nearest);
tex.SetMinFilter(TextureMinFilter.Nearest); tex.SetMinFilter(BizGL.TextureMinFilter.Nearest);
// create the FBO // create the FBO
int fbId = GL.Ext.GenFramebuffer(); int fbId = GL.Ext.GenFramebuffer();
@ -752,7 +771,13 @@ namespace BizHawk.Client.EmuHawk
{ {
if(_currPipeline.Memo == "gui") 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); GL.EnableVertexAttribArray(kvp.Key);
currBindings.Add(kvp.Key); currBindings.Add(kvp.Key);
} }
@ -801,18 +826,18 @@ namespace BizHawk.Client.EmuHawk
{ {
_rsBlendNoneVerbatim = new CacheBlendState( _rsBlendNoneVerbatim = new CacheBlendState(
false, false,
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero,
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero);
_rsBlendNoneOpaque = new CacheBlendState( _rsBlendNoneOpaque = new CacheBlendState(
false, false,
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero, BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero,
BlendingFactorSrc.ConstantAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); BizGL.BlendingFactorSrc.ConstantAlpha, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero);
_rsBlendNormal = new CacheBlendState( _rsBlendNormal = new CacheBlendState(
true, true,
BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha, BizGL.BlendingFactorSrc.SrcAlpha, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.OneMinusSrcAlpha,
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); BizGL.BlendingFactorSrc.One, BizGL.BlendEquationMode.FuncAdd, BizGL.BlendingFactorDest.Zero);
} }
private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal; private CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;