Page 1 of 1

Help with SDL!

Posted: Sun Feb 12, 2012 12:34 pm
by lalacomun
Hello everybody i am having a problem with SDL, when i compile and run my game with the IDE it works just perfect, but when i ty to run the .exe aplication, it apear a black screen for 1 sec and then it crash! :cry: i am using Dev-C++ as IDE, i added al the DLL's to the file
please Help!!!

Re: Help with SDL!

Posted: Sun Feb 12, 2012 1:46 pm
by Teser0ck
Are you sure you have your images, music, etc. in the folder where's the .exe ? You should show us some code if this doesn't solve the problem.

Re: Help with SDL!

Posted: Sun Feb 12, 2012 1:54 pm
by lalacomun
here:

bool load_files()
{
dot = load_image( "C:\\Users\\nico\\Desktop\\proyecto engine-editor\\game\\Images\\dot.png" );

if( dot == NULL )
{
return false;
}

tileSheet = load_image( "C:\\Users\\nico\\Desktop\\proyecto engine-editor\\game\\Images\\tiles.png" );

if( tileSheet == NULL )
{
return false;
}
return true;
}


As you can see i have the images directorys defined in the code, but the exe is not in the images and maps folders, is in the engine folder.

Re: Help with SDL!

Posted: Sun Feb 12, 2012 5:36 pm
by Nokurn
lalacomun wrote:here:

bool load_files()
{
dot = load_image( "C:\\Users\\nico\\Desktop\\proyecto engine-editor\\game\\Images\\dot.png" );

if( dot == NULL )
{
return false;
}

tileSheet = load_image( "C:\\Users\\nico\\Desktop\\proyecto engine-editor\\game\\Images\\tiles.png" );

if( tileSheet == NULL )
{
return false;
}
return true;
}


As you can see i have the images directorys defined in the code, but the exe is not in the images and maps folders, is in the engine folder.
Try setting breakpoints, stepping through your code, or adding some debug logging everywhere that an error condition is returned or acted upon, like so:

Code: Select all

fprintf(stderr, "Some shit hit the fan in load_image when loading tiles.png\n");
Also, you should fix your directories and use relative paths if you think you might ever move the project folder to a different location or give your game to anyone else. Absolute paths are, in all but the most extreme of cases, terrible ideas.

Re: Help with SDL!

Posted: Sun Feb 12, 2012 6:39 pm
by lalacomun
Yes i add debugg stuff in the code and the problem is loading the files (player, tiles) but i cant fix it!!, its interesting that when i compile and run it from the compiler it load the files perfect, the problem is the exe!

Re: Help with SDL!

Posted: Sun Feb 12, 2012 7:05 pm
by Nokurn
lalacomun wrote:Yes i add debugg stuff in the code and the problem is loading the files (player, tiles) but i cant fix it!!, its interesting that when i compile and run it from the compiler it load the files perfect, the problem is the exe!
If it's a SDL function that's failing, log the error message from SDL. SDL and its addons provide *_GetError() messages, where * is SDL, IMG (for SDL_image), Mix (for SDL_mixer), or TTF (for SDL_ttf). So if IMG_Load() is failing, do this:

Code: Select all

SDL_Surface *image = IMG_Load(filename);
if (!image) {
    fprintf(stderr, "IMG_Load(%s) returned NULL; SDL_image said '%s'\n", filename, IMG_GetError());
    return NULL;
}
You're providing very little information on the specifics of your problem. Just saying that the problem is loading the files and that you can't fix it doesn't give us the necessary details to help you. You've provided us with one function that very simply calls another function (load_image()), but not the source to the function where the actual work is being done--and therefore, likely where the error is happening.

Re: Help with SDL!

Posted: Sun Feb 12, 2012 7:09 pm
by lalacomun
Thanx for all your help the problem were these 2 damn dlls : libpng12-0.dll and zlib1.dll

Re: Help with SDL!

Posted: Wed Feb 15, 2012 10:38 am
by lalacomun
Well i get to the conclusion That Dev-C++ SUCKS!

Re: Help with SDL!

Posted: Wed Feb 15, 2012 12:01 pm
by jaybee
lalacomun wrote:Well i get to the conclusion That Dev-C++ SUCKS!
I think that's the general consensus among most people on this forum. ;)

Re: Help with SDL!

Posted: Wed Feb 15, 2012 12:01 pm
by dandymcgee
lalacomun wrote:Thanx for all your help the problem were these 2 damn dlls : libpng12-0.dll and zlib1.dll
Ahh yes. I've forgotten to put those in the folder so many times. Without them, nothing works yet no error.. perhaps there's a way to error-check that in the code.

Re: Help with SDL!

Posted: Wed Feb 15, 2012 3:28 pm
by short
Ah, I promise if you keep at it you'll get to the point where you recognize the runtime error as a missing dll.

Re: Help with SDL!

Posted: Wed Feb 15, 2012 5:37 pm
by superLED
short wrote:Ah, I promise if you keep at it you'll get to the point where you recognize the runtime error as a missing dll.
But it would still be a good idea, in chase the player somehow screwed up and removed a dll from the folder. "Hey, you are missing this dll"
In my experience, most of my chases of missing dll's, I've got a message box that tells me I'm missing a dll. But some dll's wont give me that error message, so I have to figure it out myself.

Re: Help with SDL!

Posted: Thu Feb 16, 2012 11:32 am
by lalacomun
superLED wrote:
short wrote:Ah, I promise if you keep at it you'll get to the point where you recognize the runtime error as a missing dll.
But it would still be a good idea, in chase the player somehow screwed up and removed a dll from the folder. "Hey, you are missing this dll"
In my experience, most of my chases of missing dll's, I've got a message box that tells me I'm missing a dll. But some dll's wont give me that error message, so I have to figure it out myself.
Hell yes!
short wrote:Ah, I promise if you keep at it you'll get to the point where you recognize the runtime error as a missing dll.
I hope so !!