private void writeFacePixels(CubeMapFace face, byte[] pixels, int width, int height) { byte[] pixelsWithAlpha = new byte[width * height * 4]; for (int i = 0; i < width * height; i++) { pixelsWithAlpha[i * 4 + 0] = pixels[i * 4 + 2]; pixelsWithAlpha[i * 4 + 1] = pixels[i * 4 + 1]; pixelsWithAlpha[i * 4 + 2] = pixels[i * 4 + 0]; pixelsWithAlpha[i * 4 + 3] = pixels[i * 4 + 3]; } SharpDX.DataStream stream; SharpDX.DataRectangle r = _cubeMap.LockRectangle(face, 0, LockFlags.None, out stream); Direct3D9Texture.WritePixelsToTextureDataStream(stream, pixelsWithAlpha, width, height); _cubeMap.UnlockRectangle(face, 0); }
public override void Update(byte[] pixels) { if (pixels.Length != _width * _height * 4) { throw new ArgumentException("Pixel array is not the expected length"); } // need to swap the R and B components for (int i = 0; i < _width * _height; i++) { byte temp = pixels[i * 4 + 0]; pixels[i * 4 + 0] = pixels[i * 4 + 2]; pixels[i * 4 + 2] = temp; } Surface s = _texture.GetSurfaceLevel(0); SharpDX.DataStream stream; SharpDX.DataRectangle r = s.LockRectangle(LockFlags.None, out stream); Direct3D9Texture.WritePixelsToTextureDataStream(stream, pixels, _width, _height); s.UnlockRectangle(); }