Skip to content

Commit

Permalink
Enourmous progress towards making the Core render
Browse files Browse the repository at this point in the history
That is, moving the core rendering procedure involving the render queue
of render packets to the Core of the engine, rather than having it in
ghengin and full of issues with Apecs

Now, we have a Core monad, which threads through a RenderQueue (which
can be altered in its course, to update things like render properties of
render packets), and always render things which are available in the
render queue (which can be manipulated by the game developer)

This Core monad will allow the user to define render packets and render
them through Core only.

We're getting some steps closer to being able to define a demo that uses
ghengin-core only, and uses its own entity management system, camera and
world-to-clip-space transformations, etc...

PS: In the next commit the engine should get back to compiling
  • Loading branch information
alt-romes committed Jul 9, 2023
1 parent e8e85cb commit 5b0599d
Show file tree
Hide file tree
Showing 16 changed files with 605 additions and 54 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,42 @@ truly awful, painful experience.

The assets folder is copied to the bundle, so all resources should be in assets

## ghengin-core

What `ghengin-core` does and does not:

- Does not implement a game-loop, nor a time step strategy
- Does not implement a scene-graph
- Nor (game) object positioning in terms of so-called "world coordinates"
- Does not provide a camera
- Does not manage game objects/entities in any way (no ECS, no FRP, actually, no concept of game object whatsover)
- Does not have a UI abstraction, but will allow renderpasses to be managed in such a way that one can add outside of Core, e.g., a dear-imgui render pass
- Has an (editable) Render Queue with the render packets (meshes + properties + material properties + pipeline with shader) that are rendered every frame
- Can express all of the above things it "does not" do with the existing concepts and combinators
- Handles double-buffering (eventually configurable?) semantics for the 'render' function, i.e. blocks after drawing a second frame
- Actually, it's the renderer implementation that handles this

## Add-ons

These add-ons exist as separate packages, and are all included in `ghengin`, the
batteries included engine. These also attempt to be somewhat independent from
ghengin-core when possible.

- `ghengin-scene-graph`, which defines a scene-graph and world coordinate space
with objects related in a hieararchy with properties defined relative to
their parents (i.e. a scene, in its usual meaning)
- `ghengin-camera`, a camera object, shader, and update function (i.e. a camera, in its usual meaning)
- `ghengin-models`, to load and render 3D models
- `ghengin-lighting`, that provides lighting functions/models like the Blinn-Phong model
- `ghengin-dearimgui`, for UIs based on ghengin

## Ghengin

`ghengin` provides game-development abstractions on top of `ghengin-core`, and
is more developer friendly in the sense that it *does not* require linear types

## Other design ideas

- The `render/draw` function takes an action which "draws" things, which,
depending on the implementation, either batches the drawcall or actually
makes the draw call.
6 changes: 6 additions & 0 deletions ghengin-core-indep/ghengin-core-indep/Ghengin/Core/Log.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import Ghengin.Core.Prelude as G
import System.Log.FastLogger
import qualified Prelude (take)

import Control.Functor.Linear as Linear

#ifdef THINGS_ARE_GOING_THAT_BAD
-- In that case we always flush and use BS.putStr
import qualified Data.ByteString as BS
Expand All @@ -32,6 +34,10 @@ class MonadIO m => HasLogger m where
-- HasLogger for all MonadTrans over a HasLogger m.
withLevelUp :: m a m a

instance (MonadIO m, HasLogger m) => HasLogger (StateT s m) where
getLogger = lift getLogger
withLevelUp (StateT m) = StateT $ \s -> withLevelUp (m s)

-- | Returns a new logger and an IO cleanup action
newLogger :: MonadIO m => LogType -> m (Ur Logger, IO ())
{-# INLINE newLogger #-}
Expand Down
3 changes: 3 additions & 0 deletions ghengin-core-indep/ghengin-core-indep/Ghengin/Core/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,7 @@ l2vec = Unsafe.toLinear V.fromList
vec2l :: V.Vector a [a]
vec2l = Unsafe.toLinear V.toList

--- More orphans

instance MonadIO m => MonadIO (StateT s m) where
liftIO io = StateT $ \s -> (,s) <$> liftIO io
36 changes: 33 additions & 3 deletions ghengin-core/ghengin-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,17 @@ library
Ghengin.Core.Render.Property,
Ghengin.Core.Render.Packet,
Ghengin.Core.Render.Queue,
Ghengin.Core.Render,
Ghengin.Core.Render

Ghengin.Core.Renderer
signatures: Ghengin.Core.Renderer.Kernel,
signatures: Ghengin.Core.Renderer,
Ghengin.Core.Renderer.Kernel,
Ghengin.Core.Renderer.DescriptorSet,
Ghengin.Core.Renderer.Buffer,
Ghengin.Core.Renderer.Pipeline,
Ghengin.Core.Renderer.RenderPass,
Ghengin.Core.Renderer.Texture,
Ghengin.Core.Renderer.Sampler,
Ghengin.Core.Renderer.Command

hs-source-dirs: ghengin-core

Expand All @@ -113,10 +114,39 @@ library
reference-counting,

containers,
mtl,
vector,

gl-block,

ghengin-core-indep,
linear-utils

executable planets-core
main-is: Main.hs
default-extensions: UnicodeSyntax
build-depends:
base >=4.17.0.0,
-- Can't depend on this without instancing it because of backpack
ghengin-core,
ghengin-vulkan,
ghengin-core-indep,
mtl, vector, hsnoise, containers, random, linear-base,
derive-storable

ghc-options: -dcmm-lint -dstg-lint -dasm-lint -g2 -rtsopts -debug
cpp-options: -DDEBUG

hs-source-dirs: planets-core
mixins: ghengin-core
requires ( Ghengin.Core.Renderer.Kernel as Ghengin.Vulkan.Renderer.Kernel
, Ghengin.Core.Renderer.DescriptorSet as Ghengin.Vulkan.Renderer.DescriptorSet
, Ghengin.Core.Renderer.Buffer as Ghengin.Vulkan.Renderer.Buffer
, Ghengin.Core.Renderer.Pipeline as Ghengin.Vulkan.Renderer.Pipeline
, Ghengin.Core.Renderer.RenderPass as Ghengin.Vulkan.Renderer.RenderPass
, Ghengin.Core.Renderer.Texture as Ghengin.Vulkan.Renderer.Texture
, Ghengin.Core.Renderer.Sampler as Ghengin.Vulkan.Renderer.Sampler
, Ghengin.Core.Renderer.Command as Ghengin.Vulkan.Renderer.Command
, Ghengin.Core.Renderer as Ghengin.Vulkan.Renderer
)
default-language: GHC2021
Loading

0 comments on commit 5b0599d

Please sign in to comment.