Sign in to follow this  
RenZimE

[.net] S3TC in taoframework

Recommended Posts

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.
                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);   
                }



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this