Giter Site home page Giter Site logo

Comments (7)

Zinggi avatar Zinggi commented on September 26, 2024

This is quite a bummer.
I'm currently working on this little 2d rendering engine and this would be very much needed for any 2d game with sprites.

I've read the contributing.md, but this can't be added as a PATCH.

Best would be to add something like

toHtmlWithEvenMore
    :  { alpha: Bool, depth: Bool, stencil: Bool, antialias: Bool, premultipliedAlpha: Bool  }
    -> List FunctionCall
    -> List (Attribute msg)
    -> List Renderable
    -> Html msg

(Info to these properties here)

This would be a MINOR change.

I left out two properties because I don't really understand the first one and because I think the second one would be useless in elm:

  • preserveDrawingBuffer: If the value is true the buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
  • failIfMajorPerformanceCaveat: Boolean that indicates if a context will be created if the system performance is low.

I'm currently also doing the little shader trick from @w0rm combined with BlendFunc (One, OneMinusSrcAlpha), but this isn't a good solution.
The problem with this solution is that you also have to change the rendering order. This makes rendering multiple objects very unintuitive for a user.

from elm-webgl.

nphollon avatar nphollon commented on September 26, 2024

Possible alternative to @Zinggi API suggestion: What if we extended the Capability type to cover these attributes?

Then there would be no need to add a new toHtml-type function... you could just call Disable PremultipliedAlpha to your FunctionCall list. This would be a less invasive API change.

I realize that premultipliedAlpha is not actually a function call, but from an implementation perspective I don't see a problem with treating it like one. What would y'all think? Would this be confusing?

from elm-webgl.

Zinggi avatar Zinggi commented on September 26, 2024

@nphollon, I like the suggestion, but there is a problem with it.

You can use List FunctionCall as an agrument to renderWithConfig too.
Now with your suggestion you could then write a nonsense renderWithConfig [Enable PremultipliedAlpha] which doesn't make sense on a per render basis, as it (premultipliedAlpha) only applies to the top-level canvas element.

It would be a way to avoid bumping the version, but it wouldn't be the best API.

I think someone has to bother Evan for this. It's not critical, but it would be a big improvement. I would go ahead and implement it, but first I have to know whether a pull request would even be accepted.

from elm-webgl.

nphollon avatar nphollon commented on September 26, 2024

Good point, I had forgotten about renderWithConfig. (It would have required a version bump anyway, since it would involve changing a type definition.)

As for whether the PR would be accepted, you can get approval from either @evancz or @johnpmayer. We also have #32 waiting for approval at the moment. I think it would make sense to release the updates together if they both get the thumbs up.

from elm-webgl.

Zinggi avatar Zinggi commented on September 26, 2024

All right, I'll try to get my hands dirty on this one.
Will take some time though, as I haven't done native stuff yet.

from elm-webgl.

Zinggi avatar Zinggi commented on September 26, 2024

Ok, so I implemented this here: #38

from elm-webgl.

w0rm avatar w0rm commented on September 26, 2024

This is implemented as the part of 2.0.

from elm-webgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.