[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Handling context lost in WebGL
- To: Mark Callow <callow_mark@hicorp.co.jp>
- Subject: Re: [Public WebGL] Handling context lost in WebGL
- From: "Gregg Tavares (wrk)" <gman@google.com>
- Date: Wed, 12 Oct 2011 22:37:44 -0700
- Cc: public webgl <public_webgl@khronos.org>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1318484266; bh=RqVNqMzxDnI+1ca0jyPfW+4LwRA=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type; b=QNXVDbl3Nztozw2pi8qfhMI4Uq7tKWB39c9cFkepuExqTXMWx1VtVN/Fi743fFXot fIMXZyMpfh7YW755Ecmlw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record; bh=GcWlPP5vtmy1AUnUZt8IG/sd5BwSG87dB0czqUj7YGQ=; b=qwddqOPJBI8viiv0dRC9LW/ofqavK/XgI+JHDL5+QlaGiuO07NS2pr8VoGaRXHop++ 8TrI2TtSAnvwny2d1fWw==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=dkim-signature:mime-version:in-reply-to:references:date: message-id:subject:from:to:cc:content-type:x-system-of-record; b=BkoYbzniOP3algeh7GllBHp0w1w67Ee6KSP5Y9ut5ogDy/J8SppLR1PXJpi54odG8 0Pj6bTaQ7AhmMRpuACLYg==
- In-reply-to: <4E964DF2.6030907@hicorp.co.jp>
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- References: <CAKZ+BNoeeBdz7yJwHcq+0i7oM5WOPa1f_qei6SkDheZptvbWYA@mail.gmail.com> <4E964DF2.6030907@hicorp.co.jp>
- Sender: owner-public_webgl@khronos.org
On Wed, Oct 12, 2011 at 7:33 PM, Mark Callow
<callow_mark@hicorp.co.jp> wrote:
In
function init() {
canvas.removeEventListener(‘mousemove’, mouseMoveHandler, false);
...
var mouseUniformLocation = gl.getUniformLocation(program, “uMouse”);
...
function mouseMoveHandler(event) {
gl.uniform2f(mouseIniformLocation, event.x, event.y);
}
canvas.addEventListener(‘mousemove’, mouseMoveHandler, false);
...
do you really need the first line?
Yes. I fixed a typo above (and on the wiki). Maybe that makes it clearer?
There were 2 issues
1) init is called more than once (at the beginning and each time the context is restored).
That means a new mouseUniformLocation is created each time. If you made mouseUniformLocation a global instead of a local it would work for example.
2) when you use an anonymous function as an eventListener there is no way to remove it since you need to pass it to removeEventListener
Since the handler is no longer
an anonymous function, it should use the current value of
mouseUniformLocation when called.
I think this is a very useful document. Thanks for preparing it.
Regards
-Mark
On 13/10/2011 10:25, Gregg Tavares (wrk) wrote:
I just got through updating all the
demos on the Khronos WebGL SDK to handle context lost
I wrote up some of the issues I ran into and their
solutions and put them on the WebGL Wiki here
I hope that's useful.
-gregg