Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Agbahlok   Members   

262
Like
0Likes
Like

Posted 04 October 2012 - 11:04 PM

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.

#2 MJP   Moderators   

19483
Like
5Likes
Like

Posted 04 October 2012 - 11:25 PM

*
POPULAR

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.

#3 Agbahlok   Members   

262
Like
0Likes
Like

Posted 05 October 2012 - 08:33 PM

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.

Edited by Agbahlok, 05 October 2012 - 08:35 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.