Exemple #1
0
        public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
        {
            //note - this is dangerous since it changes the bound texture. could we save it?
            BindTexture2d(tex);
            var bb      = new BitmapBuffer(tex.IntWidth, tex.IntHeight);
            var bmpdata = bb.LockBits();

            GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpdata.Scan0);
            var err = GL.GetError();

            bb.UnlockBits(bmpdata);
            return(bb);
        }
Exemple #2
0
 public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
 {
     sdi.BitmapData bmp_data = bmp.LockBits();
     try
     {
         GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
         GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmp.Width, bmp.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
     }
     finally
     {
         bmp.UnlockBits(bmp_data);
     }
 }
Exemple #3
0
		public unsafe void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
		{
			sdi.BitmapData bmp_data = bmp.LockBits();
			var tw = tex.Opaque as TextureWrapper;
			var dr = tw.Texture.LockRectangle(0, LockFlags.None);

			//TODO - do we need to handle odd sizes, weird pitches here?
			if (bmp.Width * 4 != bmp_data.Stride)
				throw new InvalidOperationException();

			dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height * 4);
			dr.Data.Close();

			tw.Texture.UnlockRectangle(0);
			bmp.UnlockBits(bmp_data);
		}
Exemple #4
0
		public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
		{
			//note - this is dangerous since it changes the bound texture. could we save it?
			BindTexture2d(tex);
			var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight);
			var bmpdata = bb.LockBits();
			GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpdata.Scan0);
			var err = GL.GetError();
			bb.UnlockBits(bmpdata);
			return bb;
		}
Exemple #5
0
		public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
		{
			sdi.BitmapData bmp_data = bmp.LockBits();
			try
			{
				GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
				GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmp.Width, bmp.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
			}
			finally
			{
				bmp.UnlockBits(bmp_data);
			}
		}
Exemple #6
0
        public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
        {
            sdi.BitmapData bmp_data = bmp.LockBits();
            d3d9.Texture dtex = tex.Opaque as d3d9.Texture;
            var dr = dtex.LockRectangle(0, LockFlags.None);

            //TODO - do we need to handle odd sizes, weird pitches here?
            dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height);
            dtex.UnlockRectangle(0);
            bmp.UnlockBits(bmp_data);
        }