Help with SDL!

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Help with SDL!

Post 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!!!
Image
User avatar
Teser0ck
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 35
Joined: Mon Aug 29, 2011 12:59 pm
Current Project: Platformer game, Map editor, Particle system
Programming Language of Choice: C++
Location: Czech Republic

Re: Help with SDL!

Post 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.
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Help with SDL!

Post 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.
Image
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: Help with SDL!

Post 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.
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Help with SDL!

Post 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!
Image
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: Help with SDL!

Post 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.
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Help with SDL!

Post by lalacomun »

Thanx for all your help the problem were these 2 damn dlls : libpng12-0.dll and zlib1.dll
Image
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Help with SDL!

Post by lalacomun »

Well i get to the conclusion That Dev-C++ SUCKS!
Image
User avatar
jaybee
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 27
Joined: Thu Jan 13, 2011 12:53 pm
Current Project: 2d platformer
Favorite Gaming Platforms: NES, SNES, Genesis, DOS
Programming Language of Choice: C++
Location: Running Springs, CA

Re: Help with SDL!

Post 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. ;)
"Do I really have to spell this out? What if a bunch of punk kids go into the woods with a bullet proof vest and strap it on a grizzly bear? Then what have you got? Invincible bears. Is that what you want? Invincible bears running around; raping your churches and burning your women?"
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Help with SDL!

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: Help with SDL!

Post 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.
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
Posts: 303
Joined: Sun Nov 21, 2010 10:56 am
Current Project: Engine
Favorite Gaming Platforms: N64
Programming Language of Choice: C++, PHP
Location: Norway

Re: Help with SDL!

Post 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.
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Help with SDL!

Post 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 !!
Image
Post Reply