Program runs correct from Visual Studio but not from executable

I have some openGL code and when I run it using the Visual Studio debugger it looks the way I expect it to look. But, when I run the executable, the colors are different.

Here's a link to a video of what is happening. The first window is launched from VS with a green ground plane and red boxes. The second window is launched from the executable and has a red ground plane and red boxes, with a few green boxes mixed in.

https://youtu.be/h0AQEiJO6dA

Any ideas why this might be happening.
Can you provide code?
I was really hoping someone would say: "Yeah, that happened to me once and here's how you fix it." But, I guess not; that would be too easy.

Let me ask a different question. How would you go about trying to track down this problem? I'm just a hobbyist and only recently started using Visual Studio regularly. I'm using an older laptop with Win 7 and my VS version is 11 update 5, or MSVS Express 2012. One other note is that it seems to run just fine when I run the exe using gDEBugger, which I find odd. When I double click the exe file to run it, sometimes it's perfect, sometimes not. Furthermore, the green boxes are random, i.e. not the same every time, which I also find odd.

I don't know what code might be helpful to see, since it should be the same damn executable run from the Debug folder. If you really want to look at it though, I pushed it to my github (https://github.com/mgoetschius/GameEngine). Fair warning it's ~1600 lines in 37 files as it stands right now.

Thanks for reading. If you have any idea where I should start, I'd love to hear it.
When a program's behavior differs from run to run, the first thing I think of is an uninitialized variable. How do you set the color of the boxes?
"Yeah, that happened to me once and here's how you fix it."


In this order:

Make sure every variable is initialised properly. The windows compiler has a habit, in default debug builds, of setting values in variables.
Build it with all the compiler warnings turned on, and fix them all.
If you're using threads, double-check them for race hazards
Run the code using a memory watcher of some kind (valgrind or Dr Memory or some such) and see if it tells you that you're trashing any memory.
Thank you both. I think I've got it sorted out. You were both right. I had an issue with my openGL textures which included an uninitialized variable complete with a memory leak, both having to do with a missing copy constructor. Also, I wasn't handling my textures properly in regards to the openGL specs. Everything completely my fault. Thanks again for pointing me in the right direction.
Topic archived. No new replies allowed.