Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


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


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   -  Reputation: 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.

Sponsor:

#2 MJP   Moderators   -  Reputation: 11781

Like
5Likes
Like

Posted 04 October 2012 - 11:25 PM

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   -  Reputation: 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.



PARTNERS