private void ImportTexture(ITexture tex, string file, GliFormat imgOriginalFormat)
 {
     try
     {
         models.Images.AddImage(tex, file, imgOriginalFormat);
         tex = null; // images is now owner
     }
     catch (ImagesModel.MipmapMismatch e)
     {
         // silently generate mipmaps and import
         if (models.Images.NumMipmaps > 1 && tex.NumMipmaps == 1)
         {
             var tmp = tex.GenerateMipmapLevels(models.Images.NumMipmaps);
             ImportTexture(tmp, file, imgOriginalFormat);
         }
         else
         {
             // don't just discard the mipmaps
             models.Window.ShowErrorDialog(e.Message);
         }
     }
     catch (Exception e)
     {
         models.Window.ShowErrorDialog(e.Message);
     }
     finally
     {
         tex?.Dispose();
     }
 }
예제 #2
0
파일: GBuffer.cs 프로젝트: deccer/Xacor
 public void Dispose()
 {
     _buffer1.Dispose();
     _buffer2.Dispose();
     _buffer3.Dispose();
     _depthBuffer.Dispose();
 }
예제 #3
0
 public void Dispose()
 {
     if (texture != null)
     {
         texture.Dispose();
     }
 }
예제 #4
0
        /// <summary>
        /// Performs texture disposal, deleting the texture.
        /// </summary>
        private void DisposeTextures()
        {
            HostTexture.Dispose();

            _arrayViewTexture?.Dispose();
            _arrayViewTexture = null;
        }
예제 #5
0
 public override void OnDestroy()
 {
     base.OnDestroy();
     if (!isCached)
     {
         texture?.Dispose();
     }
 }
예제 #6
0
 public void Dispose()
 {
     overlayTex?.Dispose();
     blendState?.Dispose();
     foreach (var overlay in Overlays)
     {
         overlay.Dispose();
     }
 }
예제 #7
0
파일: Texture.cs 프로젝트: vsear/Ryujinx
        /// <summary>
        /// Performs texture disposal, deleting the texture.
        /// </summary>
        private void DisposeTextures()
        {
            HostTexture.Dispose();

            _arrayViewTexture?.Dispose();
            _arrayViewTexture = null;

            Disposed?.Invoke(this);
        }
예제 #8
0
 public void UpdateLightmapTexture()
 {
     lock (Lightmaps) {
         string texName = LightmapTexture.Name;
         LightmapTexture.Dispose();
         LightmapTexture         = TextureHelper.Create(texName, Lightmaps[3], Lightmaps[3].Width, Lightmaps[3].Height, TextureFlags.None);
         LightmapTextureOutdated = false;
     }
 }
예제 #9
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && !this._disposedValue)
     {
         _test_texture.Dispose();
         _test_vao.Dispose();
         _test_prog.Dispose();
         this._disposedValue = true;
     }
     base.Dispose(disposing);
 }
예제 #10
0
 /// <summary>
 /// Destroy this texture instance.
 /// </summary>
 public void Destroy()
 {
     if (_ceTex != null && _texId != 0)
     {
         var id = _texId;
         GameFramework.AddDestroyAction(() => DestroyNativeTexture(id));
         _ceTex.Dispose();
         _ceTex = null;
         _texId = 0;
     }
 }
예제 #11
0
 private void OnDestroy()
 {
     if (texturePromise != null)
     {
         AssetPromiseKeeper_Texture.i.Forget(texturePromise);
         texturePromise = null;
     }
     else
     {
         imageAsset?.Dispose();
     }
 }
예제 #12
0
 /// <summary>
 /// Destroy this texture instance.
 /// </summary>
 public void Destroy()
 {
     if (_nativeTexture != null && _texId != 0)
     {
         var id             = _texId;
         var isRenderTarget = _isRenderTarget;
         GameFramework.AddDestroyAction(() => DestroyNativeTexture(id, isRenderTarget));
         _nativeTexture.Dispose();
         _nativeTexture = null;
         _texId         = 0;
     }
 }
예제 #13
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _shader.Dispose();
                    _texture.Dispose();
                }

                disposedValue = true;
            }
        }
예제 #14
0
        void updateTexture()
        {
            int newLength = colorIndices.Count;

            if (newLength <= (textureRows << 8))
            {
                // Still writing the same row
                updateRange(writtenColorsCount, colorIndices.Count);
                writtenColorsCount = colorIndices.Count;
                return;
            }

            // Filled a row, resize the texture
            int capacity = textureRows << 8;

            if (writtenColorsCount != capacity)
            {
                updateRange(writtenColorsCount, capacity);
                writtenColorsCount = capacity;
            }

            int      newHeight = (newLength >> 8) + 1;
            ITexture newTexture;

            using (var dev = context.device)
            {
                var desc = textureDesc(newHeight);
                newTexture = dev.CreateTexture(ref desc, "Palette");
            }

            context.context.copyTexture(newTexture, texture);
            texture.Dispose();
            m_textureView.Dispose();
            texture       = newTexture;
            m_textureView = newTexture.GetDefaultView(TextureViewType.ShaderResource);

            while (newLength >= writtenColorsCount + 0x100)
            {
                int lineEnd = writtenColorsCount + 0x100;
                updateRange(writtenColorsCount, lineEnd);
                writtenColorsCount = lineEnd;
            }

            updateRange(writtenColorsCount, newLength);
            writtenColorsCount = newLength;

            foreach (var sub in textureResized)
            {
                sub();
            }
        }
예제 #15
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && !_disposed)
     {
         _light_ssbo.Dispose();
         _mvp_ssbo.Dispose();
         _cube_vao.Dispose();
         _texture.Dispose();
         _normalmap.Dispose();
         _displacementmap.Dispose();
         _parallax_prog.Dispose();
         _disposed = true;
     }
 }
 public void StoreTexture(ITexture tex)
 {
     Debug.Assert(tex != null);
     if (IsCompatibleWith(tex))
     {
         // can be used for later
         textures.Push(tex);
     }
     else
     {
         // immediately discard (incompatible image)
         tex.Dispose();
     }
 }
예제 #17
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;
            texture.Dispose();

            OpenGL.glDeleteFramebuffers(1, ref framebuffer);
            OpenGL.CheckGLError();
            OpenGL.glDeleteRenderbuffers(1, ref depth);
            OpenGL.CheckGLError();
        }
예제 #18
0
 /// <summary>
 /// 保持しているフォントを解放する。
 /// </summary>
 public void Release()
 {
     if (fonts != null)
     {
         //	明示的に解放しておくか..
         for (int i = 0; i < fonts.Count; ++i)
         {
             ITexture t = fonts[i].Texture;
             if (t != null)
             {
                 t.Dispose();
             }
         }
         fonts.Clear();
     }
 }
예제 #19
0
 /// <summary>
 /// Dispose Scenario elements.
 /// </summary>
 public void Dispose()
 {
     try
     {
         BackGround.texture.Dispose();
         Ballon.texture.Dispose();
         txuUperBallon.Dispose();
         txuDownerBallon.Dispose();
         Bough.texture.Dispose();
         for (int i = 0; i < BirdsList.Count; i++)
         {
             BirdsList[i].texture.Dispose();
         }
         BirdsList.Clear();
     }
     catch { }
 }
예제 #20
0
        /// <summary>
        /// Dispose Scenario elements.
        /// </summary>
        public void Dispose()
        {
            try
            {
                BackGround.texture.Dispose();
                Apple.texture.Dispose();
                Boy.texture.Dispose();
                BoySadTexture.Dispose();
                BoyHappyTexture.Dispose();
                BoySuccessTexture.Dispose();
                BoyHand.texture.Dispose();

                for (int i = 0; i < BirdsList.Count; i++)
                {
                    BirdsList[i].texture.Dispose();
                }
                BirdsList.Clear();
            }
            catch { }
        }
예제 #21
0
파일: Sheet.cs 프로젝트: zredb/OpenRA
 public void Dispose()
 {
     texture?.Dispose();
 }
 public void EndDrawMeshToImage()
 {
     //dispose OpenGL resources
     GL.DeleteFramebuffers(1, frameBuffersForDrawMesh);
     textureForDrawMesh.Dispose();
 }
예제 #23
0
        /// <summary>
        /// creates a thumbnail for one image layer/mipmap
        /// </summary>
        /// <param name="size">maximum width/height of the thumbnail</param>
        /// <param name="texture">source texture</param>
        /// <param name="dstFormat">destination texture format</param>
        /// <param name="layer">source layer</param>
        /// <returns>texture with width, height smaller or equal to size. One layer and one mipmap</returns>
        public TextureArray2D CreateThumbnail(int size, ITexture texture,
                                              SharpDX.DXGI.Format dstFormat, int layer, ScalingModel scaling)
        {
            Debug.Assert(ImageFormat.IsSupported(dstFormat));
            Debug.Assert(ImageFormat.IsSupported(texture.Format));

            // determine dimensions of output texture
            var width  = 0;
            var height = 0;

            if (texture.Size.Width > texture.Size.Height)
            {
                width  = size;
                height = (texture.Size.Height * size) / texture.Size.Width;
            }
            else
            {
                height = size;
                width  = (texture.Size.Width * size) / texture.Size.Height;
            }
            Debug.Assert(width <= size);
            Debug.Assert(height <= size);

            var res = new TextureArray2D(LayerMipmapCount.One, new Size3(width, height), dstFormat, false);

            // compute which mipmap has the closest fit
            var mipmap   = 0;
            var curWidth = texture.Size.Width;

            while (curWidth >= width)
            {
                ++mipmap;
                curWidth /= 2;
            }
            // mipmap just jumped over the optimal size
            mipmap = Math.Max(0, mipmap - 1);

            var      dev    = Device.Get();
            ITexture tmpTex = null;

            if (texture.NumMipmaps < mipmap + 1)
            {
                // generate new texture with mipmaps
                tmpTex = texture.CloneWithMipmaps(mipmap + 1);

                scaling.WriteMipmaps(tmpTex);
                dev.Pixel.SetShaderResource(0, tmpTex.GetSrView(new LayerMipmapSlice(layer, mipmap)));
            }
            else
            {
                dev.Pixel.SetShaderResource(0, texture.GetSrView(new LayerMipmapSlice(layer, mipmap)));
            }

            quad.Bind(false);
            if (texture.Is3D)
            {
                dev.Pixel.Set(convert3D.Pixel);
            }
            else
            {
                dev.Pixel.Set(convert2D.Pixel);
            }

            dev.Pixel.SetSampler(0, sampler);

            dev.OutputMerger.SetRenderTargets(res.GetRtView(LayerMipmapSlice.Mip0));
            dev.SetViewScissors(width, height);
            dev.DrawFullscreenTriangle(1);

            // remove bindings
            dev.Pixel.SetShaderResource(0, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();

            tmpTex?.Dispose();

            return(res);
        }
예제 #24
0
 public void Dispose()
 {
     blenderBinding?.Dispose();
     targetView?.Dispose();
     texture?.Dispose();
 }
예제 #25
0
 /// <summary>Unload and dispose of any assets. Remember to dispose SDL-native objects!
 /// </summary>
 private void UnloadContent()
 {
     textureGitLogo.Dispose();
     textureVisualStudioLogo.Dispose();
 }
예제 #26
0
파일: Textures.cs 프로젝트: zeta1999/Vrmac
 public void finalize()
 {
     view?.Dispose();
     texture?.Dispose();
 }
예제 #27
0
        /// <summary>
        /// GetTexture/GetTextureSolid用のhelper
        /// </summary>
        /// <remarks>
        /// isBlendedの値に応じて、DrawBlendedUnicodeとDrawTextureSolidとを切り替えて描画する。
        /// </remarks>
        /// <param name="letter"></param>
        /// <param name="style"></param>
        /// <param name="isBlended"></param>
        /// <returns></returns>
        private ITexture GetTextureHelper(char letter, int style, bool isBlended)
        {
            if (loader == null)
            {
                return(null);                     // うんこーヽ(`Д´)ノ
            }
            int index = int.MaxValue;             // fail safe

            //	探してみる
            for (int i = 0; i < fonts.Count; ++i)
            {
                if ((fonts[i].Letter == letter) &&
                    (fonts[i].Style == style) &&
                    (fonts[i].FontLoader == loader) &&
                    (fonts[i].FontNo == fontNo))
                {
                    //	みっけ!
                    index = i;
                    goto Exit;
                }
            }

            // 見つからなかったので生成してみる

            ITexture texture = factory();

            if (texture == null)
            {
                return(null);                // factory設定されとらん(´ω`)
            }
            Font font = loader.GetFont(fontNo);

            if (font != null)
            {
                Surface surface =
                    isBlended
                                        ? font.DrawBlendedUnicode(letter.ToString())
                                        : font.DrawSolidUnicode(letter.ToString());
                texture.SetSurface(surface);
                surface.Dispose();                 // 解放しとかなきゃ
            }
            else
            {
                // なんやー。読み込まれへんかったわ
                return(null);               // 生成失敗
            }

            // 生成できた。次に空き場所を確定させる

            if (fonts.Count == max)
            {
                //	場所が空いてないので、一番最後に参照された
                //	オブジェクトを解放する
                long t = long.MaxValue;
                for (int i = 0; i < fonts.Count; ++i)
                {
                    if (fonts[i].LastAccessTime < t)
                    {
                        t     = fonts[i].LastAccessTime;
                        index = i;
                    }
                }
                ITexture tt = fonts[index].Texture;
                if (tt != null)
                {
                    tt.Dispose();                     // 一応解放しておく
                }
            }
            else
            {
                index = fonts.Count;
                fonts.Add(new Info());                 // ひとつ確保
            }

            // このlocal copy、最適化で消えるやろか?
            Info info = new Info();

            info.Letter     = letter;
            info.FontLoader = loader;
            info.FontNo     = fontNo;
            info.Style      = style;
            info.Texture    = texture;

            fonts[index] = info;

Exit:
            //	これ参照したので、時刻をずらしておく。
            fonts[index].LastAccessTime = ++time;
            return(fonts[index].Texture);
        }
예제 #28
0
 public static void UnloadTexture(ITexture texture)
 {
     _disposables.TryRemove(texture.FileName, out _);
     texture.Dispose();
 }
예제 #29
0
 public static void UnloadTexture(ITexture texture)
 {
     GL.DeleteTexture(texture.TextureHash);
     texture.Dispose();
 }