A ready to use Vulkan triangle example for D

Alex Parrill via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sat May 28 10:50:30 PDT 2016


On Saturday, 28 May 2016 at 10:58:05 UTC, maik klein wrote:
>
> derelict-vulcan only works on windows, dvulkan doesn't have the 
> platform dependend surface extensions for xlib, xcb, w32 and 
> wayland. Without them Vulkan is unusable for me.
>
> I really don't care what I use, I just wanted something that 
> works.

Platform extension support will be in the next release of 
d-vulkan. It doesn't include platform extensions now because I 
wanted to find a way to implement it without tying d-vulkan to a 
specific set of bindings, though I can't seem to find a good 
solution unfortunately... I personally use the git version of 
GLFW, which handles the platform-dependent surface handling for 
me.

As for the demo itself... It might help explain things more if 
the separate stages (instance creation, device creation, setting 
up shaders, etc) were split into their own functions, instead of 
stuffing everything into `main`.

Struct initializers are also useful when dealing with Vulkan info 
structs, since you don't have to repeat the variable name each 
time. Ex this:

VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo = 
{};
vertexInputStateCreateInfo.sType = 
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputStateCreateInfo.vertexBindingDescriptionCount = 1;
vertexInputStateCreateInfo.pVertexBindingDescriptions = 
&vertexBindingDescription;
vertexInputStateCreateInfo.vertexAttributeDescriptionCount = 1;
vertexInputStateCreateInfo.pVertexAttributeDescriptions = 
&vertexAttributeDescritpion;

Can become:

VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo = 
{
     sType = 
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // 
also sType is pre-set with erupted or d-derelict
     vertexBindingDescriptionCount = 1,
     pVertexBindingDescriptions = &vertexBindingDescription,
     vertexAttributeDescriptionCount = 1,
     pVertexAttributeDescriptions = &vertexAttributeDescritpion,
};


More information about the Digitalmars-d-announce mailing list