Ejemplo n.º 1
0
        private MipMapChain CreateMipMapChain(ImageID imageID, int imageNum, int faceNum)
        {
            IL.BindImage(imageID);
            if (!IL.ActiveImage(imageNum))
            {
                return(null);
            }
            if (!IL.ActiveFace(faceNum))
            {
                return(null);
            }

            //Get total number of mipmaps (including base face)
            int         mipMapCount = IL.ilGetInteger(ILDefines.IL_NUM_MIPMAPS) + 1;
            MipMapChain mipMapChain = new MipMapChain();

            //Get the first mipmap and every other, when we hit a null, we break
            for (int i = 0; i < mipMapCount; i++)
            {
                ImageData data = ImageData.Load(new Subimage(imageID, imageNum, faceNum, 0, i));
                if (data == null)
                {
                    break;
                }
                mipMapChain.Add(data);
            }
            mipMapChain.TrimExcess();
            return(mipMapChain);
        }
Ejemplo n.º 2
0
        private MipMapChain CreateMipMapChain(ImageID imageID, int imageNum, int faceNum)
        {
            IL.BindImage(imageID);
            if (!IL.ActiveImage(imageNum))
            {
                return((MipMapChain)null);
            }
            if (!IL.ActiveFace(faceNum))
            {
                return((MipMapChain)null);
            }
            int         num         = IL.ilGetInteger(3570U) + 1;
            MipMapChain mipMapChain = new MipMapChain();

            for (int mipMapIndex = 0; mipMapIndex < num; ++mipMapIndex)
            {
                ImageData imageData = ImageData.Load(new Subimage(imageID, imageNum, faceNum, 0, mipMapIndex));
                if (imageData != null)
                {
                    mipMapChain.Add(imageData);
                }
                else
                {
                    break;
                }
            }
            mipMapChain.TrimExcess();
            return(mipMapChain);
        }
Ejemplo n.º 3
0
        private Texture1D CreateTexture1D(MipMapChain mipMapChain)
        {
            ImageData mip0 = mipMapChain[0];
            Texture1D tex  = new Texture1D(mip0.Width, (mipMapChain.Count > 1), GetSurfaceFormat(mip0));

            for (int i = 0; i < mipMapChain.Count; i++)
            {
                ImageData mip  = mipMapChain[i];
                byte[]    data = (mip.HasCompressedData) ? mip.CompressedData : mip.Data;
                tex.SetData <byte>(data, i, 0, mip.Width, 0, data.Length);
            }
            return(tex);
        }
Ejemplo n.º 4
0
        private void LoadFaces(ImageID imageID, int imageNum)
        {
            IL.BindImage(imageID);
            if (!IL.ActiveImage(imageNum))
            {
                return;
            }
            int num = IL.ilGetInteger(3553U) + 1;

            for (int faceNum = 0; faceNum < num; ++faceNum)
            {
                MipMapChain mipMapChain = this.CreateMipMapChain(imageID, imageNum, faceNum);
                if (mipMapChain == null)
                {
                    break;
                }
                this.m_faces.Add(mipMapChain);
            }
        }
Ejemplo n.º 5
0
        private void LoadFaces(ImageID imageID, int imageNum)
        {
            IL.BindImage(imageID);
            if (!IL.ActiveImage(imageNum))
            {
                return;
            }

            //Get total number of faces (including base face)
            int faceCount = IL.ilGetInteger(ILDefines.IL_NUM_FACES) + 1;

            //Get the first face and every other as a mip map chain, when we hit a null, we break
            for (int i = 0; i < faceCount; i++)
            {
                MipMapChain mipMapChain = CreateMipMapChain(imageID, imageNum, i);
                if (mipMapChain == null)
                {
                    break;
                }
                m_faces.Add(mipMapChain);
            }
        }
Ejemplo n.º 6
0
        private Texture CreateTexture(ManagedImage image)
        {
            MipMapChainCollection mipMapChainCollection = image.Faces;
            int faceCount = mipMapChainCollection.Count;

            if (faceCount == 1)
            {
                MipMapChain face = mipMapChainCollection[0];
                if (face.Count > 0)
                {
                    ImageData mip0   = face[0];
                    int       width  = mip0.Width;
                    int       height = mip0.Height;
                    int       depth  = mip0.Depth;

                    //Only create 1D/3D textures if we have width/depth greater than zero. So an image that is 1x1x1
                    //will become a texture2d
                    if (width > 1 && height == 1 && depth == 1)
                    {
                        return(CreateTexture1D(face));
                    }
                    else if (depth > 1)
                    {
                        return(CreateTexture3D(face));
                    }
                    else
                    {
                        return(CreateTexture2D(face));
                    }
                }
            }
            else if (faceCount > 1 && faceCount <= 6)
            {
                return(CreateTextureCube(mipMapChainCollection));
            }

            throw new ArgumentException("Invalid texture type");
        }
Ejemplo n.º 7
0
        private MipMapChain CreateMipMapChain(ImageID imageID, int imageNum, int faceNum) {
            IL.BindImage(imageID);
            if(!IL.ActiveImage(imageNum))
                return null;
            if(!IL.ActiveFace(faceNum))
                return null;

            //Get total number of mipmaps (including base face)
            int mipMapCount = IL.ilGetInteger(ILDefines.IL_NUM_MIPMAPS) + 1;
            MipMapChain mipMapChain = new MipMapChain();

            //Get the first mipmap and every other, when we hit a null, we break
            for(int i = 0; i < mipMapCount; i++) {
                ImageData data = ImageData.Load(new Subimage(imageID, imageNum, faceNum, 0, i));
                if(data == null)
                    break;
                mipMapChain.Add(data);
            }
            mipMapChain.TrimExcess();
            return mipMapChain;
        }