Why doesn't "webgl" context work on Chrome? -
this piece of code returns null
on chrome returns proper context on firefox.
var create3dcontext = function(canvas, opt_attribs) { var names = ["webgl", "experimental-webgl"]; var context = null; (var ii = 0; ii < names.length; ++ii) { try { context = canvas.getcontext(names[ii], opt_attribs); } catch(e) {} if (context) { break; } } return context; }
this how called:
var setupwebgl = function(canvas, opt_attribs) { function showlink(str) { var container = canvas.parentnode; if (container) { container.innerhtml = makefailhtml(str); } }; if (!window.webglrenderingcontext) { showlink(get_a_webgl_browser); return null; } var context = create3dcontext(canvas, opt_attribs); if (!context) { showlink(other_problem); } return context; }; var getwebglcontext = function(canvas, opt_attribs) { if (isiniframe()) { updatecssifiniframe(); // make canvas backing store size it's displayed. canvas.width = canvas.clientwidth; canvas.height = canvas.clientheight; } else { var title = document.title; var h1 = document.createelement("h1"); h1.innertext = title; document.body.insertbefore(h1, document.body.children[0]); } var gl = setupwebgl(canvas, opt_attribs); return gl; }; var isiniframe = function() { return window != window.top; }; getwebglcontext(document.getelementbyid("canvas"));
Comments
Post a Comment