public Texture Load(string path) { ValidatePath(path); int textureHandle = adapter.GenTexture(); adapter.Bind(TextureTarget.Texture2D, textureHandle); SetTextureParameters(); using (var image = new Bitmap(Bitmap.FromFile(path))) { var data = new byte[image.Width * image.Height * 4]; var bitmapData = image.LockBits( new Rectangle(0, 0, image.Width, image.Height), Imaging.ImageLockMode.ReadOnly, Imaging.PixelFormat.Format32bppArgb ); Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); adapter.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bitmapData.Width, bitmapData.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bitmapData.Scan0 ); image.UnlockBits(bitmapData); var texture = new Texture(adapter, textureHandle, image.Width, image.Height, data); return texture; } }
public void SetUp() { adapter = new Mock<ITextureAdapter>(); texture = new Texture(adapter.Object, handle, width, height, data); /* We don't want the texture finalizer to run without an OpenGL context * Otherwise the tests will fail. We are using a mock here so no memory leaks */ //GC.SuppressFinalize(texture); }