public override DeviceTexture2D CreateTexture(IntPtr pixelData, int width, int height, int pixelSizeInBytes, PixelFormat format) { D3DTexture2D texture = new D3DTexture2D( _device, BindFlags.ShaderResource, ResourceUsage.Default, CpuAccessFlags.None, D3DFormats.ConvertPixelFormat(format), pixelData, width, height, width * pixelSizeInBytes); return(texture); }
public override DeviceTexture2D CreateTexture <T>(T[] pixelData, int width, int height, int pixelSizeInBytes, PixelFormat format) { GCHandle handle = GCHandle.Alloc(pixelData, GCHandleType.Pinned); D3DTexture2D texture = new D3DTexture2D( _device, BindFlags.ShaderResource, ResourceUsage.Default, CpuAccessFlags.None, D3DFormats.ConvertPixelFormat(format), handle.AddrOfPinnedObject(), width, height, width * pixelSizeInBytes); handle.Free(); return(texture); }
public D3DCubemapTexture( Device device, IntPtr pixelsFront, IntPtr pixelsBack, IntPtr pixelsLeft, IntPtr pixelsRight, IntPtr pixelsTop, IntPtr pixelsBottom, int width, int height, int pixelSizeInBytes, PixelFormat format) { Width = width; Height = height; int stride = width * pixelSizeInBytes; DataRectangle[] dataRectangles = new DataRectangle[] { new DataRectangle(pixelsRight, stride), new DataRectangle(pixelsLeft, stride), new DataRectangle(pixelsTop, stride), new DataRectangle(pixelsBottom, stride), new DataRectangle(pixelsBack, stride), new DataRectangle(pixelsFront, stride), }; DeviceTexture = new Texture2D( device, new Texture2DDescription() { Format = D3DFormats.ConvertPixelFormat(format), ArraySize = 6, MipLevels = 1, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.ShaderResource, Width = width, Height = height, OptionFlags = ResourceOptionFlags.TextureCube }, dataRectangles); }