TextureBase.cs
1 using OpenTK.Graphics.OpenGL; 2 using Ryujinx.Graphics.GAL; 3 4 namespace Ryujinx.Graphics.OpenGL.Image 5 { 6 class TextureBase 7 { 8 public int Handle { get; protected set; } 9 10 public TextureCreateInfo Info { get; } 11 12 public int Width => Info.Width; 13 public int Height => Info.Height; 14 15 public Target Target => Info.Target; 16 public Format Format => Info.Format; 17 18 public TextureBase(TextureCreateInfo info) 19 { 20 Info = info; 21 22 Handle = GL.GenTexture(); 23 } 24 25 public void Bind(int unit) 26 { 27 Bind(Target.Convert(), unit); 28 } 29 30 protected void Bind(TextureTarget target, int unit) 31 { 32 GL.ActiveTexture(TextureUnit.Texture0 + unit); 33 GL.BindTexture(target, Handle); 34 } 35 36 public static void ClearBinding(int unit) 37 { 38 GL.ActiveTexture(TextureUnit.Texture0 + unit); 39 GL.BindTextureUnit(unit, 0); 40 } 41 } 42 }