Texture2D - Added texture slot clamping and debug assertion when slot is out of range

This commit is contained in:
miku-666
2023-11-12 12:03:25 +01:00
parent a90a98f8bc
commit 2fef371397

View File

@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace PckStudio.Rendering
@@ -47,6 +44,8 @@ namespace PckStudio.Rendering
public void Bind(int slot)
{
Debug.Assert(slot >= 0 || slot < 32, "Slot is out of range");
slot = MathHelper.Clamp(slot, 0, 31);
GL.ActiveTexture(TextureUnit.Texture0 + slot);
GL.BindTexture(TextureTarget.Texture2D, _id);
}