Beispiel #1
0
        public static Texture GetTexture(string id)
        {
            Texture tex;

            if (!texCache.TryGetValue(id, out tex))
            {
                Bitmap image = new Bitmap(id + ".jpg");
                BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
                    ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                tex = new Texture();
                tex.Bind(true);
                GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, image.Width, image.Height,
                    0, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, data.Scan0);
                image.UnlockBits(data);

                tex.Bind(false);
                texCache[id] = tex;
            }

            return tex;
        }
Beispiel #2
0
 public void AddOverlay(Texture tex)
 {
     overlays.Add(tex);
 }