Beginner Question: Why do we use ZeroMemory macro for Swap Chain object ?

Started by
1 comment, last by Tibetan Sand Fox 11 years, 6 months ago
Hello.
As I mentioned in topic I'm curious why does Swap Chain object require to use ZeroMemory macro before filling it with data? I know what ZeroMemory macro does - from what I read on MSDN it fills a block of memory with zeros, but why?

Thanks a lot in advance for satisfying my curiosity.
Advertisement
It's just a way of initializing the structure data, since the struct doesn't have a constructor. This has always been considered the idomatic way to initialize Win32 structures as long as I can remember. You don't have to do it if you don't want to, you just need to make sure that you set all of the members of the struct.
Thank you. I used debugger today as well to see myself how the process of Swap Chain initialization exactly works. I managed to notice that after creating Swap Chain struct object is filled with some random data (structs don't have constructor as you mentioned) and as you said I see I could skip the ZeroMemory step, but it's very convenient and I don't have to care about all of the struct members. I guess I'll stay that way. Thanks again.

This topic is closed to new replies.

Advertisement