From d6f46a7fcce34bc5438a71253917a43380163996 Mon Sep 17 00:00:00 2001 From: jgk Date: Fri, 12 Feb 2021 14:26:51 +0100 Subject: [PATCH] Reimplement text rendering, slow --- app/Main.hs | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.yaml | 17 +++++++++++ src/Lib.hs | 6 ---- stack.yaml | 3 +- 4 files changed, 96 insertions(+), 9 deletions(-) delete mode 100644 src/Lib.hs diff --git a/app/Main.hs b/app/Main.hs index de1c1ab35..edcbd9c29 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,6 +1,81 @@ module Main where -import Lib +import Loop +import EventHelper +import Shaders +import Render +import Shapes + +import Dodge.Rendering +import Dodge.RenderPicture +import Dodge.Picture +import Dodge.Prototypes +import Dodge.Data +import Dodge.Initialisation +import Dodge.Rooms +import Dodge.Layout +import Dodge.LoadSound +import Dodge.Update +import Dodge.KeyEvents +import Dodge.Preload + +import Control.Concurrent +import Control.Lens + +import System.Random + +import qualified SDL as SDL +import qualified SDL.Mixer as Mix +import Graphics.Rendering.OpenGL hiding (color,scale) +--Mix.openAudio Mix.defaultAudio 256 >> + +initWorld = initialWorld + { _randGen = mkStdGen 2 + , _windowX = 800 + , _windowY = 600 + } + +pps = [(0,0),(50,0),(0,25)] +ppt = [(0,0),(-50,0),(20,25)] + +tSh = TextShape + [((0.0,0.0,0),(1,0,1,1),(s,1)) + ,((0.5,0.0,0),(1,1,1,1),(e,1)) + ,((0.5,1.0,0),(1,1,1,1),(e,0)) + ,((0.0,1.0,0),(1,1,1,1),(s,0)) + ] + where x = 1/128 + s = 20 * x + e = s + x +tSh' = TShape' + [0.0,0.0,0,1,0,1,1,s,1 + ,0.5,0.0,0,1,1,1,1,e,1 + ,0.5,1.0,0,1,1,1,1,e,0 + ,0.0,1.0,0,1,1,1,1,s,0 + ] TriangleFan + where x = 1/128 + s = 20 * x + e = s + x +tSha = TShape' + [0.0,0.0,0,1,1,1,1 + ,50 ,0.0,0,1,1,1,1 + ,50 ,50 ,0,1,1,1,1 + ,0.0,1.0,0,1,1,1,1 + ] TriangleFan main :: IO () -main = someFunc +main = do +-- loadedSounds <- loadSounds + setupLoop + "windowName" + 800 600 + doPreload' + (initializeWorld $ generateFromTree lev1 $ initWorld) + (-- \((bs:fs:ts:_),tes) w -> --do render setparams w egFade + \preData w -> --do render setparams w egFade + renderPicture preData (draw blank w) + -- renderTex'' preData tSh + ) + handleEvent + (\w -> Just $ update w) + Mix.closeAudio diff --git a/package.yaml b/package.yaml index 85f30d865..41c8e2e91 100644 --- a/package.yaml +++ b/package.yaml @@ -21,6 +21,23 @@ description: Please see the README on GitHub at = 4.7 && < 5 +- containers +- unordered-containers +- heap +- sdl2 +- sdl2-mixer +- text +- OpenGL +- raw-strings-qq +- bytestring +- lens +- mtl +- fgl +- random +- bmp +- monad-loops +- JuicyPixels +- vector library: source-dirs: src diff --git a/src/Lib.hs b/src/Lib.hs deleted file mode 100644 index d36ff2714..000000000 --- a/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/stack.yaml b/stack.yaml index 9c85f7719..27dacda95 100644 --- a/stack.yaml +++ b/stack.yaml @@ -34,7 +34,8 @@ packages: # These entries can reference officially published versions as well as # forks / in-progress versions pinned to a git hash. For example: # -# extra-deps: +extra-deps: +- SDL-0.6.7.0@sha256:9d6ba75c0cab575ec38468c8277803983e985f9622437aeca6a53e6a7337a7d5,2045 # - acme-missiles-0.3 # - git: https://github.com/commercialhaskell/stack.git # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a