Simple C++ Fog Problem

That address doesn’t help; I need to know the function. I guess we don’t ship the pdb files along with the pre-built panda (they’re too huge). That probably means the only way to get anything meaningful out of that would be to build your own Panda.

Hmm, can you package up your project file and upload it somewhere for me? Maybe I can try to reproduce your problem. Which version of Panda are you using?

David

I am using Panda 1.6.2. The newest one up on the site I believe. And I am using Visual Studio 2008. I uploaded my project in a .rar here:

[url]
mediafire.com/?sharekey=d9ba … f6e8ebb871

Hey I tried your Code and the same thing happened it Compiled OK started and a few secconds passed and BOOM it crashed. Then this is what i did to make it work with no problems (the fog was also blue instead of black).

I deleted these :WIN32;NDEBUG;_CONSOLE;WIN32_VC from the processor definitions. and it Works fine now for me. Try it. Mybe itll help I also had to have the CG.DLL in the same DIR as my App, but that maynot be the case for u. After deleting this the fog renders correctly in a black color. and all is smooth and no crashes occur

Well that seems to have done the trick.

Can anyone explain to me why these preprocessor definitions cause this problem?

Thanks again for all the help

Ah, I believe NDEBUG is the culprit. The presence of this symbol means your code is being compiled for a final production release, with all run-time parameter validation checks and other development assistance removed. (As a general rule of thumb in C/C++ development, you should never build with this symbol defined unless you are absolutely sure your code is bug-free and are ready to release it to the world.)

In the case of the Panda code, defining this symbol also removes the declaration of certain members from low-level objects which are used internally to ensure self-consistency.

The problem is, the Panda library distributed here was not built with NDEBUG defined (nor should it have been, since this Panda is used primarily for development). But when you compiled your own code with NDEBUG and included the Panda header files, you lied to the compiler, and told it that Panda had been compiled with NDEBUG defined. The compiler computed the necessary offsets into the low-level Panda structures based on the definition of NDEBUG, and got the answer wrong, or at least different than the code you were linking with at runtime. Thus, internal structures were being corrupted, and mysterious crashes were the result.

So, the short answer is: don’t define NDEBUG unless you are ready to make a full production release, and then only when you are willing to build all of Panda the same way.

David

Ahh interesting little fact to know.

Thanks again for everything!

Alright so this seemed to work fine on my PC which I have running VS 2008… however I am currently using a different PC with VS 2005 and this does not solve the issue. It seems whenever I try to create a PointerTo object for reference counted objects I get a crash at runtime.

e.g.  PT(CollisionRay)

The NDEBUG is not in my Preprocessor definitions. The additional libraries and includes are as stated above. Once again everything compiles fine but I am left with a runtime error which crashes the program. Any additional ideas?

Panda is compiled against VS 2008 - so I did not expect it to even work with older versions of MSVC.

Well everything seems to work fine except for those PointerTo objects. So basically I need to be updated to VS 2008 in order for this problem to fixed?

I think so, yes.

What if I wear to build the source myself with VS 2005? Would that then allow me to use every thing as expected? Or would the build fail if attempted with VS 2005?

Or would I just be better off downloading and using VS C++ 2008 Express?

You could build Panda with VS2005, with some effort. Or you could downgrade to Panda 1.5.4.

Probably getting VC 2008 is better, though.

Just wanted to let everyone know that was the problem. Upgraded VC++ 2008 Express Edition and it seems to be good to go now.

Thanks much for your help today pro-rsoft.