Exemplo n.º 1
0
        public override void PrepareRender()
        {
            VerifyThreadAffinity();
            OpenGL.glUseProgram(program);
            OpenGL.CheckGLError();

            // bind the textures
            foreach (var kv in textures)
            {
                if ((kv.Value as Texture).disposed)
                {
                    continue;                     // on world restart some Textures can be Disposed. But assigned to Shader.
                    // TODO: On Dispose Texture from Sheets need to add Clear textures on Shaders
                }
                OpenGL.glActiveTexture(OpenGL.GL_TEXTURE0 + kv.Key);
                OpenGL.CheckGLError();

                if ((kv.Value as Texture).TextureType == OpenGL.GL_TEXTURE_2D_ARRAY)
                {
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D_ARRAY, ((ITextureInternal)kv.Value).ID);
                    OpenGL.CheckGLError();
                }
                else
                {
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, ((ITextureInternal)kv.Value).ID);
                    OpenGL.CheckGLError();
                }
            }

            OpenGL.CheckGLError();
        }
Exemplo n.º 2
0
        public void PrepareRender()
        {
            VerifyThreadAffinity();
            OpenGL.glUseProgram(program);
            OpenGL.CheckGLError();

            // bind the textures
            foreach (var kv in textures)
            {
                var id = ((ITextureInternal)kv.Value).ID;

                // Evict disposed textures from the cache
                if (OpenGL.glIsTexture(id))
                {
                    OpenGL.glActiveTexture(OpenGL.GL_TEXTURE0 + kv.Key);
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, id);
                }
                else
                {
                    unbindTextures.Enqueue(kv.Key);
                }
            }

            while (unbindTextures.Count > 0)
            {
                textures.Remove(unbindTextures.Dequeue());
            }

            OpenGL.CheckGLError();
        }
Exemplo n.º 3
0
        public void PrepareRender()
        {
            VerifyThreadAffinity();
            OpenGL.glUseProgram(program);

            // bind the textures
            foreach (var kv in textures)
            {
                OpenGL.glActiveTexture(OpenGL.GL_TEXTURE0 + kv.Key);
                OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, ((ITextureInternal)kv.Value).ID);
            }

            OpenGL.CheckGLError();
        }
Exemplo n.º 4
0
        public void PrepareRender()
        {
            VerifyThreadAffinity();
            OpenGL.glUseProgram(program);
            OpenGL.CheckGLError();

            // bind the textures
            foreach (var kv in textures)
            {
                var texture = (ITextureInternal)kv.Value;

                // Evict disposed textures from the cache
                if (OpenGL.glIsTexture(texture.ID))
                {
                    OpenGL.glActiveTexture(OpenGL.GL_TEXTURE0 + kv.Key);
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, texture.ID);

                    // Work around missing textureSize GLSL function by explicitly tracking sizes in a uniform
                    int param;
                    if (OpenGL.Profile == GLProfile.Legacy && legacySizeUniforms.TryGetValue(kv.Key, out param))
                    {
                        OpenGL.glUniform2f(param, texture.Size.Width, texture.Size.Height);
                        OpenGL.CheckGLError();
                    }
                }
                else
                {
                    unbindTextures.Enqueue(kv.Key);
                }
            }

            while (unbindTextures.Count > 0)
            {
                textures.Remove(unbindTextures.Dequeue());
            }

            OpenGL.CheckGLError();
        }