示例#1
0
        public void SetUniform(string name, Texture value, int textureUnit)
        {
            EnsureNotDisposed();

            if (value.Disposed)
            {
                throw new ArgumentException("Texture provided was already diposed.");
            }

            if (textureUnit == 0)
            {
                _log.Error("Cannot set texture unit 0: reserved for use by the rendering system blitting functions.");
                return;
            }

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                _log.Warning($"Texture sampler '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetShaderImage(value.ImageHandle, loc, textureUnit);
        }
示例#2
0
        public void SetUniform(string name, Color value)
        {
            EnsureNotDisposed();

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                _log.Warning($"Vec4 uniform '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetUniformfv(loc, 4, 1, value.AsNormalizedFloatArray());
        }
示例#3
0
        public void SetUniform(string name, Vector4 value)
        {
            EnsureNotDisposed();

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                _log.Warning($"Vec4 uniform '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetUniformfv(loc, 4, 1, new[] { value.X, value.Y, value.Z, value.W });
        }
示例#4
0
        public void SetUniform(string name, uint value)
        {
            EnsureNotDisposed();

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                _log.Warning($"Uint uniform '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetUniformui(loc, value);
        }
示例#5
0
        public void SetUniform(string name, Texture value, int textureUnit)
        {
            EnsureNotDisposed();

            if (value.Disposed)
            {
                throw new ArgumentException("Texture provided was already diposed.");
            }

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                Log.Warning($"Float uniform '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetShaderImage(value.ImageHandle, loc, textureUnit);
        }
示例#6
0
        public void SetUniform(string name, Matrix4x4 value)
        {
            EnsureNotDisposed();

            var loc = SDL_gpu.GPU_GetUniformLocation(ProgramHandle, name);

            if (loc == -1)
            {
                _log.Warning($"Mat4 uniform '{name}' does not exist.");
                return;
            }

            SDL_gpu.GPU_SetUniformMatrixfv(loc, 1, 4, 4, false, new[]
            {
                value.M11, value.M12, value.M13, value.M14,
                value.M21, value.M22, value.M23, value.M24,
                value.M31, value.M32, value.M33, value.M34,
                value.M41, value.M42, value.M43, value.M44
            });
        }