TextureBase.cs 1.0 KB

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