On Fri, Mar 16, 2012 at 12:58 PM, Gregg Tavares (å) <firstname.lastname@example.org>
All the ones below here NEED to continue to allow NULL otherwise they will start throwing exceptions on context lost when all the createXXX functions start returning NULL.
I think that's a bit of a design error.Â If you call eg. createTexture while the context is lost, it should probably return a WebGLTexture with the invalidated flag already set, instead of returning null.
This has a few benefits.Â First, it eliminates the above problem; functions don't need to be nullable when it's not the natural thing to do.
Second, it reduces the number of failure cases.Â Currently, if you do the following, two different things might happen on context loss:
tex = ctx.createTexture();
If the context was lost before createTexture is called, tex is null.Â However, the context might be lost *between* the createTexture and bindTexture calls.Â If that happens, bindTexture receives a non-null texture whose invalidated flag is set.Â These cases would be merged, so there's only one error path to worry about.
Third, that things like this don't break in subtle, racy ways, because tex is never null: