protected void GenerateMipMaps( byte[] data, bool useSoftware, bool isCompressed, int faceNum )
{
// use regular type, unless cubemap, then specify which face of the cubemap we
// are dealing with here
int type = ( TextureType == TextureType.CubeMap ) ? Gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceNum : this.GLTextureType;
if ( useSoftware && MipmapCount > 0 )
{
if ( TextureType == TextureType.OneD )
{
Glu.gluBuild1DMipmaps(
type,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
Width,
this.GLFormat,
Gl.GL_UNSIGNED_BYTE,
data );
}
else if ( TextureType == TextureType.ThreeD )
{
// TODO: Tao needs glTexImage3D
Gl.glTexImage3DEXT(
type,
0,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
SrcWidth, SrcHeight, Depth, 0, this.GLFormat,
Gl.GL_UNSIGNED_BYTE,
data );
}
else
{
// build the mipmaps
Glu.gluBuild2DMipmaps(
type,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
Width, Height,
this.GLFormat,
Gl.GL_UNSIGNED_BYTE,
data );
}
}
else
{
if ( TextureType == TextureType.OneD )
{
Gl.glTexImage1D(
type,
0,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
Width,
0,
this.GLFormat,
Gl.GL_UNSIGNED_BYTE,
data );
}
else if ( TextureType == TextureType.ThreeD )
{
// TODO: Tao needs glTexImage3D
Gl.glTexImage3DEXT(
type,
0,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
SrcWidth, SrcHeight, Depth, 0, this.GLFormat,
Gl.GL_UNSIGNED_BYTE,
data );
}
else
{
if ( isCompressed && Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.TextureCompressionDXT ) )
{
int blockSize = ( Format == PixelFormat.DXT1 ) ? 8 : 16;
int size = ( ( Width + 3 ) / 4 ) * ( ( Height + 3 ) / 4 ) * blockSize;
// load compressed image data
Gl.glCompressedTexImage2DARB(
type,
0,
this.GLFormat,
SrcWidth,
SrcHeight,
0,
size,
data );
}
else
{
Gl.glTexImage2D(
type,
0,
HasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,
Width, Height, 0,
this.GLFormat, Gl.GL_UNSIGNED_BYTE,
data );
}
}
}
}