Gl.glBindTexture(Gl.GL_TEXTURE_2D, TexID);
int cWidth = (int)m_ddsHeader.dwWidth;
int cHeight = (int)m_ddsHeader.dwHeight;
int offset = 0;
int size = 0;
int format = (int)ddsInfo.internalFormat;
byte[] temp;
for (int i = 1; i < m_ddsHeader.dwMipMapCount; i++)
{
size =(int)((cWidth/4)*(cHeight/4)*ddsInfo.blockBytes);
temp = new byte[size];
Array.Copy(DDSSurface,offset,temp,0,size);
Gl.glCompressedTexImage2DARB(Gl.GL_TEXTURE_2D,i,format,cWidth,cHeight,0,size,temp);
offset+=size;
cWidth = Math.Max(1,cWidth >> 1);
cHeight = Math.Max(1,cHeight >> 1);
Array.Clear(temp,0,temp.Length);
}
[.net] S3TC in taoframework
i have been having problems with taoframework throwing an access violation exception while calliing glCompressedTexImage2DARB and was wondering if any one else has come across this or has any way i can avoid it.
Simple answer: is your buffer big enough? Looks to me like you're trying to fill it with (cWidth×cHeight) pixels but only allocating a sixteenth of that ... even allowing for the pixel format (more than one byte per pixel), which I presume is covered by ddsInfo.blockBytes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement