public Renderer.Texture2D CreateTextureCube(Renderer.Device _Device) { if (m_Opts.m_type != ImageOptions.TYPE.TT_CUBIC) { throw new Exception("The image is not a cube map texture!"); } ImageUtility.PIXEL_FORMAT textureFormat = ImageUtility.PIXEL_FORMAT.UNKNOWN; ImageUtility.COMPONENT_FORMAT componentFormat; m_Opts.m_format.GetEquivalentRendererFormat(out textureFormat, out componentFormat); uint ArraySize = 6 * m_Opts.m_arraySize; uint MipsCount = m_Opts.m_curNumLevels; uint PixelSize = m_Opts.m_format.BitsCount >> 3; List <Renderer.PixelsBuffer> Content = new List <Renderer.PixelsBuffer>(); for (uint SliceIndex = 0; SliceIndex < ArraySize; SliceIndex++) { for (uint MipLevelIndex = 0; MipLevelIndex < MipsCount; MipLevelIndex++) { ImageSlice Slice = m_Slices[MipLevelIndex * ArraySize + SliceIndex]; // Stupidly stored in reverse order! Renderer.PixelsBuffer Pixels = new Renderer.PixelsBuffer((uint)(Slice.m_Width * Slice.m_Height * PixelSize)); Content.Add(Pixels); using (BinaryWriter Writer = Pixels.OpenStreamWrite()) Writer.Write(Slice.m_Content); } } Renderer.Texture2D Result = new Renderer.Texture2D(_Device, m_Opts.m_curWidth, m_Opts.m_curHeight, -6 * (int)m_Opts.m_arraySize, m_Opts.m_curNumLevels, textureFormat, componentFormat, false, false, Content.ToArray()); return(Result); }
public Renderer.Texture3D CreateTexture3D(Renderer.Device _Device) { if (m_Opts.m_type != ImageOptions.TYPE.TT_3D) { throw new Exception("The image is not a 2D texture!"); } throw new Exception("Texture 3D are not supported yet!"); }