Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8236959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:18:30+00:00 2026-06-07T19:18:30+00:00

I found a nifty JavaScript library that allows for hardware accelerated canvas 2d drawing:

  • 0

I found a nifty JavaScript library that allows for “hardware accelerated” canvas 2d drawing: https://github.com/corbanbrook/webgl-2d

I tried the example out and the first frame renders like it should, but after the first frame, the canvas is white.

I setup a fiddle here: http://jsfiddle.net/RaW5x/5/

I have to assume it is the library because this is the example from the repository.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:18:32+00:00Added an answer on June 7, 2026 at 7:18 pm

    Short answer: I don’t think it’s the library’s fault, but it is definitely an issue that the library should resolve.

    Specifically, webgl-2d sets the GL color mask during initialization using gl.colorMask(1, 1, 1, 0) — thus blocking any writes to the alpha channel.

    Now, I must admit that I’m not entirely sure what’s happening to turn the screen white. The blend function is (src alpha, one minus src alpha), which means that for every color written out, it will be blended with the background color according to the source alpha component. To simplify the explanation, here’s the formula for just the Red channel:

    Red = Rs * As + Rd * (1 - As)
    

    …where Rs is the source (new) Red channel, As is the source Alpha channel, and Rd is the destination (current background) Red channel.

    So, if we assume a Red color of 50 (or ~0.196 in WebGL), my understanding is that what should be happening is:

    Red = 0.196 * 1 + 0.196 * (1 - 1) = 0.196
    

    In other words, it should be replacing the previous color with the new one.

    As long as the source channel equals the destination channel, even where alpha other than 1.0 is involved, the numbers change a bit, but not the result:

    Red = 0.196 * 0.5 + 0.196 * (1 - 0.5) = 0.196
    

    The result would obviously change if the destination Red channel is, in fact, different from the source channel, but even then I don’t see how it works out to a white color. If the issue were due solely to blending, I would expect an incremental step towards white based on the value in the Alpha channel, not a “jump” to white in a single frame.

    So mathematically, it looks fine to me. But, I can reproduce this issue in my own WebGL framework (Jax) by setting the color mask to prevent alpha writes, so it’s not completely the fault of the library. My guess is this could be a bug in the OpenGL drivers on your and my (and countless other) machines.

    I will continue to research this issue, and update this answer if I can learn anything.

    Regardless, the problem can be resolved within the webgl-2d library. I have submitted a pull request to the developer. (FYI, the repo you linked in the question was a fork from the original repository; I can’t tell who the current maintainer is so I sent the pull request to the original repository.)

    Until the pull request is (hopefully) accepted, or the issue is otherwise resolved, I believe you can do this:

    ctxGL.colorMask(1, 1, 1, 1);
    

    …before doing any rendering, and it should Just Work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I once found a nifty little library that used JNI to allow java applications
I found a nifty RegEx function that I'm using (see below). The function outputs
I found this nifty plugin that lets me create dashboard widgets from external files.
for Linux, there is a nifty little library called xbindkeys that (surprise) binds commands
Found a nice drop down menu: Demo: http://www.jqueryload.com/examples/menu/ HTML, CSS & JavaScript: http://www.jqueryload.com/jquery-dropdown-menu-with-google-style I've
found this little code snippet that seems to do what i want, but im
Found a piece of code today, that I find a little smelly... TMyObject.LoadFromFile(const filename:
I recently found out about the awesomeness of the iTunes COM for Windows SDK.
I have this nifty little script that does a nice job of manipulating some
I found a nifty little php function to check whether a url is an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.