Ejemplo n.º 1
0
        private void TextureChanged(object sender, TextureEventArgs textureDataEventArgs)
        {
            if (!_identifierToTextureHandleDictionary.TryGetValue(textureDataEventArgs.Texture.SessionUniqueIdentifier,
                                                                  out ITextureHandle toBeUpdatedTextureHandle))
            {
                throw new KeyNotFoundException("Texture is not registered.");
            }

            ITextureBase texture = textureDataEventArgs.Texture;

            switch (textureDataEventArgs.ChangedEnum)
            {
            case TextureChangedEnum.Disposed:
                // Add the TextureHandle to the toBeDeleted Stack...
                _toBeDeletedTextureHandles.Push(toBeUpdatedTextureHandle);
                // remove the TextureHandle from the dictionary, the TextureHandle data now only resides inside the gpu and will be cleaned up on bottom of Render(Mesh mesh)
                _identifierToTextureHandleDictionary.Remove(texture.SessionUniqueIdentifier);
                // add the identifier to the reusable identifiers stack
                //_reusableIdentifiers.Push(textureDataEventArgs.Texture.Identifier);
                break;

            case TextureChangedEnum.RegionChanged:
                //TODO: An IWritableTexture has no implementation of UpdateTextureRegion (yet)
                if (texture is ITexture iTexture)
                {
                    _renderContextImp.UpdateTextureRegion(toBeUpdatedTextureHandle, iTexture,
                                                          textureDataEventArgs.XStart, textureDataEventArgs.YStart, textureDataEventArgs.Width,
                                                          textureDataEventArgs.Height);
                }
                break;
            }
        }