Exemple #1
0
        /// <summary>
        /// Creates a texture array.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <param name="request">The request.</param>
        private void Create(TexImage array, ArrayCreationRequest request)
        {
            array.Width            = request.TextureList[0].Width;
            array.Height           = request.TextureList[0].Height;
            array.Depth            = request.TextureList[0].Depth;
            array.RowPitch         = request.TextureList[0].RowPitch;
            array.SlicePitch       = request.TextureList[0].SlicePitch;
            array.Format           = request.TextureList[0].Format;
            array.FaceCount        = request.TextureList[0].FaceCount;
            array.MipmapCount      = request.TextureList[0].MipmapCount;
            array.DisposingLibrary = this;

            array.Name      = request.TextureList[0].Name + "_array";
            array.ArraySize = request.TextureList.Count;

            array.SubImageArray = new TexImage.SubImage[request.TextureList.Count * request.TextureList[0].SubImageArray.Length];

            array.DataSize = 0;
            array.DataSize = request.TextureList[0].DataSize * array.ArraySize;

            array.Data = Marshal.AllocHGlobal(array.DataSize);

            int      offset1, offset2;
            long     arrayData = array.Data.ToInt64();
            long     currentData;
            IntPtr   buffer;
            TexImage current;

            offset1 = 0;
            for (int i = 0; i < request.TextureList.Count; ++i)
            {
                current  = request.TextureList[i];
                buffer   = new IntPtr(arrayData + offset1);
                offset1 += current.DataSize;
                Utilities.CopyMemory(buffer, current.Data, current.DataSize);

                offset2     = 0;
                currentData = buffer.ToInt64();
                for (int j = 0; j < current.SubImageArray.Length; ++j)
                {
                    array.SubImageArray[i * current.SubImageArray.Length + j]      = current.SubImageArray[j];
                    array.SubImageArray[i * current.SubImageArray.Length + j].Data = new IntPtr(currentData + offset2);
                    offset2 += current.SubImageArray[j].DataSize;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a texture array.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <param name="request">The request.</param>
        private void CreateArray(TexImage array, ArrayCreationRequest request)
        {
            Log.Info("Creating texture array ...");

            Create(array, request);
        }