Beispiel #1
0
        /// <summary>
        /// Binds the given <see cref="Texture2DArray"/> to the GraphicsDevice at the given texture unit location.
        /// </summary>
        /// <param name="slot">The texture unit slot that the texture will be bound to.</param>
        /// <param name="texture2DArray">The <see cref="Texture2DArray"/> to bind.</param>
        public void BindTexture2DArray(int slot, Texture2DArray texture2DArray)
        {
            if (slot < 0 || slot >= GLInfo.MaxTextureImageUnits)
            {
                throw new ArgumentOutOfRangeException(nameof(slot));
            }

            if (texture2DArray == null)
            {
                throw new ArgumentNullException(nameof(texture2DArray));
            }

            texture2DArray.EnsureUndisposed();

            SetActiveTextureSlot(slot);

            if (_textureUnits[slot].Texture2DArrayHandle == texture2DArray.Handle)
            {
                return;
            }

            ClearOtherTextureTypes(slot, ManaTextureType.Texture2DArray);

            GL.BindTexture(TextureTarget.Texture2DArray, texture2DArray.Handle);

            _boundTextureType = ManaTextureType.Texture2DArray;
            _textureUnits[slot].Texture2DArrayHandle        = texture2DArray.Handle;
            _textureUnits[slot].Texture2DArray              = texture2DArray;
            _textureUnits[slot].Texture2DArray.BoundContext = this;
        }
Beispiel #2
0
        /// <summary>
        /// Ensures that there is no active <see cref="Texture2DArray"/> object bound to the RenderContext's given
        /// texture unit slot.
        /// </summary>
        public void UnbindTexture2DArray(int slot)
        {
            if (slot < 0 || slot >= GLInfo.MaxTextureImageUnits)
            {
                throw new ArgumentOutOfRangeException(nameof(slot));
            }

            if (_textureUnits[slot].Texture2DArrayHandle == GLHandle.Zero)
            {
                return;
            }

            SetActiveTextureSlot(slot);

            GL.BindTexture(TextureTarget.Texture2DArray, GLHandle.Zero);

            _boundTextureType = ManaTextureType.None;
            _textureUnits[slot].Texture2DArrayHandle        = GLHandle.Zero;
            _textureUnits[slot].Texture2DArray.BoundContext = null;
            _textureUnits[slot].Texture2DArray = null;
        }