vulkan-tutorial/src/Framebuffers.hs

43 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 (unless)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource
import Data.Bits
import qualified Data.ByteString as BS
import qualified Data.Vector as V
import Foreign.C.Types (CInt)
import qualified Vulkan as Vk
import qualified Vulkan.Zero as Vk
import qualified Vulkan.CStruct.Extends as Vk
createFramebuffer
:: (MonadResource m)
=> Vk.RenderPass
-> V.Vector Vk.ImageView
-> V2 CInt
-> Vk.Device
-> m Vk.Framebuffer
createFramebuffer renderPass swapchainImageViews (V2 swapchainWidth swapcheinHeight) logicalDevice
= do
let framebufferCreateInfo = Vk.zero
{ Vk.renderPass = renderPass
, Vk.attachments = swapchainImageViews
, Vk.width = fromIntegral swapchainWidth
, Vk.height = fromIntegral swapcheinHeight
, Vk.layers = 1
}
snd <$> allocate
(Vk.createFramebuffer logicalDevice framebufferCreateInfo Nothing)
(\framebuffer -> do
putStrLn "destroying framebuffer"
Vk.destroyFramebuffer logicalDevice framebuffer Nothing
)