From b192d6a5c4ed78af2155df9de9608607af769f81 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 6 Jan 2020 14:16:32 -0500 Subject: [PATCH 1/2] Copute sweep &c. in the shader. --- src/Starlight/Draw/Radar.hs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Starlight/Draw/Radar.hs b/src/Starlight/Draw/Radar.hs index ea9b9828..482e5d70 100644 --- a/src/Starlight/Draw/Radar.hs +++ b/src/Starlight/Draw/Radar.hs @@ -119,15 +119,30 @@ verticesForShips cs = ] +instanceCount :: Int +instanceCount = 1 + + shader :: Shader U V O shader = program $ \ u - -> vertex (\ V{ there, colour } IF{ colour2 = out } -> do - pos <- let' "pos" ((there - here u) D.^* (1/D.norm (there - here u))) + -> vertex (\ V{ there, r, colour } IF{ colour2 = out } -> do + there <- let' "there" (there - here u) + d <- let' "d" (D.norm there) + dir <- let' "dir" (there D.^* (1/D.norm there)) + let perp v = vec2 (negate (v D.^.D._y)) (v D.^.D._x) + angleOf vec = atan2' (vec D.^.D._y) (vec D.^.D._x) + wrap mn mx x = ((x + mx) `mod'` (mx - mn)) + mn + edge <- let' "edge" (perp dir D.^* r + dir D.^* d) + angle <- let' "angle" (angleOf there) + sweep <- let' "sweep" (minSweep `D.max'` (abs (wrap (-pi) pi (angleOf edge - angle)))) + theta <- let' "theta" (angle + (float gl_InstanceID / fromIntegral instanceCount) * sweep) + pos <- let' "pos" (vec2 (cos theta) (sin theta)) gl_PointSize .= 3 out .= colour gl_Position .= ext4 (ext3 ((matrix u !* ext3 pos 1) D.^. D._xy) 0) 1) - >>> fragment (\ IF{ colour2 } O{ fragColour } -> fragColour .= colour2) + >>> fragment (\ IF{ colour2 } O{ fragColour } -> fragColour .= colour2) where + minSweep = 0.0133 -- at radius'=150, makes approx. 4px blips data U v = U From eb9c3d707e971ce1f689b1af07086ce703f59c79 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 6 Jan 2020 15:25:33 -0500 Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"This=20doesn=E2=80=99t=20work."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ff0624eeec7e298bfe7d1de4a7d624bd803545a4. --- .github/workflows/haskell.yml | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/haskell.yml diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml new file mode 100644 index 00000000..d7a5ba7e --- /dev/null +++ b/.github/workflows/haskell.yml @@ -0,0 +1,62 @@ +name: Haskell CI + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + +jobs: + build: + name: ghc ${{ matrix.ghc }} + runs-on: ubuntu-16.04 + strategy: + matrix: + ghc: ["8.8.1"] + cabal: ["3.0"] + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/setup-haskell@v1 + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + # We cache the elements of the Cabal store separately, + # as the entirety of ~/.cabal can grow very large + # for projects with many dependencies. + + - uses: actions/cache@v1 + name: Cache ~/.cabal/packages + with: + path: ~/.cabal/packages + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages + - uses: actions/cache@v1 + name: Cache ~/.cabal/store + with: + path: ~/.cabal/store + key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store + - uses: actions/cache@v1 + name: Cache dist-newstyle + with: + path: dist-newstyle + key: ${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle + + - name: Install sdl2 + run: | + sudo apt-get install libsdl2-dev + + - name: Install dependencies + run: | + cabal v2-update + cabal v2-configure --enable-tests --enable-documentation --write-ghc-environment-files=always + cabal v2-build --only-dependencies + - name: Build & test + run: | + cabal v2-build + echo 'No tests'