0
我寫了一個小函數在着色器之間切換,但不幸的是它不起作用。 我創建着色器並將其作爲着色器對象返回。WebGL:在着色器之間切換
程序= gl.createProgram(VS,FS, 「VertexPosition」, 「TextureCoord」, 「VertexNormal」);深度程序= gl.createProgram(vs,fs,「VertexPosition」,false,false);
我使用開關功能,其中包括我的更新功能:
function Update(){
gl.switchProgram(program);
gl.Draw(Teapot, cam);
};
模型的所有緩衝器都在繪製函數綁定,(參數:模型,攝像機位置)
this.switchProgram = function(program){
if (this.program !== program){
this.lastprogram = this.program;
this.program = program;
gl.useProgram(this.program);
};
};
這裏是所產生的誤差:WebGL的:INVALID_OPERATION:drawElements:attribs沒有設置正確 如果我評論一切工作正常,但我無法切換:(
depthprogram = gl.createProgram(vs, fs, "VertexPosition", false, false);
gl.switchProgram(program);
thx,我發現我的問題:) – Pris0n 2013-05-19 15:02:52