Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import Vulkan
- import Control.Exception
- import Foreign hiding (newForeignPtr)
- data VulkanException = VulkanException VkResult
- deriving Show
- instance Exception VulkanException
- checkResult :: VkResult -> IO ()
- checkResult (VkResult 0) = return ()
- checkResult result = throwIO (VulkanException result)
- createInstance :: VkInstanceCreateInfo -> IO VkInstance
- createInstance instance_create_info =
- alloca $ \p_instance_create_info -> do
- poke p_instance_create_info instance_create_info
- alloca $ \p_instance -> do
- vkCreateInstance p_instance_create_info nullPtr p_instance >>= checkResult
- peek p_instance
- destroyInstance :: VkInstance -> IO ()
- destroyInstance instanze =
- vkDestroyInstance instanze nullPtr
- withInstance :: VkInstanceCreateInfo -> (VkInstance -> IO ()) -> IO ()
- withInstance createInfo = bracket (createInstance createInfo) destroyInstance
- main :: IO ()
- main = do
- let instance_create_info = VkInstanceCreateInfo vkStructureTypeInstanceCreateInfo nullPtr (VkInstanceCreateFlags 0) nullPtr 0 nullPtr 0 nullPtr
- withInstance instance_create_info $ \instanze ->
- return ()
Advertisement
Add Comment
Please, Sign In to add comment