GithubHelp home page GithubHelp logo

Handle WebGL context loss about wasm4 HOT 4 CLOSED

aduros avatar aduros commented on May 16, 2024
Handle WebGL context loss

from wasm4.

Comments (4)

takaeri avatar takaeri commented on May 16, 2024 2

Once #44 lands, I'll work on handling this issue

from wasm4.

aduros avatar aduros commented on May 16, 2024 1

Thanks, yeah, it looks like it should be pretty easy. The GL init stuff in compositor.js needs to be pulled out into a function, and that function called on webglcontextrestored. composite() should also return early if gl.isContextLost().

Let's get #44 merged first, since it touches a lot of the same code.

A PR would be very welcome!

from wasm4.

takaeri avatar takaeri commented on May 16, 2024

Take a look into this

  1. add a lost context handler and tell it to prevent the default behavior
var canvas = document.getElementById("myCanvas");
canvas.addEventListener("webglcontextlost", function(event) {
    event.preventDefault();
}, false);
  1. re-setup all your WebGL state and re-create all your WebGL resources when the context is restored.
canvas.addEventListener(
    "webglcontextrestored", setupWebGLStateAndResources, false);

I can submit a PR but I'm quite busy this week

from wasm4.

aduros avatar aduros commented on May 16, 2024

#44 has landed if you still want to take a crack at this one πŸ˜ƒ

from wasm4.

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.