Jump to content
  • Advertisement
Sign in to follow this  
liZHao

VC++ F5 and Ctrl+F5, I'm mad...

This topic is 2210 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks,

I'm stuck on a problem.. I wrote a OpenGL rendering framework using VC 2012. It loads model and shader files from hard drive. It works very well when I launch it by F5, BUT if I use Ctrl+F5, nothing is ever drawn on the screen.. Also under both 'modes', all files have been read in properly. I cannot figure out why, please help me if you have any ideas. Thanks in advance.

The libraries I used: glew 1.9, SDL 1.2, glm 0.9.3.4, C++11

Share this post


Link to post
Share on other sites
Advertisement
Most likely you're relying on an uninitialized variable somewhere. Try turning the compiler's warning setting up to it's maximum level.
Do you use multi-threading or custom memory allocation?

Share this post


Link to post
Share on other sites
Thanks for your answer Hodgman, regarding

Most likely you're relying on an uninitialized variable somewhere. Try turning the compiler's warning setting up to it's maximum level.

I maximized the warning levels but there are no variables uninitialized.


Do you use multi-threading or custom memory allocation?

Neither of them have been used so far. Though I found the rendering results may differ from time to time. E.g. very few times when I start the app only one of two meshes is drawn while other times nothing is drawn. Edited by liZHao

Share this post


Link to post
Share on other sites
I maximized the warning levels but there are no variables uninitialized.
This just means there's no obvious uninitialized variables, there still might be some :/

e.g. This code creates a new uninitialized variable, but the compiler won't issue a warning about it:MyStruct* data = (MyStruct*)malloc( sizeof(MyStruct) );

Share this post


Link to post
Share on other sites
Note that even without weird creation mechanisms, if you pass the address of an uninitialized variable around, MSVC won't give you a warning. Ex:

void foo1(int a) {}
void foo2(int * a) {}

int main(int, char **) {
int a;
int b;
foo1(a); // C4700
foo2(&b); // no warning
}

Share this post


Link to post
Share on other sites
SiCrane - but that's normal usage of output argument. Why would you want warning for that? Then a lot of C style programs will give tons of warnings.

Share this post


Link to post
Share on other sites
SiCrane did not say that should produce a warning. He said that is a situation where an uninitialized variable is used in a potentially dangerous context. That is an important point because the OP seems to assume no "uninitialized variable" warnings mean his program does not use them. Edited by BitMaster

Share this post


Link to post
Share on other sites
Try to use CppCheck on it, it's usually pretty good at founding uninitialised variables in C++, it has already saved my neck more than a couple of times since I've started using it.

Share this post


Link to post
Share on other sites
The thing I don't get about the unitialized variable assumption ist that both F5 and Ctrl+F5 launch the debug build (one with debugger attached, the other without) so the variables that stay uninitialized in release but initialized in debug should be initialized as well. Or am I missing something?

Try to attach the debugger after launching with Ctrl+F5 maybe that helps in seeing what happens?

Share this post


Link to post
Share on other sites
I have found the reason: there is a boolean member variable indicating the visibility of a mesh and it has not been initialized explicitly.. thus in debug mode (F5) it is initialized with 'true' otherwise it is random..
What confuses me is why VC initializes a boolean variable with 'true'?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!