Beispiel #1
0
        public Texture(string _mapPath, bool flipY = true)
        {
            using (Stream s = Interface.StaticGetStreamFromPath(_mapPath)) {
                try {
                    Map = _mapPath;

                    Bitmap bitmap = new Bitmap(s);

                    if (flipY)
                    {
                        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }

                    BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                                      ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    createTexture(data.Scan0, data.Width, data.Height);

                    bitmap.UnlockBits(data);

                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
                    GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

                    GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                } catch (Exception ex) {
                    Debug.WriteLine("Error loading texture: " + Map + ":" + ex.Message);
                }
            }
        }