[SDL] libpng error: decompression error.

Christoph Nelles evilazrael at evilazrael.de
Mon Jul 19 23:54:40 PDT 2010


Am 20.07.2010 08:33, schrieb mike:
> Hi Donny
> yes you might be wright so maybe you could help me move SDL_Surface out of the
> function? This should be the way to go? 
> Anyway i tried as below and still randomly the error occurrs with 2-3 out of 4
> png textures.
>
> ------
> /// Loads one texture
> int LoadGLTexture(char *pFileName, int TextureId)
> {
>    SDL_Surface* lotto[TextureId];
>    SDL_RWops *rwop;
>    rwop=SDL_RWFromFile(TextureFileName, "rb");
>    lotto[TextureId]=IMG_LoadPNG_RW(rwop);
>
>   
Using RWops here makes it more complicated but still not correct. When
you declare an array int xyz[5] you have the elements xyz[0]..xyz[4].
You are writing to xyz[5], so you are writing in space that is probably
not belonging to you and in every case is not in your array. Go fetch a
C/C++ book.
> int lotto[5];
>   
Where is this declaration? It will still be shadowed by the local
declaration in the function.
http://en.wikibooks.org/wiki/C%2B%2B_Programming/Scope





More information about the SDL mailing list