-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4927585
commit baa1c1d
Showing
12 changed files
with
177 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,52 @@ | ||
module Graphics.Seangine | ||
( module Graphics.Seangine.Errors, | ||
module Graphics.Seangine.Frame, | ||
module Graphics.Seangine.HasVulkan, | ||
( module Graphics.Seangine.Config, | ||
module Graphics.Seangine.Config.Frame, | ||
module Graphics.Seangine.Config.VulkanHandles, | ||
module Graphics.Seangine.Errors, | ||
module Graphics.Seangine.Instance, | ||
module Graphics.Seangine.Monad, | ||
module Graphics.Seangine.Scene, | ||
module Graphics.Seangine.Window, | ||
runSeangine, | ||
sdlWindowSystem, | ||
) where | ||
|
||
import Graphics.Seangine.Config | ||
import Graphics.Seangine.Config.Frame | ||
import Graphics.Seangine.Config.VulkanHandles | ||
import Graphics.Seangine.Errors | ||
import Graphics.Seangine.Frame | ||
import Graphics.Seangine.HasVulkan | ||
import Graphics.Seangine.Instance | ||
import Graphics.Seangine.Monad | ||
import Graphics.Seangine.Scene | ||
import Graphics.Seangine.Window | ||
import Graphics.Seangine.Window.SDL | ||
|
||
import Control.Monad.Trans.Resource (MonadUnliftIO (), runResourceT) | ||
import System.FilePath ((</>)) | ||
import Text.GLTF.Loader hiding (ImpossibleError) | ||
import UnliftIO.Exception (throwIO) | ||
|
||
runSeangine :: Options -> FilePath -> IO () | ||
runSeangine opts dataDir = runResourceT $ do | ||
scene <- loadScene $ dataDir </> optFile opts | ||
|
||
(_, win) <- withWindow sdlWindowSystem "Seangine 0.1.1.0" 800 600 | ||
windowExts <- getVulkanExtensions win | ||
instance' <- withVulkanInstance windowExts | ||
(_, surface) <- withWindowSurface instance' win | ||
handles <- withVulkanHandles dataDir instance' surface | ||
|
||
let config = | ||
Config | ||
{ cfgVulkanHandles = handles, | ||
cfgOptions = opts | ||
} | ||
runVulkan config $ do | ||
pass | ||
|
||
loadScene :: MonadUnliftIO io => FilePath -> io Scene | ||
loadScene path = do | ||
result <- fromJsonFile path | ||
case result of | ||
Left _ -> throwIO ImpossibleError | ||
Right scene -> return scene |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module Graphics.Seangine.Config | ||
( Config (..), | ||
Options (..), | ||
HasConfig (..), | ||
HasOptions (..), | ||
) where | ||
|
||
import Graphics.Seangine.Config.VulkanHandles | ||
|
||
data Config = Config | ||
{ cfgVulkanHandles :: VulkanHandles, | ||
cfgOptions :: Options | ||
} | ||
|
||
data Options = Options | ||
{ optVerbose :: Bool, | ||
optFile :: FilePath | ||
} | ||
|
||
class HasConfig m where | ||
getVulkanHandles :: m VulkanHandles | ||
getOptions :: m Options | ||
|
||
class HasOptions m where | ||
getOptVerbose :: m Bool | ||
getOptFile :: m FilePath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Graphics.Seangine.Config.VulkanHandles | ||
( VulkanHandles (..), | ||
HasVulkan (..), | ||
noAllocationCallbacks, | ||
noPipelineCache, | ||
) where | ||
|
||
import Data.Vector (Vector) | ||
import Vulkan.Core10 | ||
import Vulkan.Extensions.VK_KHR_surface (PresentModeKHR, SurfaceCapabilitiesKHR, SurfaceFormatKHR) | ||
import VulkanMemoryAllocator (Allocator (..)) | ||
|
||
data VulkanHandles = VulkanHandles | ||
{ vhDataDir :: FilePath, | ||
vhInstance :: Instance, | ||
vhPhysicalDevice :: PhysicalDevice, | ||
vhDevice :: Device, | ||
vhAllocator :: Allocator, | ||
vhGraphicsQueue :: Queue, | ||
vhGraphicsQueueFamily :: Word32, | ||
vhPresentQueue :: Queue, | ||
vhPresentQueueFamily :: Word32, | ||
vhSurfaceCapabilities :: SurfaceCapabilitiesKHR, | ||
vhSurfaceFormats :: Vector SurfaceFormatKHR, | ||
vhPresentModes :: Vector PresentModeKHR, | ||
vhCommandPool :: CommandPool | ||
} | ||
|
||
class HasVulkan m where | ||
getDataDir :: m FilePath | ||
getInstance :: m Instance | ||
getPhysicalDevice :: m PhysicalDevice | ||
getDevice :: m Device | ||
getAllocator :: m Allocator | ||
getGraphicsQueue :: m Queue | ||
getGraphicsQueueFamily :: m Word32 | ||
getPresentQueue :: m Queue | ||
getPresentQueueFamily :: m Word32 | ||
getSurfaceCapabilities :: m SurfaceCapabilitiesKHR | ||
getSurfaceFormats :: m (Vector SurfaceFormatKHR) | ||
getPresentModes :: m (Vector PresentModeKHR) | ||
getCommandPool :: m CommandPool | ||
|
||
noAllocationCallbacks :: Maybe AllocationCallbacks | ||
noAllocationCallbacks = Nothing | ||
|
||
noPipelineCache :: PipelineCache | ||
noPipelineCache = NULL_HANDLE |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Graphics.Seangine.Monad.Config (Config (..), Options (..)) where | ||
|
||
import Graphics.Seangine.Monad.Vulkan (VulkanHandles (..)) | ||
|
||
data Config = Config | ||
{ cfgOptions :: Options, | ||
cfgVulkanHandles :: VulkanHandles | ||
} | ||
|
||
data Options = Options | ||
{optVerbose :: Bool} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.