Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: lubos on June 19, 2007, 01:57:43 pm

Title: huh what the hell...
Post by: lubos on June 19, 2007, 01:57:43 pm
im coding 2d game engine with sdl in code::blocks. i have coded particle systems yesterday and i noticed today that when i run program from ide, it runs differently than when i run him directly from explorer.

i will create two particle systems:
CParticleSystem psys1;
CParticleSystem psys2;

...init them...

and draw them:
psys1.draw(0, 0);    // x and y pos of origin
psys2.draw(800, 0)

so it should draw two particle systems, one at pos 0,0 and another one at pos 800,0
however when i run this from c::b, it draws ony first created system(psys1). when i run program from explorer all is OK, it will draw both particle systems.. HOW IS THIS POSSIBLE? i have setted working directory, using release target...

winXP SP2, nightly 4092
Title: Re: huh what the hell...
Post by: David Perfors on June 19, 2007, 02:19:06 pm
are you using a console project? if so, you could try to turn off "Pause on exit" option (Project settings, not sure about the name of that option, don't have C::B here)
Title: Re: huh what the hell...
Post by: lubos on June 19, 2007, 02:44:11 pm
its a 'GUI application', not console  :( i have really no idea why it work differently from explorer and from ide.

Title: Re: huh what the hell...
Post by: byo on June 19, 2007, 03:06:26 pm
its a 'GUI application', not console  :( i have really no idea why it work differently from explorer and from ide.



Do you load any bitmaps or other files to show particles? The main difference between program running in IDE and from explorer/command line is working directory. When you run from IDE, current directory is not set to exe's location but to directory where is project file. Analogically when you run it from explorer, current directory is set to exe's path.

Regards
   BYO
Title: Re: huh what the hell...
Post by: lubos on June 19, 2007, 03:22:03 pm
...i have setted working directory,...
thanks for your post. im using images but i have working directory setted to .exe directory(release dir)..(both particle systems are using images, first one works)

what i have noticed..
when i will code it like this:
CParticleSystem *pSys1;
CParticleSystem *pSys2;

pSys1 = new CParticleSystem;
...

init...

now it will draw both systems.. it will also works when i do it like
CParticleSystem pSys[2];

im out of this..maybe i should create it with pointer...but anyway, shouldnt it work same from explorer and from ide..  :?
Title: Re: huh what the hell...
Post by: byo on June 19, 2007, 06:44:55 pm
Maybe it's Debug/Release configuration difference. You may run Debug exe in IDE and Release from explorer. Usually debug targets behave differently when your class has some members which are not initialized in constructors. They are filled with different data in those targets, so f.ex. pointers in debug may be NULL but in release some other stuff like 0xBAADF00D, so it's a good practice to initialize everything inside constructors. If it's not the case I don't have any other idea, but it's related to GCC rather than to IDE.

Regards
   BYO
Title: Re: huh what the hell...
Post by: lubos on June 19, 2007, 07:06:12 pm
whoa, this is..really strange...
i have created four particle systems:
release from ide: 1st and 3rd system works
release from explorer: 1st, 2nd and 3rd worked
debug from ide: 4th worker
debug from explorer: 3rd and 4th worked.
 :shock: :shock:
it runs differently at every target...i will try to reinstall gcc and if nothing, it seems that i have coded something wrong... :(
thanks for your help   :)
Title: Re: huh what the hell...
Post by: byo on June 19, 2007, 07:17:27 pm
whoa, this is..really strange...
i have created four particle systems:
release from ide: 1st and 3rd system works
release from explorer: 1st, 2nd and 3rd worked
debug from ide: 4th worker
debug from explorer: 3rd and 4th worked.
 :shock: :shock:
it runs differently at every target...i will try to reinstall gcc and if nothing, it seems that i have coded something wrong... :(
thanks for your help   :)

I suggest that you really check your code, set all uninitialized variables, zero newly allocated memory buffers etc. It looks like really nasty bug, so good luck with debugging :)

BYO
Title: Re: huh what the hell...
Post by: rickg22 on June 19, 2007, 08:55:07 pm
Try checking the "Enable all compiler warnings (Wall)" in your project's build options, under compiler. This will make sure nothing will go unnoticed. And if you feel strict, turn on the "pedantic" flag, too :P