# \[Ann\] marching-cubes

**URL:** <https://discourse.haskell.org/t/ann-marching-cubes/5838>\
**Category:** Announcements\
**Created:** [February 20, 2023, 1:13pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838 "2023-02-20T13:13:22Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 1:13pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/1 "2023-02-20T13:13:22Z")

</div>

Hello,

I’ve released the **marching-cubes** library on Hackage today. [Here](https://github.com/stla/isosurfaces) is a repository containing some examples. The marching cubes algorithm is used to construct 3D isosurfaces.

Would you know why the Github actions of this repository are unable to build **OpenGLRaw**?

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [February 20, 2023, 1:23pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/2 "2023-02-20T13:23:28Z")

</div>

> [@stla](#):
>
> Would you know why the Github actions of this repository are unable to build **OpenGLRaw**?

The logs say:

> ```haskell
> OpenGLRaw > Cabal-simple_SvXsv1f__3.6.3.0_ghc-9.2.5: Missing dependency on a foreign
> OpenGLRaw > library:
> OpenGLRaw > * Missing (or bad) C library: GL
> OpenGLRaw > This problem can usually be solved by installing the system package that
> OpenGLRaw > provides this library (you may need the "-dev" version). If the library is
> OpenGLRaw > already installed but in a non-standard location then you can use the flags
> OpenGLRaw > --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
> OpenGLRaw > library file does exist, it may contain errors that are caught by the C
> OpenGLRaw > compiler at the preprocessing stage. In this case you can re-run configure
> OpenGLRaw > with the verbosity flag -v3 to see the error messages.
> 
> ```

That means that you need to install the `libgl-dev` package (that is the name for Ubuntu/Debian). Although I don’t know how to actually do that with GitHub actions.

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 1:32pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/3 "2023-02-20T13:32:00Z")

</div>

Thanks. I try with `sudo apt-get install --yes libgl-dev`. Maybe this will work, but with the Ubuntu OS only of course.

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 1:46pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/4 "2023-02-20T13:46:13Z")

</div>

The installation of `libgl-dev` has worked! But there are other missing libraries, I’m currently trying to install them.

That said, this is for Ubuntu only. How to do for Mac and Windows? Here is my _ **yaml** _ file:

```haskell
name: Stack-nightly

on:
  pull_request:
  push:
    branches: [main, master]

jobs:
  test:
    strategy:
      matrix:
        runner:
          - ubuntu-latest
          - macOS-latest
          - windows-latest

      fail-fast: false

    runs-on: ${{ matrix.runner }}

    steps:
      - uses: actions/checkout@v3

      - name: Install libgl
        run: |
          sudo apt-get install --yes libgl-dev

      - name: Install mesa-utils
        run: |
          sudo apt-get install --yes mesa-utils

      - name: Install freeglut3
        run: |
          sudo apt-get install --yes freeglut3-dev

      - uses: freckle/stack-action@v3

      - id: stack
        uses: freckle/stack-action@v3
        with:
          stack-arguments: --resolver nightly --copy-bins --coverage

      - uses: actions/upload-artifact@v2
        with:
          name: coverage-report
          path: ${{ steps.stack.outputs.local-hpc-root }}

```

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 1:50pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/5 "2023-02-20T13:50:49Z")

</div>

Actually the installation works on Windows, but there’s an issue with one of my own modules:

```haskell
src\Colors\ColorRamp.hs:16:1: error: [-Worphans, -Werror=orphans]
    Orphan instance: instance Unbox a => Unbox (Color4 a)
    To avoid this
        move the instance declaration to the module of the class or of the type, or
        wrap the type with a newtype and declare the instance on the new type.

```

I never knew how to deal with the “orphan instance” warnings. Would you know? Otherwise, how to change the ghc options in order that it doesn’t throw an error for that?

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 2:17pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/6 "2023-02-20T14:17:14Z")

</div>

I found a solution. I put

```haskell
{-# OPTIONS_GHC -fno-warn-orphans #-}

```

at the top of the file.

---

<div class="post-metadata">

**Author:** ![ParetoOptimalDev](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@ParetoOptimalDev](https://discourse.haskell.org/u/ParetoOptimalDev)\
**Post date:** [February 20, 2023, 3:59pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/7 "2023-02-20T15:59:15Z")

</div>

I use Nix to avoid this kind of problem. You will probably either love or hate it. Here’s an example:

> **[GitHub - ParetoOptimalDev/apecs-shmup-example: A nix flake with the apecs...](https://github.com/ParetoOptimalDev/apecs-shmup-example)**
>
> A nix flake with the apecs shmup example. Contribute to ParetoOptimalDev/apecs-shmup-example development by creating an account on GitHub.

Note that if you have a `flake.nix` people could run examples from your repo _without worrying about dependencies at all_ with the `nix run` command like:

```haskell
nix run git:stla/isosurfaces/OpenGL .#Invader

```

or:

```haskell
nix run git:stla/isosurfaces/OpenGL .#Goursat

```

and a good way to see if it Nix might be right for you (or not) is to go through:

> **[Zero to Nix](https://zero-to-nix.com/)**
>
> An unofficial, opinionated, gentle introduction to Nix

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 20, 2023, 5:55pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/8 "2023-02-20T17:55:11Z")

</div>

Thanks, that looks amazing. I will take a look more carefully.

---

<div class="post-metadata">

**Author:** ![ocharles](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocharles/32/102_2.png) [@ocharles](https://discourse.haskell.org/u/ocharles)\
**Post date:** [February 21, 2023, 8:56am UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/9 "2023-02-21T08:56:04Z")

</div>

Very cool! I always wanted to implement the marching cubes algorithm - I know it would make 13-year-old-me very happy if I ever get a time machine!

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stla/32/2990_2.png) [@stla](https://discourse.haskell.org/u/stla)\
**Post date:** [February 23, 2023, 5:48pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/10 "2023-02-23T17:48:47Z")

</div>

I’m going to release [**marching-cubes2**](https://github.com/stla/marching-cubes2). It is better.

---

<div class="post-metadata">

**Author:** ![sclv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sclv/32/71_2.png) [@sclv](https://discourse.haskell.org/u/sclv)\
**Post date:** [February 23, 2023, 10:43pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/11 "2023-02-23T22:43:26Z")

</div>

I saw you made another thread for that. In the future, please note the “custom” here would be to just bump the existing thread for such a release.

---

<div class="post-metadata">

**Author:** ![jackdk](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jackdk](https://discourse.haskell.org/u/jackdk)\
**Post date:** [February 24, 2023, 2:55am UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/12 "2023-02-24T02:55:38Z")

</div>

The “best” solution is to upstream the instance to the package which either declares the class or the data structure. When that’s not possible, some people create an intermediate package whose entire job is to provide these instances.

---

<div class="post-metadata">

**Author:** ![ocharles](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocharles/32/102_2.png) [@ocharles](https://discourse.haskell.org/u/ocharles)\
**Post date:** [February 24, 2023, 9:34am UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/13 "2023-02-24T09:34:18Z")

</div>

Is this true? I tend to make a new discussion for all new release of my packages, rather than having one thread per package.

---

<div class="post-metadata">

**Author:** ![sclv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sclv/32/71_2.png) [@sclv](https://discourse.haskell.org/u/sclv)\
**Post date:** [February 24, 2023, 8:01pm UTC](https://discourse.haskell.org/t/ann-marching-cubes/5838/14 "2023-02-24T20:01:17Z")

</div>

Well in this case, one thread was made only three days after the other. If there was say a six month interval or more, then maybe a different choice would have made sense. Here, one thread hadn’t even fallen out of the top five before the next was made!
