Jak mohu přidat podporu pro prohlížeč vybavení, jako jsou WebGL na psacím stroji?

hlasů
6
var canvas = <HTMLCanvasElement>document.getElementById('canvas1');
var gl = canvas.getContext('webgl');
canvas.width = 400;
canvas.height = 400;
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);

Dále jen „HTMLCanvasElement“ jen zdá, že nabízejí 2D metody plátno. To mi nedovolí sestavit gl.viewport () atd. Jak přidám tuto podporu WebGL?

Položena 08/10/2012 v 06:14
zdroj uživatelem
V jiných jazycích...                            


1 odpovědí

hlasů
10

Je potřeba definovat metody WebGL před použitím. Můžete si najít nějaké komunitní psaný WebGL psát zde . Přidejte WebGL.d.ts do projektu a říkat to takhle:

///<reference path="WebGL.d.ts" />

var canvas = <any>document.getElementById('canvas1');
var gl =  <WebGLRenderingContext> canvas.getContext('webgl');
canvas.width = 400;
canvas.height = 400;
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
Odpovězeno 08/10/2012 v 06:38
zdroj uživatelem

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more