Method: Vulkan::Framebuffer#initialize

Defined in:
lib/vulkan/framebuffer.rb

#initialize(vk, attachments:, width:, height:, render_pass:, layers: 1) ⇒ Framebuffer

Returns a new instance of Framebuffer.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vulkan/framebuffer.rb', line 11

def initialize(vk, attachments:, width:, height:, render_pass:, layers: 1)
  @vk = vk
  @width = width
  @height = height
  @layers = layers
  @attachments = attachments

  framebuffer_info = VkFramebufferCreateInfo.malloc
  framebuffer_info.sType           = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
  framebuffer_info.renderPass      = render_pass
  framebuffer_info.attachmentCount = attachments.size
  framebuffer_info.pAttachments    = array_of_pointers(attachments)
  framebuffer_info.width           = width
  framebuffer_info.height          = height
  framebuffer_info.layers          = layers

  framebuffer_p = Vulkan.create_value("void *", nil)
  check_result @vk.vkCreateFramebuffer(vk.device, framebuffer_info, nil, framebuffer_p)
  @handle = framebuffer_p.value
  finalize_with vk, :vkDestroyFramebuffer, vk.device, @handle, nil
end