Something like the following should be on the very first page of every single section in the DirectX SDK, preferably prominently boxed with the word "IMPORTANT" written above it in a nice boldface font:
IMPORTANTHow very unlike Microsoft that would be. Firstly divulging what goes on behind the scenes, then telling what you have to do about it, then telling how to do it, then referring you to associated documentation, and all in the very same section.
DirectX components will spawn separate threads of their own, even in a single-threaded application. Your application should be written to accomodate this fact, otherwise you may experience temporary locksups or stalls. Unless you are specifically designing your own thread management system, calling Sleep (0) once per frame is normally sufficient. Please refer to the documentation for the Sleep function at blahblahblahblah.
Sleep (0), by the way, is your friend. It sounds like a frightening thing to put into the main loop of any game; you don't want to be sleeping while actually running do you? - but with a value of 0 the behaviour is actually quite different. Quoting MSDN:
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.Any application that does multi-threaded stuff should always use this, otherwise the main thread will take all of the CPU and other threads in the application will get nothing.
0 comments:
Post a Comment