Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: BentFX on September 03, 2006, 11:14:16 am

Title: controlling testing environment?
Post by: BentFX on September 03, 2006, 11:14:16 am
I've got a graphics program I'm working on... I've also got a buggy vid card... While testing and debugging I need to set or optionally unset an environment variable (LIBGL_ALWAYS_INDIRECT) to control whether DRI or indirect rendering is used.

From within C::B how do I control the environment that my program executes in?

Thanx!
Title: Re: controlling testing environment?
Post by: MortenMacFly on September 03, 2006, 11:54:27 am
There is a plugin that does allow you to setup the environment of C::B as you like. Go to Settings -> Environment -> Environment variables.
Please notice that these environement variables are only applied within the focus of C::B. Thus if you don't launch your application from C::B the environment may be different (just ad the "usual" on on your system). Anyway, they are being saved accross C::B session and don't get lost. ;-)
With regards, Morten.
Title: Re: controlling testing environment?
Post by: BentFX on September 03, 2006, 12:16:39 pm
Thanx Morten,

I worked around it in my own way :)

I duplicated the 'Debug' target as 'Debug(indirect)' and added 'LIBGL_ALWAYS_INDIRECT' as a compiler define.

and at the begining of my 'OnInit' I added...
Code
#ifdef LIBGL_ALWAYS_INDIRECT
    setenv("LIBGL_ALWAYS_INDIRECT","1",1);
#endif

It seams to work fine... I just need to ensure that file is rebuilt when I change targets.

I'll probably check out the plugin also, yet I think I'll leave this in to allow a build which will always run in indirect mode. (It's a feature!!!) :D

Thanx again,
Skip

Title: Re: controlling testing environment?
Post by: BentFX on September 03, 2006, 12:31:42 pm
Now it's a feature!!!

I parse for '-indirect' on the command line, and set the env var accordingly.
Then I change my 'Debug(indirect)' to be the same as 'Debug', yet I add the -indirect argument in 'Project->Set Program Arguments...->Debug(indirect)". Now nothing needs to be rebuilt, just change the target... and it will always be a runtime option!

I guess all roads lead to Rome, but some of us can afford to fly :D