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); }
private static Texture GetTextureFromBoundImage(int imageNum = 0) { IL.ActiveImage(imageNum); bool success = IL.ConvertImage(DevIL.DataFormat.RGBA, DevIL.DataType.UnsignedByte); if (!success) { return(null); } int width = IL.GetImageInfo().Width; int height = IL.GetImageInfo().Height; Texture texture = new Texture((uint)width, (uint)height); Texture.Bind(texture); { Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); Gl.glTexImage2D( Gl.GL_TEXTURE_2D, 0, IL.GetInteger(ILIntegerMode.ImageBytesPerPixel), width, height, 0, IL.GetInteger(ILIntegerMode.ImageFormat), ILDefines.IL_UNSIGNED_BYTE, IL.GetData() ); } Texture.Bind(null); return(texture); }
public bool Activate() { if (m_rootImage <= 0) { return(false); } IL.BindImage(m_rootImage); //Don't bother to activate if any subimages are zero, as it corresponds to the root image if (m_imageIndex > 0 && !IL.ActiveImage(m_imageIndex)) { return(false); } if (m_faceIndex > 0 && !IL.ActiveFace(m_faceIndex)) { return(false); } if (m_layerIndex > 0 && !IL.ActiveLayer(m_layerIndex)) { return(false); } if (m_mipMapIndex > 0 && !IL.ActiveMipMap(m_mipMapIndex)) { return(false); } return(true); }
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); }
public bool Activate() { if ((int)this.m_rootImage <= 0) { return(false); } IL.BindImage(this.m_rootImage); return((this.m_imageIndex <= 0 || IL.ActiveImage(this.m_imageIndex)) && (this.m_faceIndex <= 0 || IL.ActiveFace(this.m_faceIndex)) && ((this.m_layerIndex <= 0 || IL.ActiveLayer(this.m_layerIndex)) && (this.m_mipMapIndex <= 0 || IL.ActiveMipMap(this.m_mipMapIndex)))); }
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); } }
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); } }