Git Product home page Git Product logo

Comments (2)

gre avatar gre commented on September 27, 2024

Are you referring to games like the snake example? When you have one canvas 2d for drawing and a canvas webgl for post-processing?

If so, it is not fixable in the library itself, glsl.js is a tiny toolkit on top of GLSL, using a canvas2d with it is already a specific use-case.

But you can easily solve that in different ways, here is one:
put the 2 canvas one on top of the other :)

canvas#2d {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
}
canvas#webgl {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
}

Then check for support:

// ... do your canvas #2d work
if (Glsl.supported()) {
  // Do your Glsl({ .. }) with the canvas #webgl
}

A canvas is transparent by default, so it should make the 2d canvas visible if you don't use it.

from deprecated-glsl.js.

anissen avatar anissen commented on September 27, 2024

I did indeed base this issue on the snakes example :)

I just figured that the library always took a canvas as input for the shaders but your response makes perfect sense when the input can be from any source(s).

Thanks for your reply and (another) great library :)

from deprecated-glsl.js.

Related Issues (14)

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.