TextureBase.cs 833 B

123456789101112131415161718192021222324252627282930313233343536
  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. protected TextureCreateInfo Info { get; }
  9. public int Width => Info.Width;
  10. public int Height => Info.Height;
  11. public Target Target => Info.Target;
  12. public Format Format => Info.Format;
  13. public TextureBase(TextureCreateInfo info)
  14. {
  15. Info = info;
  16. Handle = GL.GenTexture();
  17. }
  18. public void Bind(int unit)
  19. {
  20. Bind(Target.Convert(), unit);
  21. }
  22. protected void Bind(TextureTarget target, int unit)
  23. {
  24. GL.ActiveTexture(TextureUnit.Texture0 + unit);
  25. GL.BindTexture(target, Handle);
  26. }
  27. }
  28. }