[code]/**
* Renders the quad
*/
render() {
this.gl.useProgram(this.program);
this.gl.bindBuffer(Laya.WebGLContext.ARRAY_BUFFER, this.vertexPositionBuffer);
this.gl.enableVertexAttribArray(this.vertexPositionAttribute);
this.gl.vertexAttribPointer(
this.vertexPositionAttribute,
this.vertexPositionBuffer.itemSize,
Laya.WebGLContext.FLOAT,
false,
0,
0
);
this.gl.bindBuffer(Laya.WebGLContext.ARRAY_BUFFER, this.textureCoordBuffer);
// Check the current orientation of the device combined with the
// orientation of the VRSeeThroughCamera to determine the correct UV
// coordinates to be used.
const combinedOrientation = combineOrientations(
window.screen.orientation.angle,
this.passThroughCamera.orientation
);
if (combinedOrientation !== this.combinedOrientation) {
this.combinedOrientation = combinedOrientation;
this.gl.bufferData(
Laya.WebGLContext.ARRAY_BUFFER,
this.f32TextureCoords[this.combinedOrientation],
Laya.WebGLContext.STATIC_DRAW
);
}
this.gl.enableVertexAttribArray(this.textureCoordAttribute);
this.gl.vertexAttribPointer(
this.textureCoordAttribute,
this.textureCoordBuffer.itemSize,
Laya.WebGLContext.FLOAT,
false,
0,
0
);
this.gl.activeTexture(this.gl.TEXTURE0);
this.gl.bindTexture(Laya.WebGLContext.TEXTURE_EXTERNAL_OES, this.texture);
// Update the content of the texture in every frame.
this.gl.texImage2D(
Laya.WebGLContext.TEXTURE_EXTERNAL_OES,
0,
Laya.WebGLContext.RGB,
Laya.WebGLContext.RGB,
Laya.WebGLContext.UNSIGNED_BYTE,
this.passThroughCamera
);
this.gl.uniform1i(this.samplerUniform, 0);
this.gl.bindBuffer(Laya.WebGLContext.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
this.gl.drawElements(
Laya.WebGLContext.TRIANGLES,
this.indexBuffer.numItems,
Laya.WebGLContext.UNSIGNED_SHORT,
0
);
}[/code]这是Render部分的代码