TextureBase.cs 1.1 KB

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