예제 #1
0
        /// <summary>
        /// Compute a texture mipmap size.
        /// </summary>
        /// <param name="lod">
        /// A <see cref="UInt32"/> that specify the mipmap level.
        /// </param>
        /// <returns>
        /// It returns a <see cref="Vertex3ui"/> that contains the mipmap width, height and depth.
        /// </returns>
        protected Vertex3ui GetMipmapSize(uint lod)
        {
            Vertex3ui mipmapSize = BaseSize / (uint)Math.Pow(2.0, lod);

            mipmapSize.x = Math.Max(1, mipmapSize.x);
            mipmapSize.y = Math.Max(1, mipmapSize.y);
            mipmapSize.z = Math.Max(1, mipmapSize.z);

            return(mipmapSize);
        }
예제 #2
0
        public void TestUniform3ui()
        {
            if (!HasVersion(3, 0) && !HasEsVersion(3, 0) && !IsGlExtensionSupported("GL_EXT_gpu_shader4"))
            {
                Assert.Inconclusive("required features not implemented");
            }

            using (Device device = new Device())
                using (new GLContext(device))
                {
                    uint program = CreateProgramUniform3ui();

                    try {
                        Vertex3ui uniformStruct;
                        uint[]    uniformValue;

                        int uniformLoc = Gl.GetUniformLocation(program, "uVec");
                        if (uniformLoc < 0)
                        {
                            throw new InvalidOperationException("no uniform variable");
                        }

                        // glGetUniformuiv
                        uniformValue = Array3(1u);
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array3(0u), uniformValue);

                        // glGetUniformuiv (ref)
                        uniformStruct = new Vertex3ui(1u);
                        Gl.GetUniformui(program, uniformLoc, ref uniformStruct);
                        Assert.AreEqual(Vertex3ui.Zero, uniformStruct);

                        // glUniform3ui
                        uniformValue = Array3(0u);
                        Gl.Uniform3(uniformLoc, Array3(1u));
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array3(1u), uniformValue);

                        // glUniform3uiv
                        uniformValue = Array3(0u);
                        Gl.Uniform3(uniformLoc, Array3(9u));
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array3(9u), uniformValue);

                        // glUniform3uiv (ref)
                        uniformValue  = Array3(0u);
                        uniformStruct = new Vertex3ui(5u);
                        Gl.Uniform3ui(uniformLoc, 1, ref uniformStruct);
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array3(5u), uniformValue);
                    } finally {
                        Gl.DeleteProgram(program);
                    }
                }
        }
예제 #3
0
        public void ColorBGR96_CastToVertex4()
        {
            uint r = (uint)NextComponent(uint.MaxValue);
            uint g = (uint)NextComponent(uint.MaxValue);
            uint b = (uint)NextComponent(uint.MaxValue);

            ColorBGR96 v      = new ColorBGR96(r, g, b);
            Vertex3ui  vArray = v;

            Assert.AreEqual(b, vArray.x);
            Assert.AreEqual(g, vArray.y);
            Assert.AreEqual(r, vArray.z);
        }
예제 #4
0
        /// <summary>
        /// Generate mipmaps for this Texture, replacing mipmaps level from 1 to <see cref="MipmapLevels"/> - 1.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for mipmapping definition.
        /// </param>
        /// <param name="target">
        /// A <see cref="TextureTarget"/> indicating the target for generating
        /// bitmaps.
        /// </param>
        protected void GenerateMipmaps(GraphicsContext ctx, TextureTarget target)
        {
            CheckCurrentContext(ctx);

            // Bind this Texture
            ctx.Bind(this);
            // Ensure base/max level are updated
            SetMipmapLevelRange(ctx);
            // Generate mipmaps
            Gl.GenerateMipmap(target);

            for (uint i = BaseLevel + 1; i < Math.Min(MipmapLevels, MaxLevel); i++)
            {
                Vertex3ui mipmapSize = GetMipmapSize(i);

                SetMipmap(_Mipmaps[BaseLevel].InternalFormat, mipmapSize.x, mipmapSize.y, mipmapSize.z, i);
            }
        }
예제 #5
0
        /// <summary>
        /// Generate mipmaps for this Texture, replacing mipmaps level from 1 to <see cref="MipmapLevels"/> - 1.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for mipmapping definition.
        /// </param>
        /// <param name="target">
        /// A <see cref="TextureTarget"/> indicating the target for generating
        /// bitmaps.
        /// </param>
        protected void GenerateMipmaps(GraphicsContext ctx, TextureTarget target)
        {
            CheckCurrentContext(ctx);

            if (ctx.Version >= Gl.Version_300)
            {
                // Bind this Texture
                ctx.Bind(this);
                // Generate mipmaps
                Gl.GenerateMipmap(target);
            }

            for (uint i = MipmapMinLevel + 1; i < MipmapLevels; i++)
            {
                Vertex3ui mipmapSize = GetMipmapSize(i);

                SetMipmap(_Mipmaps[MipmapMinLevel].InternalFormat, mipmapSize.x, mipmapSize.y, mipmapSize.z, i);
            }
        }
예제 #6
0
 void IShaderUniformContainer.SetUniform(GraphicsContext ctx, string uniformName, Vertex3ui v)
 {
     throw new NotImplementedException();
 }