vulkan-tutorial/src/Framebuffers.hs

44 lines
1.2 KiB
Haskell
Raw Normal View History

2022-07-13 01:41:33 +00:00
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DataKinds #-}
module Framebuffers where
import Linear
import Control.Monad.Trans.Resource
import qualified Data.Vector as V
import Foreign.C.Types (CInt)
import qualified Vulkan as Vk
import qualified Vulkan.Zero as Vk
createFramebuffer
:: (MonadResource m)
2022-07-14 05:02:10 +00:00
=> Vk.Device
-> Vk.RenderPass
2022-07-13 01:41:33 +00:00
-> V.Vector Vk.ImageView
-> V2 CInt
2022-07-16 14:36:51 +00:00
-> m (V.Vector Vk.Framebuffer)
2022-07-14 05:02:10 +00:00
createFramebuffer logicalDevice renderPass swapchainImageViews (V2 swapchainWidth swapcheinHeight)
2022-07-13 01:41:33 +00:00
= do
let framebufferCreateInfo = Vk.zero
{ Vk.renderPass = renderPass
, Vk.width = fromIntegral swapchainWidth
, Vk.height = fromIntegral swapcheinHeight
, Vk.layers = 1
}
2022-07-16 14:36:51 +00:00
V.mapM
(\imageView -> do
let createInfo = framebufferCreateInfo
{ Vk.attachments = V.singleton imageView
} :: Vk.FramebufferCreateInfo '[]
snd <$> allocate
(Vk.createFramebuffer logicalDevice createInfo Nothing)
(\framebuffer -> do
putStrLn "destroying framebuffer"
Vk.destroyFramebuffer logicalDevice framebuffer Nothing
)
2022-07-13 01:41:33 +00:00
)
2022-07-16 14:36:51 +00:00
swapchainImageViews