Exemplo n.º 1
0
        /// <summary>
        /// Indicates that the specified texture has been deleted and updates the OpenGL state accordingly.
        /// </summary>
        /// <param name="texture">The texture to delete.</param>
        public static void DeleteTexture2D(UInt32 texture)
        {
            if (GL_TEXTURE_BINDING_2D == texture)
            {
                GL_TEXTURE_BINDING_2D.Update(0);
                glTextureBinding2DByTextureUnit[GL_ACTIVE_TEXTURE] = 0;

                VerifyCache();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Immediately binds a 2D texture to the OpenGL context and updates the state cache.
        /// </summary>
        /// <param name="texture">The texture to bind to the context.</param>
        public static void Texture2D(UInt32 texture)
        {
            gl.BindTexture(gl.GL_TEXTURE_2D, texture);
            gl.ThrowIfError();

            GL_TEXTURE_BINDING_2D.Update(texture);
            glTextureBinding2DByTextureUnit[GL_ACTIVE_TEXTURE] = texture;

            VerifyCache();
        }
Exemplo n.º 3
0
        private void Dispose_BindTexture2D()
        {
            if (forced || !gl.IsDirectStateAccessAvailable)
            {
                gl.BindTexture(gl.GL_TEXTURE_2D, oldGL_TEXTURE_BINDING_2D);
                gl.ThrowIfError();

                GL_TEXTURE_BINDING_2D.Update(oldGL_TEXTURE_BINDING_2D);
                glTextureBinding2DByTextureUnit[GL_ACTIVE_TEXTURE] = oldGL_TEXTURE_BINDING_2D;
            }
        }
Exemplo n.º 4
0
        private void Dispose_ActiveTexture()
        {
            gl.ActiveTexture(oldGL_ACTIVE_TEXTURE);
            gl.ThrowIfError();

            var tb2d = 0u;

            glTextureBinding2DByTextureUnit.TryGetValue(oldGL_ACTIVE_TEXTURE, out tb2d);

            OpenGLState.GL_ACTIVE_TEXTURE.Update(oldGL_ACTIVE_TEXTURE);
            GL_TEXTURE_BINDING_2D.Update(tb2d);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Immediately sets the active texture unit and updates the state cache.
        /// </summary>
        /// <param name="texture">The texture unit to activate.</param>
        public static void ActiveTexture(UInt32 texture)
        {
            gl.ActiveTexture(texture);
            gl.ThrowIfError();

            var tb2d = 0u;

            glTextureBinding2DByTextureUnit.TryGetValue(texture, out tb2d);

            GL_ACTIVE_TEXTURE.Update(texture);
            GL_TEXTURE_BINDING_2D.Update(tb2d);

            VerifyCache();
        }
Exemplo n.º 6
0
        private void Apply_CreateTexture2D(out UInt32 texture)
        {
            if (SupportsDirectStateAccessCreateFunctions)
            {
                texture = gl.CreateTexture(gl.GL_TEXTURE_2D);
                gl.ThrowIfError();
            }
            else
            {
                texture = gl.GenTexture();
                gl.ThrowIfError();

                if (!gl.IsDirectStateAccessAvailable)
                {
                    gl.BindTexture(gl.GL_TEXTURE_2D, texture);
                    gl.ThrowIfError();

                    newGL_TEXTURE_BINDING_2D = texture;
                    oldGL_TEXTURE_BINDING_2D = GL_TEXTURE_BINDING_2D.Update(texture);
                    glTextureBinding2DByTextureUnit[GL_ACTIVE_TEXTURE] = texture;
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Immediately creates a 2D texture and updates the state cache.
        /// </summary>
        /// <param name="texture">The identifier of the texture that was created.</param>
        public static void CreateTexture2D(out UInt32 texture)
        {
            if (SupportsDirectStateAccessCreateFunctions)
            {
                texture = gl.CreateTexture(gl.GL_TEXTURE_2D);
                gl.ThrowIfError();
            }
            else
            {
                texture = gl.GenTexture();
                gl.ThrowIfError();

                if (!gl.IsDirectStateAccessAvailable)
                {
                    gl.BindTexture(gl.GL_TEXTURE_2D, texture);
                    gl.ThrowIfError();

                    GL_TEXTURE_BINDING_2D.Update(texture);
                    glTextureBinding2DByTextureUnit[GL_ACTIVE_TEXTURE] = texture;

                    VerifyCache();
                }
            }
        }