Jump to content
  • Advertisement
Sign in to follow this  
Tsumuji

zlib and files in a directory?

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
"can load all supported image formats, except TGA"
they wrote this on the SDL_Image site http://jcatki.no-ip.org/SDL_image/SDL_image.html
I don't know why it is or whether it is true, I have not tried it

when you need the autom. loading, than check the filename for the fileextension and call the right function for this fileextension
you can implement this for each fileextension or only check for ".tga" and handle all other with the IMG_Load_RW function

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
ie.

#include <string.h>
...
SDL_Surface *surface;
if (strstr(filename, ".tga") != NULL) {
surface = IMG_LoadTyped_RW(rw, 0, "TGA");
// or
surface = IMG_LoadTGA_RW(rw);
}
else {
surface = IMG_Load_RW(rw, 0);
}
...


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think your use of PHYSFS_File is not correct,
you copy the contents of the returned pointer to your own instance and use this,
but PHYSFS_openRead alloc intern memory for the PHYSFS_file data and PHYSFS_close free this memory,
but in your code this would be the instance variable, and that is not correct

you should simply use the returned pointer:

//The function that take the file I desire:
void *engine::abreArquivoCompactado( const char *arquivo, int *size ){
if ( PHYSFS_exists(arquivo) == 0 ){
std::cout << PHYSFS_getLastError() << std::endl;
}else{
PHYSFS_File *arquivo_virtual;
arquivo_virtual = PHYSFS_openRead(arquivo);
PHYSFS_uint32 pakSize;
pakSize = PHYSFS_fileLength( arquivo_virtual );
// if ( PHYSFS_setBuffer( arquivo_virtual, pakSize) == 0 ){
// std::cout << PHYSFS_getLastError() << std::endl;
// }
char *buffer = new char[pakSize];
PHYSFS_read( arquivo_virtual, buffer, pakSize, 1 );

if ( PHYSFS_close( arquivo_virtual ) == 0 ){
std::cout << PHYSFS_getLastError() << std::endl;
}
*size = pakSize;
return buffer;
}
return 0;
}



also the function PHYSFS_setBuffer is normally not needed

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!