2020-04-25 13:02:18 +00:00
|
|
|
|
using OpenTK.Graphics.OpenGL;
|
|
|
|
|
using Ryujinx.Graphics.GAL;
|
2020-07-07 02:41:07 +00:00
|
|
|
|
using System;
|
2020-04-25 13:02:18 +00:00
|
|
|
|
|
2020-05-23 09:46:09 +00:00
|
|
|
|
namespace Ryujinx.Graphics.OpenGL.Image
|
2020-04-25 13:02:18 +00:00
|
|
|
|
{
|
|
|
|
|
class TextureBase
|
|
|
|
|
{
|
|
|
|
|
public int Handle { get; protected set; }
|
|
|
|
|
|
|
|
|
|
protected TextureCreateInfo Info { get; }
|
|
|
|
|
|
2020-07-07 02:41:07 +00:00
|
|
|
|
public int Width { get; }
|
|
|
|
|
public int Height { get; }
|
|
|
|
|
public float ScaleFactor { get; }
|
2020-04-25 13:02:18 +00:00
|
|
|
|
|
|
|
|
|
public Target Target => Info.Target;
|
|
|
|
|
public Format Format => Info.Format;
|
|
|
|
|
|
2020-07-07 02:41:07 +00:00
|
|
|
|
public TextureBase(TextureCreateInfo info, float scaleFactor = 1f)
|
2020-04-25 13:02:18 +00:00
|
|
|
|
{
|
|
|
|
|
Info = info;
|
2020-07-07 02:41:07 +00:00
|
|
|
|
Width = (int)Math.Ceiling(Info.Width * scaleFactor);
|
|
|
|
|
Height = (int)Math.Ceiling(Info.Height * scaleFactor);
|
|
|
|
|
ScaleFactor = scaleFactor;
|
2020-04-25 13:02:18 +00:00
|
|
|
|
|
|
|
|
|
Handle = GL.GenTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Bind(int unit)
|
|
|
|
|
{
|
|
|
|
|
Bind(Target.Convert(), unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Bind(TextureTarget target, int unit)
|
|
|
|
|
{
|
|
|
|
|
GL.ActiveTexture(TextureUnit.Texture0 + unit);
|
|
|
|
|
GL.BindTexture(target, Handle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|