diff --git a/cabal.project b/cabal.project index 3131004..69125d8 100644 --- a/cabal.project +++ b/cabal.project @@ -20,6 +20,7 @@ packages: -- ~/Developer/vector/vector -- ~/Developer/vector/vector-stream/ -- ~/Developer/linear-base-fork/ + ~/Developer/fir/ package dear-imgui flags: +glfw +vulkan -sdl -opengl3 @@ -34,9 +35,9 @@ allow-newer: linear-apecs:*, typelits-witnesses:* -source-repository-package - type: git - location: https://gitlab.com/sheaf/fir.git +-- source-repository-package +-- type: git +-- location: https://gitlab.com/sheaf/fir.git source-repository-package type: git @@ -84,3 +85,4 @@ source-repository-package location: https://github.com/sheaf/packages subdir: haskus-utils-variant tag: 8a69e7bc8873c04d5b671271c2dbdf759f405a56 + diff --git a/games/ghengin-games.cabal b/games/ghengin-games.cabal index 630e7db..b2734fc 100644 --- a/games/ghengin-games.cabal +++ b/games/ghengin-games.cabal @@ -88,7 +88,8 @@ executable planets-core ghengin-vulkan, ghengin-core-indep, mtl, vector, hsnoise, containers, random, linear-base, - derive-storable, geomancy, vulkan, time, ghengin-geometry + derive-storable, geomancy, vulkan, time, ghengin-geometry, + fir ghc-options: -dcmm-lint -dstg-lint -dasm-lint -g2 -rtsopts -debug -Wno-partial-type-signatures cpp-options: -DDEBUG diff --git a/games/planets-core/Planet.hs b/games/planets-core/Planet.hs index 3f5e805..58c8c95 100644 --- a/games/planets-core/Planet.hs +++ b/games/planets-core/Planet.hs @@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE UndecidableInstances #-} module Planet where import qualified Prelude as P @@ -19,13 +20,16 @@ import qualified Data.List.NonEmpty as NE import Ghengin.Core import Ghengin.Core.Mesh +import Ghengin.Core.Shader () -- instance Syntactic Float import Geomancy.Vec3 import Game.Geometry.Sphere import Foreign.Storable.Generic import qualified FIR +import FIR.AST (FromGenericProduct(..)) import qualified Math.Linear as FIR +import qualified Generics.SOP as SOP -------------------------------------------------------------------------------- -- * Planet @@ -42,14 +46,18 @@ data PlanetSettings = PlanetSettings { resolution :: !Int data DisplayFace = All | FaceUp | FaceRight deriving Show + + data MinMax = MinMax !Float !Float - deriving (P.Eq, Generic, Show, GStorable) -instance FIR.Syntactic MinMax where - type Internal MinMax = FIR.Val (FIR.Struct '[ "min" 'FIR.:-> FIR.Float, "max" 'FIR.:-> FIR.Float ]) - toAST (MinMax x y) = FIR.Struct (FIR.Lit x FIR.:& FIR.Lit y FIR.:& FIR.End) - fromAST struct = case (FIR.view @(FIR.Name "min") struct, FIR.view @(FIR.Name "max") struct) of - (FIR.Lit x, FIR.Lit y) -> MinMax x y - _ -> error "impossible" + deriving (P.Eq, Generic, SOP.Generic, Show, GStorable) + deriving FIR.Syntactic via (FromGenericProduct MinMax ["min", "max"]) + +-- instance FIR.Syntactic MinMax where +-- type Internal MinMax = FIR.Val (FIR.Struct '[ "min" 'FIR.:-> FIR.Float, "max" 'FIR.:-> FIR.Float ]) +-- toAST (MinMax x y) = FIR.Struct (FIR.Lit x FIR.:& FIR.Lit y FIR.:& FIR.End) +-- fromAST struct = case (FIR.view @(FIR.Name "min") struct, FIR.view @(FIR.Name "max") struct) of +-- (FIR.Lit x, FIR.Lit y) -> MinMax x y +-- _ -> error "impossible" newPlanetMesh :: CompatibleVertex '[Vec3, Vec3, Vec3] π => RenderPipeline π bs diff --git a/ghengin-core/ghengin-core.cabal b/ghengin-core/ghengin-core.cabal index aa2077e..be8bbf7 100644 --- a/ghengin-core/ghengin-core.cabal +++ b/ghengin-core/ghengin-core.cabal @@ -113,7 +113,9 @@ library -- FIR re-exports, so people can import FIR without depending on fir (it's -- already a transitive dependency, we simply make it easier to access) - reexported-modules: FIR, Math.Linear, Math.Quaternion + reexported-modules: FIR, Math.Linear, Math.Quaternion, + -- generics-sop, for deriving generically + Generics.SOP hs-source-dirs: ghengin-core @@ -127,6 +129,7 @@ library containers, mtl, vector, + generics-sop, gl-block,