1

I'm not very experienced with C++, so when I discovered that all structures in Vulkan API have a special field to pinpoint their type, I was pretty surprised:

Any parameter that is a structure containing a VkStructureType::sType member must have a value of sType matching the type of the structure. As a general rule, the name of this value is obtained by taking the structure name, stripping the leading Vk, prefixing each capital letter with _, converting the entire resulting string to upper case, and prefixing it with VK_STRUCTURE_TYPE_. For example, structures of type VkImageCreateInfo must have a sType value of VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO.

What functionality relies on this field? Can't it rely on facilities built into the language?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
  • I suspect that his question could be rephrased so it would be about this C++ pattern in general, and not about Vulkan, but I don't think I know enough about it to do it. If you do - welcome. – Max Yankov Jul 21 '16 at 21:20
  • 2
    Vulkan is a C API. It cannot use C++ features. – Colonel Thirty Two Jul 21 '16 at 21:21
  • Damn. Reading C++ Vulkan tutorial, completely missed this. Feeling very stupid. However, this perfectly answers my question; feel free to make it an answer. – Max Yankov Jul 21 '16 at 21:24

0 Answers0