シェーダーを切り替える小さな関数を書きましたが、残念ながら機能しません。シェーダーを作成し、シェーダー オブジェクトとして返します。
program = gl.createProgram(vs, fs, "VertexPosition", "TextureCoord", "VertexNormal");
depthprogram = 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 not setup correctly
depthprogram = gl.createProgram(vs, fs, "VertexPosition", false, false);
gl.switchProgram(program);