public GLESTextureBuffer( string basename, All targetfmt, int id, int width, int height, int format, int face, int level, BufferUsage usage, bool crappyCard, bool writeGamma, int fsaa )
: base( 0, 0, 0, Media.PixelFormat.Unknown, usage )
{
_target = targetfmt;
_textureId = id;
_face = face;
_level = level;
_softwareMipmap = crappyCard;
GLESConfig.GlCheckError( this );
OpenGL.BindTexture( All.Texture2D, _textureId );
GLESConfig.GlCheckError( this );
// Get face identifier
_faceTarget = _target;
// TODO verify who get this
Width = width;
Height = height;
Depth = 1;
_glInternalFormat = (All)format;
Format = GLESPixelUtil.GetClosestAxiomFormat( _glInternalFormat );
RowPitch = Width;
SlicePitch = Height * Width;
sizeInBytes = PixelUtil.GetMemorySize( Width, Height, Depth, Format );
// Set up a pixel box
_buffer = new PixelBox( Width, Height, Depth, Format );
if ( Width == 0 || Height == 0 || Depth == 0 )
{
/// We are invalid, do not allocate a buffer
return;
}
// Is this a render target?
if ( ( (int)Usage & (int)TextureUsage.RenderTarget ) != 0 )
{
// Create render target for each slice
for ( int zoffset = 0; zoffset < Depth; zoffset++ )
{
string name = string.Empty;
name = "rtt/" + this.GetHashCode() + "/" + basename;
GLESSurfaceDescription target = new GLESSurfaceDescription();
target.Buffer = this;
target.ZOffset = zoffset;
RenderTexture trt = GLESRTTManager.Instance.CreateRenderTexture( name, target, writeGamma, fsaa );
_sliceTRT.Add( trt );
Root.Instance.RenderSystem.AttachRenderTarget( _sliceTRT[ zoffset ] );
}
}
}