diff options
| author | jp <jp_bruyere@hotmail.com> | 2016-07-23 16:50:32 +0200 |
|---|---|---|
| committer | jp <jp_bruyere@hotmail.com> | 2016-07-23 16:50:32 +0200 |
| commit | 216fa1608767774b0db1d31551dfee25fcbcddbd (patch) | |
| tree | e9c3517271ae5c9ddf370f5bf372b53c1b2ca137 /Tests/OpenGL | |
| parent | 7164e3fd70dc2401c6b325e4ddda4755332c00f6 (diff) | |
implement Crow.LoadFromStream and filenotfound catch
modifié : Tests/OpenGL/Texture.cs
debug window resize bugs
modifié : src/GraphicObjects/GraphicObject.cs
modifié : src/GraphicObjects/Window.cs
Diffstat (limited to 'Tests/OpenGL')
| -rw-r--r-- | Tests/OpenGL/Texture.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Tests/OpenGL/Texture.cs b/Tests/OpenGL/Texture.cs index 5e3a350a..ce24808b 100644 --- a/Tests/OpenGL/Texture.cs +++ b/Tests/OpenGL/Texture.cs @@ -37,30 +37,31 @@ namespace Crow public Texture(string _mapPath, bool flipY = true) { - if (!File.Exists (_mapPath)) - throw new FileNotFoundException ("Texture not found", _mapPath); - try { - Map = _mapPath; + using (Stream s = Interface.GetStreamFromPath (_mapPath)) { - Bitmap bitmap = new Bitmap(_mapPath); + try { + Map = _mapPath; - if(flipY) - bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); + Bitmap bitmap = new Bitmap (s); - BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), - ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + if (flipY) + bitmap.RotateFlip (RotateFlipType.RotateNoneFlipY); - createTexture (data.Scan0, data.Width, data.Height); + BitmapData data = bitmap.LockBits (new System.Drawing.Rectangle (0, 0, bitmap.Width, bitmap.Height), + ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - bitmap.UnlockBits(data); + createTexture (data.Scan0, data.Width, data.Height); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); - GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); + bitmap.UnlockBits (data); - GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); + GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); - } catch (Exception ex) { - Debug.WriteLine ("Error loading texture: " + Map + ":" + ex.Message); + GL.GenerateMipmap (GenerateMipmapTarget.Texture2D); + + } catch (Exception ex) { + Debug.WriteLine ("Error loading texture: " + Map + ":" + ex.Message); + } } } |