Make a struct, stuff all the common arguments in there and pass it around. Unless there's a real need for global variables, I'd avoid it.
There are things that need global variables, but this isn't it.
This is a discussion on need help with extern pointers. within the C Programming forums, part of the General Programming Boards category; Make a struct, stuff all the common arguments in there and pass it around. Unless there's a real need for ...
Just bear in mind that if you are actually interested in performance within your ray-tracer, using local variables or parameters is likely to produce better code, since the compiler must assume that global variables may be affected by any function call you make (except for functions that the compiler decides to inline and thus can decide that this portion of code doesn't modify certain variables).
It does sound like those definitions are suitable for storing in a struct that is passed as one const pointer to all functions (that need them).
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
If you absolutely must use globals, then a few rules will help matters.
1. Use a decent namespace, like prefixing all globals with "g_". If you use something terse like 'obj', then you're going to have surprises. One unfortunate project from my past managed to make a global variable called 'i'. Talk about chaos.
2. Put them all in one place, so that you can instantly see the scope of the problem should you ever want to port the code somewhere else.
3. Use gcc and compile with the -Wshadow option, to tell you about the case you highlighted in this thread, namely having a global and a parameter with the same name. But naming rules will also help.
4. Keep the numbers down. Less than 10 is a lot easier to manage than say more than 100.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.